I’m trying to set up a sensor with a couple of strings as available states. The documentation says that I can use device_class: enum
to do this, using options
to define the possible states:
SensorDeviceClass.ENUM
: The sensor has a limited set of (non-numeric) states. Theoptions
property must be set to a list of possible states when using this device class.
The problem I have is that I’m not sure how to specify the options
. My sensor currently looks like this:
- sensor:
- name: Our House Consumption W or kW
unique_id: our_house_consumption_w_or_kw
state: >
{% if states('sensor.myenergi_our_house_home_consumption')|float(1) < 1000 %}
"W"
{% else %}
"kW"
{% endif %}
device_class: enum
If I put options
at the same level as device_class
then Studio Code Server tells me Property options is not allowed
. But if I try to indent it from device_class
then it sees it as continuation of enum
and complains that I have to choose a correct device_class
.
If anyone’s able to give me an example of how to use enum to define a list of possible states for a sensor, please, that would be great. I haven’t been able to find anything on this forum, or more widely.