Hello,
I have a problem, think it would be easy to solve, but I just can’t get it.
I have a sensor that responds to on / off and simply counts it up (Tasmota / Counter) this value should now be converted and output on a new virtual sensor.
I made the following template for this, but it doesn’t work.
I created this sensor in my configuration.yaml:
platform: template
sensors:
friendly_name: "laufende Meter"
unit_of_measurement: 'm'
value_template: "{{ states('sensor.d1pro_counter_c1') | float * 0.12 | float }}"
Where is my mistake?
Thank you greetings
Gerald
juaigl
(Juaigl)
July 7, 2021, 8:16pm
2
Have a look at this:
sensor:
- platform: template
sensors:
laufende_meter:
unit_of_measurement: 'm'
value_template: "{{ states('sensor.d1pro_counter_c1') | float * 0.12 | float }}"
Edit: seems this is a legacy format. It is working, but there is a new way to do it:
template:
- sensor:
- name: "laufende Meter"
unit_of_measurement: "m"
state: "{{ states('sensor.d1pro_counter_c1') | float * 0.12 | float }}"
More info in Template - Home Assistant
Thanks!
Both worked wonderfully
1 Like
tom_l
July 8, 2021, 5:32am
4
juaigl:
0.12 | float
Just FYI that last float filter is redundant. You can remove it. You don’t need to do that to numbers. Only states.
1 Like