I have a pair of Ecolink TILTZWAVE1 tilt sensors. The sensor reports On or Off. It only shows On/Off on the dashboard. I can never remember which of On or Off means open or closed, so I would like to display the actual state. I have tried to do it by creating a template sensor, but all my attempts have failed, only resulting in a sensor that displayed Off 100% of the time, but never Open or Closed. I’m not posting the code for my actual attempts, as they were derived from suggestions but various AIs, and that is not allowed here.
This is what the device looks like in the Settings / Devices screens :
Using Manual Customization, you can add a device_class: garage_door property to your existing binary sensor. Even easier, you can specify the preferred device_class of your binary_sensor via the UI. No additional Template Binary Sensor is needed.
Be advised that the actual nominal state values of a binary_sensor are always on/off. However, by setting its device_class (“Show as”) to a desired value, then the values will be displayed differently in the Dashboard (example:Open/Closed).
If you absolutely, positively want the entity’s state values to be Open/Closed then, yes, you’re obligated to create a Template Sensor using a simple template like this:
Thanks ! This worked great also, once I typed the correct entity name.
What was confusing to me is that I needed to use “Template sensor” per your instructions. What I had tried was “Template a binary sensor”. And I couldn’t find a way to do it using that later option.
Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which indicates to others that the topic has been solved. This helps other users find answers to similar questions.
A binary sensor has two nominal state values: on and off. In contrast, the nominal state values of a sensor can be whatever you want.