Flappie
(Maarten Brand)
January 23, 2023, 7:40am
1
Hello,
I’m trying to covert a value of 1613.44 to 1613440
The value is in this sensor: ‘{{states(“sensor.heatpump_energy”)}}’
I already tried: ‘{{states(“sensor.heatpump_energy”) | float * 1000 }}’ and that gives me 1613430.0
How do i remove the last .0 from it?
Pipe it to an ‘int’ (integer). So:
{{states(“sensor.heatpump_energy”) | float * 1000 | int }}
EDIT: …oops, yes, there should be brackets in there as described below.
Flappie
(Maarten Brand)
January 23, 2023, 7:55am
3
Already tried that. Still gives me 1613430.0
Troon
(Troon)
January 23, 2023, 7:59am
4
Should have been:
{{ (states("sensor.heatpump_energy") | float(0) * 1000) | int }}
The prior attempt was only int
-ing the 1000. I’ve also added a default value for float
to use in case the sensor value can’t be converted — if it’s unavailable
on start-up, for example.
Flappie
(Maarten Brand)
January 23, 2023, 8:28am
5
Also not working.
Getting this: TemplateSyntaxError: expected token ‘name’, got ‘*’
Troon
(Troon)
January 23, 2023, 8:37am
6
Then you’ve typed something wrong, or have a very old HA installation. Please paste a screenshot.
Flappie
(Maarten Brand)
January 23, 2023, 8:56am
7
My mistake. There was an error in a rule above.
your solution works, thank you
1 Like