Energy Management in Home Assistant

Your post has no context, you haven’t replied to another post.

Same result as what exactly?

which integration?

What did you try?

Your a LEGEND, thanks for your time to respond! I added attribute of other, set attribution name to last_reset and attribuite value to ```
1970-01-01T00:00:00+00:00

and now get the drop down in energy!!! Whoop whoop, lets hope it calculates correctly :wink:
1 Like

Got you! I have changed W to Wh, however, nothing show up again, do I need to restert HA?
image
image

UPDATE:
Ok so what you need to do in order for the thing to work: make sure you have Energy kWh measurement in your system, I have it in configuration file.
If you have Power, which is instant measurements, you can change it to kWh, which mend that if you use instant data 1 hr and devide it to 1000 you will have kWh:

      - name: Pgrid 
        address: 25214
        scan_interval: 10
        slave: 4
        input_type: holding
        scale: 0.001
        offset: 0
        unit_of_measurement:  "kWh" 
        precision: 1
        device_class: energy

Then you should go to Configuration tab → Customization and find your device there and add state class: measurement:

Hit SAVE, check again your configuration files and restart HA!

And you still get nothing )))

Below two devices, one is MQTT and it works, other MODBUS and it doesn’t!

unit_of_measurement: kWh
friendly_name: Pgrid
device_class: energy
state_class: measurement

state_class: measurement
unit_of_measurement: kWh
friendly_name: Washing_Machine ENERGY Total
device_class: energy

Okay… so I have the DSMR Integration, but I’m stuck at what to add where?

These are the entities that I have:

Using “Energy Consumption” for the consumption section is obvious, but should I add “Energy Production” to the solar panels, or is the “Return to grid” ? And if so, where do I get the other entities (return to grid, or solar production?)

Hi. I have the same setup and this works perfect:

If you also have solar panels you need to connect HA somehow to your inverter to get the production data.

2 Likes

Ahh, that’s good insight… but no, while I have defined the domains for the recorder, I did not exclude this one:

# Recorder filter to include specified domains and exclude specified entities
recorder:
  include:
    domains:
      - light
      - climate
      - switch
      - sensor
      - binary_sensor
      - device_tracker
      - person
      - cover
  purge_keep_days: 180

However… I’ve just found something weird. While checking history, I noticed that the energy sensor I’m monitoring is flatlined:

That’s why I’m not getting anything on my Energy dashboard! But why is it not updating? I’ve gone into my meter config (AEON Labs gen 5 meter) and my kWh reporting is enabled, along with voltage, amps, etc… and those values are definitely updating:

It’s a valid entity… so… what the heck? I’ve just enabled another kWh report from Group 2–there are three reporting groups for this meter–to see if that one will work.

It could be because the energy monitor integration doesn’t display based on the sensor, but on the statistics. You can check the statistics as per my post here:

Hoping for this too. I cobbled together some sensors that read data from RTL-AMR and report usage and cost in a few different ways, but this August update has much more potential.

So I am looking to see if anyone has some ideas on how to handle the setup I have to make it work with the new energy dashboard. I currently collect energy data through a Brultech Greeneye energy monitor which collects energy data on every circuit in my house. The device also has a separate channel that collects the main lines and solar. This system collects data in watt-seconds that is continuously increasing, decreasing in the case of solar. Through a python script it is converted to watt-hours and stored in Influxdb. I am using the influxdb integration to pull this data into home assistant and then use a template sensor to get it into the right format for the energy dashboard to display the data.

This works great for the individual circuits/devices chart. The problem I have is with the grid consumption and the export consumption. Technically my mains line is recording net usage. So I can’t just pipe in the value directly from influxdb. Obviously some math needs to be done, but I am not sure about the best way to do it. I can stumble through writing yaml code and template sensors, just takes me awhile. I imagine the best way to do this is to some sort of intermediate calculation that is then piped into the template sensor for the energy dashboard.

I think I need this logic. Which would produce a watt-hour counter that the dashboard is expecting.

If (main_wh_now - main_wh_15min_ago) > 0 THEN
grid_consumption = (main_wh_now - main_wh_15min_ago) + previous grid_consumption value

If (main_wh_now - main_wh_15min_ago) < 0 THEN
export_grid = (main_wh_15min_ago - main_wh_now) + previous export_grid value

I found the answer here for setting the currency. if you have homeassistant: defined in your config you have to set it there

1 Like

@BillRandolph Same here with rtlamr - but I’m stuck, I think. I’m successfully sending the data to HA via MQTT, which results in a sensor.elec_meter that shows the correct current meter reading.

That’s cool - but my sensor.elec_meter doesn’t show up on the “Grid Consumption” drop down. Do I need to create some other sensor?

@ kr_noob
You need to go into the definition for the sensor or the customization page for it and define a state_class of measurement, a device class of energy, and a last_reset of ‘1970-01-01T00:00:00+00:00’

If you have a power output, you can use this integration for energy consumption calculation. Accuracy will depend on the number of times power gets updated

1 Like

So weird there is no mentioning of this in the “official” docs link…
image

I have added a proposed change via github with your information added.

2 Likes

I hope I’m right then :slight_smile:

Time must be in sync time and timezone wize between HA and your measurements.

Not sure if HA uses the selected timezone from configuration or always UTC to determine the new day.

But a mismatch here will give the negative start value. As it sees the last measurement from yesterday as starting point. And then when it drops to 0 because the next day starts for your device HA calculates the negative value.

So I think you should try to start with comparing the last reset value timezone

this is awesome!
just playing around with it now.

just to confirm, with my TP Link plugs, would I use either:
Current Consumption or Daily or Total Consumption?
or does it not matter at all?

1 Like

Works like a charm with homewizzard.
The only thing I would like to know is which smart plugs I should buy for power monitoring (EU/16A) that work ‘out of the box’ without flashing or soldering, preferably with zigbee.
I now have different Tuya variants (Gosund, Elivco) that only show the consumption in the app and not in Home assistant
Any advise is welcome :wink:

I am also keen to be able to use template sensors - just succeeded in connecting my Smart meter to my HA Rpi, information from P1 protocol is extracted using template sensors. Or would there be a workaround to get this information into Energy Dashboard ?

The same trick can be done to go from template-sensor like you have into a new template-sensor. There are multiple posts above which show the format