Value Translation

I was a control systems engineer and for distributed control system tags there was always an easy way of translating on/off, zero or 1, or even lists of values to text strings, For example for a boolean you could convert an “on/1” to “running” or “open” or “alarm” or any text you wanted. If you had a device that had multiple interger values you could convert them to text. For example 12 = “High”, 13 = “low”, 14=“bad”. In one system they called them digital state tables and you made multiple lists and then applied the table to what in Home Assistant is the entity. For example:

Door Switch
0 Open
1 Closed

Window Contact Switch
0 Alarm
1 Closed

Christmas Tree Lights
12 White
13 Multi Colored
14 Blink White
14 Blink Multi Colored

I have some Zwave garage door sensors I would like to change the text from on and off to open and closed. I found out how to do it but a yaml configuration instead of through the interface. From my web searches I am not the only one that has wanted to do this.

Do you mean something like this ?

1 Like

Device_class -> garage. You can set it through the customize section in the UI.

1 Like

Yes, I had not found the Binary Sensor yet, Thanks!

eh ?

You had not found binary sensor yet you thought that you should launch a feature request without researching your problem ?

Why ?

I did once help a Portuguese guy create sensors (they can’t be binary_sensors) so that when his windows wer open/closed it said so in his users frontend in Portuguese.
I dont think that applies here

It is not that I had not researched the issue, I had. In my web searching I had not found a post that I thought addressed my issue. I was unaware of how the device class addressed both the icon and the state values. I also do not think changing the device class it is at all an obvious solution unless you are very familiar with Home Assistant. There is a lot to Home Assistant/ to learn…

While the answer addresses my specific issue with a garage door sensor there are many other possible situations it may not address.

I see that it is possible to create coustom device classes to address new or different types of sensor. That seems to be a pretty complicated solution to a simple problem. This issue is addressed in the control systems world in a simple manor. You simply configue the string you want displayed for the different states of the device.

As the number of smart home devices increases the device class frame work may fall apart unless device class is a smart home standard. A switch has 2 states but could have dozens of uses therefore values (strings) for the states. While logically for a garage door ‘on’ is equal to “open’ not all switch applications could you assume the mapping of on/off state to displayed string for a device. Also, not all devices fit neatly into binary or analog. Many devices could be none analog devices but have more than 2 states. for example on/off/failed. Maybe some smart home device standard addresses the issue of multi state devices so a multi state none analog device is not an issue.

Yep, but in those exceptional circumstances (actually options for devices have limited contexts, try to think of an example outside those listed) but as stated above there is a way out with template sensors. I have 2 tri state (but they could as easily be 5 or 12 state) sensors one displays my heating segment, day - icon spade, evening - icon cocktail glass, night - icon sleeping.
We can cover almost any eventuality.