Energy Management in Home Assistant

Currently testing this using the getstatistic API (API Specification — PVOutput documentation) and a curl sensor run in a bash script.

solar.yaml


template:
  sensor:
    - name: "Total Energy Generated"
      unit_of_measurement: 'kWh'
      device_class: energy
      state_class: measurement
      state: '{{ states.sensor.total_energy_command.state |float/1000 }}'
      attributes:
          last_reset: '2018-08-06T00:00:00+00:00'
sensor:
  - platform: command_line
    command: './shell_scripts/total_energy.sh'
    name: "Total Energy Command"
    unit_of_measurement: 'W'
    scan_interval: 900

total_energy.sh

#!/bin/bash
curl -s https://pvoutput.org/service/r2/getstatistic.jsp\?key\=[API_KEY]\&sid\=[ID] | awk -F ',' '{print $1}'
1 Like

I thought from the first graph you gave that the Tasmota device might not be setup with correct date/time, so it reset not at midnight, … 'cause I had that problem once.

I have recently updated all my Tasmota devices to 9.5.0 and also moved them all from MQTT integration to Tasmota Integration.

For the power monitor plugs I use (ArlecPC399HA).
Eg. this is my Microwave (currently in Standby)
Arlec-PC399HA

When I setup the Individual Device Monitoring in Energy Management, all I entered was the Energy_Total entities. I did not create any value templates or customise entries.

Try using the sensor.fridge_energy_total ?? rather than the _today value.

1 Like

What attributes are required? I have an Aeotec meter, not the Fronius meter, but here’s what my energy entity has:

sensor.home_energy_meter_electric_kwh
Home_Energy_Meter: Electric [kWh]
2100.45	state_class: measurement
last_reset: 1970-01-01T00:00:00+00:00
unit_of_measurement: kWh
friendly_name: Home_Energy_Meter: Electric [kWh]
device_class: energy

I’m still not getting any grid consumption display out of it (see post # 490).

I have the same problem. did you find a solution?

If you mean me (directly above your comment), no, I didn’t.

no, I am referring @benquan

Yet another way to screw us :face_with_symbols_over_mouth:
First you invest a lot of money in solar panels, then the reversing meter is abolished (which was ‘guaranteed’ for 15 years) and soon we can’t even turn on a washing machine and a dryer at the same time, because then you pay the maximum subscription costs.
And now they’re trying to persuade us to buy a lithium battery.
If we all have one, the insurance premiums will go up again because of the fire risk.
After 20 years, those things have not yet been earned back and you can pay to dispose them.

3 Likes

thanks bro that look like it fix it

1 Like

Yes

I have selective history so I added the cost to the history list.

1 Like

Those attributes I mention are required for it to even be selectable in the energy configuration. You have that working so it looks good. I don’t know why you wouldn’t see any data.

Do you have that sensor excluded from the reporter? Some people have reported that being their issue earlier in this thread.

1 Like

I would ALSO love to be able to measure my battery OOTB. I am using the Fronius integration which is bringing some great data into the system (I have to convert it from W, but that is easy enough).

From the Fronius I get a great graphic - but I would love this in HA so I can do automation (and have one view for the house).

can you explain a bit further what you did?

Does anyone else discover this kind of display bug in the Devices energy graph?
It occurs sometimes when i open the browser after a day or change size of the browser
tab. After a page refresh or click and drag-down the graph shows up correctly.

Devices energy graph: (type: energy-devices-graph )

energy_graph

3 Likes

You need to use the Total value, not Today value. Today resets daily, which results in a lower than previous value, that generates the starting negative value you are seeing.

Would it work if last_reset was set correctly when the daily value ticked over?

1 Like

oh… didnt even consider that as other settings were per day taken. Thx for waking me up :slight_smile:

Having issues getting my stats to show in drop down. I get power stats via emoncms. I have overwrite attributes to Unit of measurement to kWh and set state class to measurement?

1 Like

It has been said many times in this thread and in the 2021.8 release thread, but there are a number of attributes that need to be set. I believe that they are:

state_class: measurement
last_reset: '1970-01-01T00:00:00+00:00'
unit_of_measurement: kWh # or Wh
device_class: energy

Also make sure the entity is measuring energy not power. Power is the rate of consumption of energy. Think of it like this, your heater consumes at the rate of 1.5 kW (power) and in 3 hours uses 4.5 kWh of energy.

2 Likes

‘’’
Thanks so much nickrout! I tried to read though thread must have miss read or understood! I have set device_class to energy. Dont seem to find the last reset but kWh are reset daily. With setting device class to energy still not populating in drop down but will keep trying
‘’

I get the same result no matter I do, the problem is with integration.