Invert sensor input states?

Not sure if this is a Home Assistant or ESPHome question.

I just upgraded my Alarm Panel from the previous Konnected firmware to ESPHome. When doing so the state of the sensors has inverted.

Is there a convenient way to invert them via ESPHome, or something I’ve missed in HA without needing to creating sensor templates?

I think I may have solved this. So for anyone else in the same situation here are the details.

The solution was in ESPHome. I had an instance of this running in it’s own Docker container, but I instead added the ESPHome add-in within HA. Following this article allowed me to adopt it.

I then edited the device’s ESPHome yaml with the following for each sensor.

binary_sensor:
  - id: !extend zone1
    pin:
      inverted: true

I had the same problem with sirens. My device is Alarm Panel Pro version 1.8

In Europe, usually the sirens are wired the other way around. Instead of the siren to be silent when there’s no voltage, and make sound when it finds voltage, it makes sound when there’s no voltage and is silent when there’s voltage.

The reason for this is, if someone cuts the wires, to still make noise.

To fix this I had to add this to the default esphome configuration:

switch:
  - id: !extend alarm1
    pin:
      number: GPIO12
      inverted: true
  - id: !extend alarm2
    pin:
      number: GPIO5
      inverted: true

This fixed the issue.

(one more thing, I wasn’t able to compile it, if you have similar problems also add

mdns:
  disabled: true

and it will compile (also remember to clean the build files)