Energy Sensor (kWh) values are accumulated in Utility meter

Hello guys,

I have a Solaredge inverter with a modbus meter.
Everything works like a charm with getting values every 5s over the Modbus tcp from the inverter.

Now i have calculated my own consumption:

        self_consumption:
            friendly_name: "Self consumption"
            value_template: "{{ (state_attr('sensor.solaredge_modbus', 'ac_power_output') | round(2)) - (state_attr('sensor.solaredge_modbus_meter_1', 'ac_power_output') | round(2)) }}"
            unit_of_measurement: 'W'
        self_consumption_kwh:
            friendly_name: "Self consumption"
            value_template: "{{ ((states('sensor.self_consumption')| float) / 1000 )  }}"
            unit_of_measurement: 'kWh'

Now i created two utility meters:

    consumption_daily:
      source: sensor.self_consumption_kwh
      cycle: daily
    consumption_monthly:
      source: sensor.self_consumption_kwh
      cycle: monthly

My problem is that those values were accumulated every 5 seconds.
Can anyone help me with this issue?
Thank you!

Your problem is that you are using a power sensor (W or kW) instead of an energy sensor (kWh).

Simply changing the unit of a power sensor does not change it to an energy sensor.

You need to integrate the power sensor to get energy:

Some advice on which method to use here:

2 Likes

Thank you for this awesome hint, seems to work

1 Like

The integration shown here does not apply to power meters like a Modbus power meter that already integrates the power. I have two of them. I do not see a way to add these to the energy dashboard. The device class is energy from the very 1st day and I have tried to added “state_class: total_increasing” to the sensor but I do not see a new entity available in the energy dashboard. I might be missing something here.