Remove or ignore units?

Hello, i’m sure this is probably really simple, and i’ve probably dealt with it before, but i need a little help to know how to handle a value received via mqtt.

1678 kWh

I’m pretty sure it’s a template that is needed, i just cant quite get all the syntax.

I really just want the 1678 or whatever the value is, so that i can graph it.

Any pointers please?

value_template: "{{ value|replace(' kWh', '') }}"

This replaces ’ kWh’ with nothing.

If you have not done this already, you will also need to add:

unit_of_measurement: kWh

So that the state can be graphed as a number.

1 Like

That works perfectly!
Magic, thanks!