Show in KW instead of W

I am using this to pull the power consumption from Shelly EM.

- platform: rest
  name: Sensor Load
  resource: http://192.168.1.53/status
  username: 'user'
  password: 'pass'
  authentication: basic
  value_template: '{{ value_json.emeters.0.power }}'
  scan_interval: 5
  unit_of_measurement: KW

My problem is that the number is shown in Watts instead of Kilowatts.

1

How can I make it shown in Kilowatts?

Thanks

Assuming power is not a string value:

value_template: '{{ value_json.emeters.0.power / 1000 }}'

Or this if want to limit the number of decimal places:

value_template: '{{ (value_json.emeters.0.power / 1000) | round(2) }}'

If power is a string value then you should use thefloat filter to convert it before performing the division.

Thank you.
Is there also a way to remove all those numbers to the right?
Maybe only keep 2.74?

2

Use the round filter as shown in my second example.

that was very helpful, thank you very much.

You’re welcome!

For the benefit of other users, please consider marking my first post with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has an accepted solution. This can help users find answers to similar questions.

1 Like