Daily/Monthly kWh total

I have a Aeotec G2 Home Energy monitor (HEM)… I used to use Domoticz with this device, which had an excellent system for graphing and totaling powering usage built in. I am trying to achieve some of this functionality in Home Assistant.

Currently the device is configured to report live volts, amps, and watts every 5 seconds. This works fine in Home Assistant. But ultimately I would like a sensor that shows daily power usage in kWh and another that shows monthly usage. But unsure how to go about this. Can any of the built in templating/statistics sensor components do this?

As a side note, the HEM itself also keeps a running total of kWh usage; it accumulates until you issue a RESET command from the Zwave meter command class. My HEM is not configured to report this value though, as I never had to use it. But if this could possibly achieve what I want, I can enable it.

1 Like

any luck in these 5 months waiting for an answer?
im in the same spot

Do you guys use Influx or Grafana? Do you keep the data for one month? How do you want to record (full month/day or last 31days/24hours).

I rather have monthly to compare with power bill, If I ever figure out how to do it automatically.

I would suggest using the same method as I used for cumulative rainfall. Store in an MQTT value and update it each day / week / month etc for your prior cumulative value, from this you can calculate the period value.

see How to: Daily rain sensor from cumulative sensor using MQTT and template_sensor

@Jizar_Stoffel There are multiple solutions for this, but I think it’s time to have a HASS platform for this. Or at least develop a bit more the History Statistics Sensor.

  • One solution would be the one suggested above by @phileep. Excellent idea. However, you need MQTT for this. Enabling MQTT just for this isn’t feasible.

  • Another solution is using an automation that modifies one or more input_boolean components with the value of the sensor in discussion at e.g. midnight, first day of the month etc. I am pretty sure you can also do this with the command line sensor (writing and reading the value to/from a local file). Then with some templating (math operations and some rounding) the value mentioned above should provide what you need.

  • A third solution is using Influxdb and Influxdb sensor platforms. You store all data to Influxdb and then query from HASS using the Influxdb sensor the values you need (in the past). With some more templating and math operations you can get what you need.

  • A forth solution is using Influxdb in combination with Grafana. With Grafana you can get what you need and even more (all kind of charts, customization, grouping etc.).

Let me know if you want me to detail one of the options above.
Cheers.

option one seems good, I already have a mqtt server running, I use it for my sonoffs switches.
Option 2 is also good, but can that change the values on the xml config file for the energy meter?

But the main problem still persist. in HA the meter is not automatic reporting, it only changes values when I restart HA or reboot my Pi

1 Like

Did anyone manage to write the code for hourly / daily / monthly consumption using an adaptation of the daily rain mqtt solution? I have a total current consumption sensor polled every 15 seconds. I’m hopeful I can figure something out, but why reinvent the wheel?