Home assistant converting Wh to kWh (with integration or with a template sensor)
I was looking for a way to convert a home assistant integration entity of Wh to kWh (which is really just dividing by 1000)
In theory, I should be using the “Integration – Riemann sum integral” but it was not working for me for some reason, so attached in this post is also the template way of converting Wh to kWh
On this page
Using Integration – Riemann sum integral
Using YAML
#from https://www.home-assistant.io/integrations/integration/#energy sensor: - platform: integration source: sensor.current_power name: energy_spent unit_prefix: k round: 2
Using the UI
Head over to “Settings > Devices & Services > [ontop of the page] select the Helpers tab > [right down below] hit + Create Helper”
In the create helper wizard pick “Riemann sum integral sensor”
Pick a name for your conversion sensor and the source of the data
Using a template sensor
template: - sensor: - name: "Hallway heater (template sensor) kWh" unique_id: hallway_heater_template unit_of_measurement: kWh state: "{{ states('sensor.hallway_heather_energy_consumption')|float/1000}}" device_class: energy state_class: total_increasing attributes: last_reset: "1970-01-01T00:00:00+00:00"