Help setting up Utility Meter Sensor

Hi,

I have an electricty sensor that reports power and energy in watts. I understand that the utility meter needs values in kWh.

image

Is this the correct configuration? Not sure I have my calculations correct for the kWh

sensor:
  - platform: template
    sensors:
      electricity_energy_kwh:
        friendly_name: "Electricity Energy"
        unit_of_measurement: 'kWh'
        value_template: "{{(state_attr('sensor.energy_monitor', 'lwrf_energy') | float / 1000) | round(2)}}"
      electricity_current_power_kw:
        friendly_name: "Electricity Power"
        unit_of_measurement: 'kW'
        value_template: "{{(state_attr('sensor.energy_monitor', 'lwrf_power') | float / 1000) | round(2)}}"
        
utility_meter:
  electricity_hourly_khw:
    source: sensor.electricity_energy_kwh
    cycle: hourly
  electricity_daily_khw:
    source: sensor.electricity_energy_kwh
    cycle: daily
  electricity_weekly_khw:
    source: sensor.electricity_energy_kwh
    cycle: weekly
  electricity_monthly_khw:
    source: sensor.electricity_energy_kwh
    cycle: monthly
  electricity_quarterly_khw:
    source: sensor.electricity_energy_kwh
    cycle: quarterly
  electricity_yearly_khw:
    source: sensor.electricity_energy_kwh
    cycle: yearly
1 Like

Power is measured in Watts. Energy is measured in Watt hours, or Watt seconds (a Joule), or Watt minutes.

So if your energy sensor does report in Wh all you need to do is divide by 1000 to get kWh. In which case your electricity_energy_kwh template is correct.

It it reports in Ws or Wmin you need further math.

However:

This is not true. If you feed the Utility meter with Ws it will output Ws. If you feed it kWh it will output kWh. It can work with any unit of energy, or capacity (Litres or m3, of gas or water for example).

Perfect, thanks!