luxtronik icon indicating copy to clipboard operation
luxtronik copied to clipboard

Long term statistics sensors for HA Home Energy management

Open WhistleMaster opened this issue 4 years ago β€’ 34 comments

Hi !

Since 2021.8.0, a new Home Energy management has been added to HA.

Utility Meter can be configured to track consumptions of various utilities (e.g., energy, gas, water, heating).

But, to be able to use an utility meter, the sensor has to integrate long term statistics.

For my luxtronik heatpump, I have the following sensor kwh:

  • luxtronik.id_web_wmz_heizung
  • luxtronik.id_web_wmz_brauchwasser

Thanks ! Regards,

WM

WhistleMaster avatar Aug 25 '21 16:08 WhistleMaster

Not the complete implementation for long term statistics, but it's a start :-) #23

WhistleMaster avatar Aug 30 '21 14:08 WhistleMaster

A requirement to opt-in for statistics is that the sensor has state_class set to one of the valid state classes: measurement or total_increasing. In our case, if I'm not wrong, the two sensors should have the measurement class.

WhistleMaster avatar Aug 31 '21 05:08 WhistleMaster

I've not yet read much about the HA energy management. Can only certain measurement units (kWh etc.) be used in the energy dashboard? If so, can we automate that by checking the sensor type and apply the needed state_class?

Bouni avatar Aug 31 '21 06:08 Bouni

I've not yet read much about the HA energy management. Can only certain measurement units (kWh etc.) be used in the energy dashboard?

Indeed, only the energy one can be integrated.

If so, can we automate that by checking the sensor type and apply the needed state_class?

I think so. I've tried to add a new property def state_class(self) and test the type of sensor and if it's CONF_ENERGY, return the measurement class, without success.

WhistleMaster avatar Aug 31 '21 06:08 WhistleMaster

I'm not sure, but from others custom components I've seen, they are using async_add_devices instead of add_entities (sensor.py#L67). Could it be a problem here ?

WhistleMaster avatar Aug 31 '21 06:08 WhistleMaster

πŸ€” the async prefix only indicates that they use asynchronous funtions, but I dont know the difference between add_devices vs. add_entities. I think I've read a long time ago that HA changed their terminology about whats a device / entity / integration / component and so on. To be honest, I never really understood whats the right thing to use πŸ˜…

Bouni avatar Aug 31 '21 06:08 Bouni

Maybe a bit offtopic, but anyway: I thought about rewriting this entire thing anyway someday and make it configurable via the UI. This just did not yet happen because I lack the neccessry amount of spare time to do this 😞

Bouni avatar Aug 31 '21 06:08 Bouni

It is a good time to rewrite. Recently, lots of sensor implementations are refactored using EntityDescription, which alleviates you from lots of boilerplate and makes it kinda convenient: https://github.com/home-assistant/core/pulls?q=is%3Apr+is%3Aclosed+EntityDescription

What’s needed for statistics is mostly covered in https://developers.home-assistant.io/docs/core/entity/sensor/

Please note the rules for the two state classes to be allowed for statistics, e.g. for the measurement class:

The state represents a measurement in present time, not a historical aggregation such as statistics or a prediction of the future.

andre-richter avatar Aug 31 '21 08:08 andre-richter

Okay so I added the luxtronik sensors the same you also used... But I have no Idea how to make them total_increasing instead of measurement.... Can someone tell me how you did it? I'm lost....

Kh3nsu avatar Sep 05 '21 11:09 Kh3nsu

It's not yet ready in the actual code so the only way at the moment is to create new utility_meter with those sensors:

utility_meter:
  heat_energy:
    source: luxtronik.id_web_wmz_heizung
    cycle: daily
  
  water_energy:
    source: luxtronik.id_web_wmz_brauchwasser
    cycle: daily

WhistleMaster avatar Sep 05 '21 11:09 WhistleMaster

Okay thank you ^^ So its going to be supported natively by this integration later?

Kh3nsu avatar Sep 05 '21 11:09 Kh3nsu

Why are we resetting the value every day? I mean isn't it a total value which is increasing indefinitely? Why setting it to 0 every day? Doesn't that give the wrong values in the Energy Dashboard? Or do I not fully understand how the dashboard works?

Kh3nsu avatar Sep 05 '21 12:09 Kh3nsu

Yes it is a total value which is increasing but I want to have the calculation done every day, that's why I have the daily cycle setup. The "reset" is done on the new sensors created based on the two others from the luxtronik integration. The one from the integration are not reset, and keep increasing. If you setup a monthly cycle, then you will get the calculation done every month.

WhistleMaster avatar Sep 05 '21 12:09 WhistleMaster

Mhh okay so for the energy dashboard hourly would be the best because its updating every hour as well right? The best would be to just put in the value which is increasing all the time. How can I do that?

Kh3nsu avatar Sep 05 '21 12:09 Kh3nsu

Well that's the point, you can't with the actual integration, it has to be updated to add the long term statistics.

WhistleMaster avatar Sep 05 '21 12:09 WhistleMaster

Oh okay but wasn't that added with the newest version 1.21? Cause it says "Allow long term statistics for use with energy dashboard" or is that something different?

Kh3nsu avatar Sep 05 '21 12:09 Kh3nsu

No I did a quick PR as a start but it far from the complete implementation for those. https://github.com/Bouni/luxtronik/issues/22#issuecomment-908384015

WhistleMaster avatar Sep 05 '21 12:09 WhistleMaster

Maybe a bit offtopic, but anyway: I thought about rewriting this entire thing anyway someday and make it configurable via the UI. This just did not yet happen because I lack the neccessry amount of spare time to do this 😞

@Bouni I have start writing a new gui config based version of your component: https://github.com/BenPru/luxtronik

BenPru avatar Oct 24 '21 18:10 BenPru

Hello,

I just discovered that those values: luxtronik.id_web_wmz_heizung luxtronik.id_web_wmz_brauchwasser are not really the power what the heatpump draws. It is what the heat pump has produced in heat in kW. Because a heat pump does not convert 1 kW of electricity into 1 kW of heat, most of the time it produces more heat for less electricity (1 kW of electricity = 3 kW of electricity). That is rather variable.

My house has consumed 35.4kWh today. However, the heat pump says that it has already consumed 59.3kWh for heating alone and hot water 5.1kWh.

My utility meter:

luxtronik_heat_energy:
  source: luxtronik.waermemenge_kwh_heizung_raw
  cycle: daily
  
luxtronik_water_energy:
  source: luxtronik.waermemenge_kwh_warmwasser_raw
  cycle: daily

I think we really have to ask Novelan how to calculate the real power draw or can someone enlighten me on this?

Kh3nsu avatar Dec 01 '21 22:12 Kh3nsu

Indeed it is not related to power draw by the heat pump but the energy produced for water and heat.

WhistleMaster avatar Dec 02 '21 06:12 WhistleMaster

Yeah thats actually not very useful for any energy measuring in home Assistant :/

Do you know the correct value I have to use?

Kh3nsu avatar Dec 02 '21 07:12 Kh3nsu

Yeah thats actually not very useful for any energy measuring in home Assistant :/

Well, it depends what you would like to monitor πŸ˜ƒ

Do you know the correct value I have to use?

I'm not sure if there are any other parameters that could fill that requirement unfortunately.

WhistleMaster avatar Dec 03 '21 13:12 WhistleMaster

Ok so I just asked the support... There really is no value :(

Kh3nsu avatar Dec 07 '21 17:12 Kh3nsu

I just wanted to ask if there is any update on this. Did the support tell you something useful? I've searched on the internet and in the openHAB Forum someone stated that:

electrical power = heating power / COP

https://community.openhab.org/t/luxtronikheatpump-finding-the-currently-drawn-power/121605/12

The COP is stated on the outdoor part of my heatpump (4.5 in my case). Using that value I do come close to the value my energy counter of the house states. But it's not quite accurate (assuming both started at 0. I do not know that.).

Did someone find a way to extract the "real" power consumption of the heatpump?

dr-waterstorm avatar Feb 25 '22 12:02 dr-waterstorm

Well sadly I did not :/ The support told me that there is no value given by them to extract. So we have to figure it out with some other method.

With the electricalpower= heating/COP

What exactly is COP and is heating the current heating generating value or the total?

Kh3nsu avatar Feb 25 '22 12:02 Kh3nsu

Too bad :(

COP is the Coefficient of performance For my test I was using both values given by the heatpumpt and divided each by the COP stated on my heat pump. The sum of both gives me veeeery roughly the value that my energy counter states for total consumption.

But actually I'm very new to this topic, so I have no idea if that is the way one should/would do this. I'm just playing around with the values for now. Maybe someone could enlighten us.

dr-waterstorm avatar Feb 25 '22 12:02 dr-waterstorm

Well I guess the only way to do so is to install something between the heat pump and the main power. Maybe a Shelly?

Kh3nsu avatar Feb 25 '22 12:02 Kh3nsu

Probably, yes. My guess would be that the COP (and therefore the calculation) depends on external factors such as temperature, so I guess it would be pretty hard to calculate a good value.

Small update: Justed read up on this. The COP on my device is stated as A7/W35 which means for an air temp of 7 degress and a water temp of 35 degrees. So yep, depends on the temperatures. However mine states 4.5 on the device, but when I actually calcuate the COP myself (of course it's not A7W35 all the time ;-) ) using the overall power used vs. the data from the heat pump I get more like ~2.81

Using something like a shelly is probably pretty accurate. However in my case that would require re-wiring (because the heatpump is directly connected and not plugged in to a standard power socket), which I cannot and will not do myself. Too bad :-/

I'll test this calculation for a few days, let's see how "accurate" it is

dr-waterstorm avatar Feb 25 '22 12:02 dr-waterstorm

Well I guess the only way to do so is to install something between the heat pump and the main power. Maybe a Shelly?

I have a seperate power meter for my heatpump (one of these "smart meters" also known as EHZ in Germany and probably other parts of Europe). With the upcoming EHZ support I will build a ESP / ESPhome based senor for it. In my opinion thats the only way to tell what a heatpump actuall yuses in terms of electic power ...

Bouni avatar Feb 25 '22 14:02 Bouni

We sadly don't have a seperate power meter for our heat pump :/ So I guess this solution is not usable for me.

Kh3nsu avatar Feb 25 '22 15:02 Kh3nsu