Converting a value from Watt to Kilowatt

I’m just starting to use Home Assistant.

Can someone explain me how I can turn a value of a sensor indicated in Watt into a Kilowatt value ?

Thanks

1 Like

Hi there…You can create a template senor and convert the value like this.

sensor:
  - platform: template
    sensors:
      kilowatt_sensor:
        friendly_name: "Kilowatt Sensor"
        unit_of_measurement: "kW"
        value_template: "{{ states('sensor.entity') | float * 0.001 }}"

please change the senor.entity to your sensor with watt value

3 Likes

Thanks for the input. I save this script in the configuration.yaml ?

yes you should copy this to configuration,yaml. then restart HA.

instead to convert it to kwh?

Use the integration integration :wink:

@koying

like this?

sensor:
  - platform: integration
    source: sensor.current_power_watt
    name: energy_spent
    unit_prefix: k
    round: 2

Hi
I am trying to convert a sensor from W to Kwh with the integration, and I don’t think it is working correctly.
imagen

Mi configuration.yaml

  • platform: template
    sensors:
    acaprox:
    value_template: “{% set wac = states(‘sensor.shelly_cocina_vitro_horno_consumo’) | float - states(‘sensor.pcsmario_power’) | float - states(‘sensor.blitzwolf_power’) | float - states(‘sensor.blitzwolfestufasalon_power’) | float - 160 %}
    {% if (wac) > 0 %}
    {{wac | float | round (3)}}
    {% else %}
    0
    {% endif %}”
    friendly_name: ‘Power Aprox AC’
    unit_of_measurement: ‘W’

  • platform: integration
    source: sensor.acaprox
    name: KwhACAprox
    unit_prefix: k
    unit_time: h
    round: 3

How is it possible that it appears in seconds with 8 Kwh calculated?
imagen