Quick question about templates and scripts.
When checking in a template such as is_state, can I use on and off for a any device class or must I use the proper adjective(such as open and closed)?
Do the same rules apply to scripts?
the best thing to do is to go to Developer Tools > States and look for that specific entity.
It will show you the state it’s at.
Then you can go to Template and test your code to see the results.
Simply entering this will show you what to expect/write:
For a binary_sensor, its two valid states are on and off and are the values you would use in a template.
When you specify a device_class (battery, door, heat, window, etc), it causes the entity to display descriptive states for the device_class (low/normal, open/closed, hot/normal, etc). These are just for display in the UI (they are ‘just for show’) and not for use in templates.
If the discussion is about sensors, then they can have many kinds of states and, as per lolouk44’s recommendation, it’s best to examine them in the States page to learn about their valid states.
That totally makes sense. I was looking at examples that were using sensor domain devices not binary_sensors. That would explain the Open/Close.
Thanks!