Hi guys
I recently wanted to create entities starting from some attributes coming from my Tuya plug. I created a template using forums and suggestion on here but when i try to restart HA, i get this error:
The system cannot restart because the configuration is not valid: Invalid config for [sensor.template]: invalid template (TemplateSyntaxError: expected token ‘,’, got ‘current’) for dictionary value @ data[‘sensors’][‘scrivania_curr’][‘value_template’]. Got “{{ state_attr('switch.scrivaniatest’,‘current’) }}” invalid template (TemplateSyntaxError: expected token ‘,’, got ‘current_consumption’) for dictionary value @ data[‘sensors’][‘scrivania_cons’][‘value_template’]. Got “{{ state_attr('switch.scrivaniatest’,‘current_consumption’) }}” invalid template (TemplateSyntaxError: expected token ‘,’, got ‘voltage’) for dictionary value @ data[‘sensors’][‘scrivania_volt’][‘value_template’]. Got “{{ state_attr('switch.scrivaniatest’,‘voltage’) }}”. (See ?, line ?).
I did for sure some mistake writing the code and i’m stuck because i can’t figure out what it is.
This is my code:
sensor:
- platform: template
sensors:
scrivania_cons:
unique_id: “scrivania_cons”
friendly_name: “Consumo scrivania"
unit_of_measurement: “W”
value_template: “{{ state_attr('switch.scrivaniatest’,‘current_consumption’) }}”
scrivania_curr:
unique_id: “scrivania_curr”
friendly_name: “Corrente scrivania”
unit_of_measurement: “mA”
value_template: “{{ state_attr('switch.scrivaniatest’,‘current’) }}”
scrivania_volt:
unique_id: “scrivania_volt”
friendly_name: “Voltaggio scrivania”
unit_of_measurement: “V”
value_template: “{{ state_attr('switch.scrivaniatest’,‘voltage’) }}”
It basically takes the attributes values (which i can see in the developer tap so they are working) but i can’t understand the problem.