Home Energy Management in 2021.8

Glad it’s working now. :slight_smile:

Will it ,over time, give me monthly statistics ?
Or is it just day by day?

Anyone else seen that the calculation of peak and offpeak not correct on energy page?

Well i setup a long time ago with the same device a (utility_device) that calculates the daily usage.
After a day i checked and on the energy dashboard it says i consumed total (4.93kWh) and on my utility_device it’s (4.80kWh) i have a dmsr 5 meter so it goes automatically to peak offpeak and i use the Cumulative device…

When i check the saved (Cumulative device) and do some math the utility_meter shows the correct value…

regards

I have a sensor that mesures the current used at all time, so i want to transform it to kWh, which i have done with a template sensor (see code at the bottom), the template sensor works fine, but it doesn’t turn up as a device in the energy management. Somebody suggested using “last_reset” but that doesn’t seem to be possible with a template sensor? I get a config error if i use “last_reset”. Any tips?

- sensor:

    - name: test_kwh

      unique_id: test_kwh

      unit_of_measurement: "kWh"

      device_class: energy

      state_class: measurement

      state: "{{ states('sensor.test_energy')|float * 0.240 }}"

try with customize integration, check a few posts above.

this is the first version, data goes into the new statistics database, I’m sure we’ll be able to do what we want with data. the default view is the daily one.

Read the blog post, particularly this section: 2021.8.0: Feel the energy ⚡️ - Home Assistant

You can create a statistics card: Statistics Graph Card - Home Assistant

1 Like

put this in the customize.yaml

#your sensorname
sensor.test_kwh:
    unit_of_measurement: kWh
    friendly_name: test_kwh
    icon: mdi:YOUR ICON
    device_class: energy
    state_class: measurement
    last_reset: 1970-01-01T00:00:00+00:00

and this configuration.yaml

sensor:
  - platform: template
    sensors:
        test_kwh:
            friendly_name: test_kwh"
            value_template: "{{ states('sensor.test_energy')|float * 0.240 }}"
            unit_of_measurement:  kWh

Thanks a lot, I will try that out. Do you know if they have plans to change this? Seems like quite a roundabout way to do it, and not all that intuitive (at least not for me :))

Like I wrote today to another person who had the same question: Home Energy Management in 2021.8 - #68 by alexdelprete

I was more thinking about having to use the “customize”-thing, instead of being able to set it directly in the template sensor.

Sensors for long-term statistics need specific attributes in order to be managed correctly. The last_reset attribute is needed in order to understand if it’s a lifetime sensor (it never resets) or if it has to be treated like a daily cumulative sensor, that resets at a specific time. The state_class attribute is needed in order to treat appropriately with the new long-term statistics db: Sensor Entity | Home Assistant Developer Docs

These workarounds with template and customize are not a solution. the thing to do is ask the dev of the integration/component that creates the sensor you use, to set the appropriate attributes on all energy sensors, that’s all. These workarounds are needed in this initial period, hoping that all these integrations get updated to support these new features.

The sensor isn’t an energy sensor, it just measures the current (Amps) of the device. But hopefully the energy measurement will support that kind of sensor in the future, I really like the energy feature :slight_smile:

It won’t. An energy integration has to be fed with energy sensors, not current sensors.

What’s the point of measuring only current? What about power? In your template, you multiply by 240, like power is a constant, but it isn’t. If you measure Voltage, you’ll notice it can be +/- 5-10% respect to what you think. So your templeate sensor will never be accurate.

1 Like

I hope you prediction isn’t right, It should be pretty easy to calculate in the energy from the current (or power for that matter). But we will see, I am at least hopeful.

That is what is measured by the device, sure, it would be nice if it also measured kWH, but you work with the hardware you have. I guess they have a somewhat purist approach as it (as many things like this) only actually measures current, and can’t handle reactive power and the like very good, even if it can assume there is only active power.

Nope, you cannot derive energy from only current, because power is not constant. That’s why energy meters measure Amps, V and also Power Factor.

example: For production, inverters provide info both for voltage and amps, for a reason…

1 Like

Yeah, proper energy meters do that, quite a few of the simple ones integrated in devices that does other things doesn’t measure power factor. But you are right, we can’t be sure the energy is right when just measuring the current.

That’s why the approach is: feed the energy integration with energy sensors, and it’s your responsibility to make sure those sensors provide accurate values. What you get out of the energy card depends on what you put in, excluding bugs, obviously…:slight_smile:

PF maybe not, but V and A, for sure.

1 Like

Yeah, I guess that is reasonable, but then the developer of my “energy sensor” I need to have the appropriate attributes is home assistant :smiley:

Obviously…and in cases where devs don’t support anymore, you can use customize, while waiting for someone to pickup where the previous dev left.

I got it tested now, seems to work fine, thanks a lot.