Converting 1613.40 to 1613400

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.

Already tried that. Still gives me 1613430.0

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.

Also not working.
Getting this: TemplateSyntaxError: expected token ‘name’, got ‘*’

Then you’ve typed something wrong, or have a very old HA installation. Please paste a screenshot.

My mistake. There was an error in a rule above.
your solution works, thank you :slight_smile:

1 Like