Need help to calculate Total Watt from sensor

Hi,

I had a sensor outputting live power readings via MQTT to HA in Watt.
How can I calculate the total power used / hour / day.
Is there any way that I can store the day’s usage and add it up to calculate the total usage for the month.

Thanks in advance.

if your output looks like a square sign wave, use the integration integration. It gets the area under the watt curve, which is the result you are looking for, a Wh. But you can make it into a kWh so it matches your monthly bill.

sensor:
  - platform: integration
    source: sensor.current_power
    name: energy_spent
    unit_prefix: k
    round: 2
    method: left

If your live output reading is more of a ‘flowing sign wave’, change the method to trapezoidal. But be warned, trapezoidal can get wildly incorrect numbers if your device sits at 0 watts for hours on end. You do not want to use this for a washing machine or something like that.

Once you have that sensor, you can use the utility meter integration to calculate even more stuff.

1 Like

Thank you, will try this out and peek you posted.