Hi.
I have a d-link switch that monitors consumption.
The template
'{{ state_attr('switch.asciugatrice', 'current_power_w' ) | float }}'
works in the sandbox.
Instead, this, to hava a sensor to display and use in an automation,
- platform: template
sensors:
consumo_asciugatrice:
value_template: '{{ state_attr('switch.asciugatrice', 'current_power_w' ) | float }}'
friendly_name: "Consumo"
unit_of_measurement: "W"
results in a configuration error.
I can’t understand where I am wrong.
Thanks in advance.
lolouk44
(lolouk44)
2
you can’t use single quote to enclose your value_template AND to define the strings inside the value_template.
Try:
- platform: template
sensors:
consumo_asciugatrice:
value_template: '{{ state_attr("switch.asciugatrice", "current_power_w" ) | float }}'
friendly_name: "Consumo"
unit_of_measurement: "W"
or
- platform: template
sensors:
consumo_asciugatrice:
value_template: "{{ state_attr('switch.asciugatrice', 'current_power_w' ) | float }}"
friendly_name: "Consumo"
unit_of_measurement: "W"
4 Likes
I think I had tried both, but I’ll give that a new try.
Thank you
My fault
Thank you again.
1 Like