I have a FordPass integration that returns an attribute of a 0 if unplugged and 1 if plugged in. I want it to return Unplugged/Plugged In. I have extracted the “Plug Status” attribute with the below in my /config/configuration.yaml:
- name: Eva - Plug Status
state: "{{ state_attr('sensor.fordpass_elveh', 'Plug Status') }}"'
That works, creating ‘sensor.eva_plug_status’. Now I want to go the next step and make the 0 return “Unplugged” and a 1 “Plugged in”.
I added the below to my configuration.yaml. The template below produces the desired return in the developer tools Template Editor.
' - name: Eva - Plugged in to EVSE
device_class: connected
value_template: >-
{%- if is_state("sensor.eva_plug_status", "on") -%}
Unplugged
{%- else -%}
Plugged in
{%- endif -%}'
That generates the error below:
Logger: homeassistant.config
Source: config.py:820
First occurred: 16:30:51 (1 occurrences)
Last logged: 16:30:51
Invalid config for [template]: expected SensorDeviceClass or one of ‘apparent_power’, ‘aqi’, ‘battery’, ‘carbon_monoxide’, ‘carbon_dioxide’, ‘current’, ‘date’, ‘duration’, ‘energy’, ‘frequency’, ‘gas’, ‘humidity’, ‘illuminance’, ‘monetary’, ‘nitrogen_dioxide’, ‘nitrogen_monoxide’, ‘nitrous_oxide’, ‘ozone’, ‘pm1’, ‘pm10’, ‘pm25’, ‘power_factor’, ‘power’, ‘pressure’, ‘reactive_power’, ‘signal_strength’, ‘sulphur_dioxide’, ‘temperature’, ‘timestamp’, ‘volatile_organic_compounds’, ‘voltage’ for dictionary value @ data[‘sensor’][3][‘device_class’]. Got ‘connected’ extra keys not allowed @ data[‘sensor’][3][‘value_template’]. Got ‘{%- if is_state(“sensor.eva_plug_status”, “on”) -%} Unplugged {%- else -%} Plugged in {%- endif -%}’ required key not provided @ data[‘sensor’][3][‘state’]. Got None. (See /config/configuration.yaml, line 34).
What am I doing wrong?