Whenever I add “device_class” as per my below example and the link above my config validation fails with a message that says
sensor.template:
- Invalid config for [sensor.template]: [device_class] is an invalid option for [sensor.template]. Check: sensor.template->sensors->battery_front_door_sensor->device_class. (See ?, line ?)
Here is my config
- platform: template
sensors:
battery_front_door_sensor:
friendly_name: Front Door Sensor Battery
unit_of_measurement: ‘%’
device_class: battery
value_template: >-
{%- if states.zwave.front_door_sensor.attributes.battery_level %}
{{ states.zwave.front_door_sensor.attributes.battery_level|round }}
{% else %}
{{ states.sensor.battery_front_door_sensor.state }}
{%- endif %}
When I comment out the device_class line everything works as expected.
Am I doing it wrong or are the docs outdated or did I find a bug?
Please format your code correctly using 3 `'s (upper left button on keyboard) or using the </> button in the editor.
anyways from the looks of it, device_class is not a valid option for template sensors, that can only be done in the customization. Remove that and you should be fine. If you want to add the device_class to the sensor, do it in the customization section.