Binary Sensor - Status Name Reversed

I have a over 30 dry contact sensors connected to doors, float switches and other devices where the contact is either open, usually indicating that a door is open, or closed, the float switch has triggered, etc. These sensors are connected to an ESPHome board which In Home Assistant defaults to a switch where “On” indicates that the door is closed and “Off” indicates that the door is open. But when I change the name, icon, etc. and select “Door” from the “Show As” drop down “On” changes to “Open” and “Off” changes to “Closed,” the opposite of what I would expect. The same for other Show As options such as moisture sensors where “On” indicates “Dry.” Is there a way to reverse the labels? I suspect I am missing something very fundamental.
I am new to Home Assistant, moving from an obsolete legacy system so forgive the simple question. Thanks.

(post deleted by author)

I would concentrate on fixing the ESPHome configuration…

1 Like

(post deleted by author)

No there isn’t and no you are not missing anything. See this feature request: Inverting or reversing binary sensor display states

Normally the only option is to create inverted template binary sensors for each of your devices. Like this:

template:
  - binary_sensor:
      - name: "Custom Sensor Name"
        device_class: motion # or occupancy
        state: "{{ is_state('binary_sensor.your_sensor', 'off') }}"
        availability: "{{ has_value('binary_sensor.your_sensor') }}"

However because you said:

You have a much easier option. For each of your GPIO inputs on your ESP devices you need to specify this:

inverted: true

See: Configuration Types — ESPHome

Share your ESPHome config if you need help with this.

1 Like

If the sensors are defined as a switch in EspHome too, then all you need to do is add the inverted: true in the sensors for which you want the states to be flipped.

If they’re set up as binary sensors, then you can achieve the same thing by adding:

    filters:
      - invert:

The pin schema works at the hardware level of the GPIO port, filters are a software layer on top of this. Both will work but I prefer using the ESP hardware options if available. Less for the CPU to do.

2 Likes

Editing the YAML file solved the issue. In my case I had to switch inverted to false from true. Thanks you all for the very helpful advice.