Template from Wh to KWh

Hi I have this REST data

“emeters”:[{“power”:811.25,“reactive”:-507.50,“voltage”:227.16,“is_valid”:true,“total”:2264.8,“total_returned”:0.0},

using this REST sensor I able to get the ENERGY value but its in Wh, I need KWh.

Please help in how to change the template


  - platform: rest
    resource: http://192.168.1.150/status
    name: Potenza Generale Consumata
    value_template: '{{ value_json.emeters[0]["total"]  }}'
    scan_interval: 10
    unit_of_measurement: "KWh"

There might be other solutions but try:

value_template: '{{ value_json.emeters[0]["total"]  | multiply(0.001) | float }}'

Hi, thanks!!

I did this, is it wrong?


value_template: '{{ value_json.emeters[0]["total"] / 1000 }}'

Not sure about the ["total"] and I have trouble with the “/” so I use multiply instead. I think it should be

value_template: '{{ value_json.emeters[0].total | multiply(0.001) | float }}'

But use whatever that works!

EDIT: both .total and ["total"] works.

Just a pedantic point but the units of measurement should be “kWh” as upper case “K” is Kelvin, lower case “k” is kilo