kodebach / hacs-idm-heatpump

HACS integration for IDM heat pumps
MIT License
20 stars 1 forks source link

Sometimes very wrong values for "Aktuelle Leistungsaufnahme Wärmepumpe" #61

Closed AndyNew2 closed 7 months ago

AndyNew2 commented 7 months ago

´From time to time I have spikes in the graph and the reason is a very wrong value for "IDM_Wärmepumpe: Aktuelle Leistungsaufnahme Wärmepumpe". It jumps for one read (60sec on my integration) to the wrong value and jumps immediately afterwards back to the correct one. I saw it jumps to 20,64kW(!) Input Power for my heatpump and return immediately afterwards to 0,20 (which is the off state). I think there a a locking issue, when reading a float value with two source values. This could be done of course wrong on the IDM_heatpump as well. So there might be nothing wrong with the integration. However it always corrupts the graphs and make the interesting part hard to see, since HA automatically adjusts the scaling to the biggest value, even there are wrong....

An easy fix could be to read the value again, if it changes too much from last reading (with this extrem example we could even allow an increase of 100% and any growth below 1kW. Or we do the reread based on plausability. A input power more than 10kW seems wrong and should be checked via re-read.

idm_heatpump_screen

kodebach commented 7 months ago

Hm, yes that is weird. Now that I look at it, it happens with my set up as well... I've even got values as high as 32 kW and it also happens when the heat pump is actually running.

Seems like an issue on the heat pump side. At least I have no idea how the integration would be at fault here. The raw 32-bit value is read via Modbus and then interpreted as a floating point number. The process is always the same so, if the error only occurs sometimes I don't think the integration is at fault...

An easy fix could be to read the value again, if it changes too much from last reading

What is "too much"? I have legit jumps from 0 to 3 kW (and maybe even more) when the heat pump starts. A percentage won't work (division by zero). Even limiting the growth in kW is hard, because the integration would have to remember previous values without giving them to Home Assistant to track the growth properly.

Best thing I could to is add a field to the integration configuration, where you can set the maximum input power of your heat pump model. Any value above that would be reported as "Unavailable". Then Home Assistant would just show a gap in the graph instead of the spike.

AndyNew2 commented 7 months ago

As long as your integration reads the 32bit value in one go, there is nothing wrong in your integration, the issue is in the heatpump, since they probably set it together from two 16bit values with might be not aligned.

The solution is easy. I propose following algorithm: If a change more than 3kW from previous reading is detected it reads the value again from heatpump. So it is the difference from previous reading not a percentage, that avoids any divison by 0 issue when the heatpump starts. In case, as you told the change is actually real nothing harmful would happen. What is the result not trusting the value, correct it is just reading it again. So if the change is actually so high, it would read again the same value and the second time it is trusted. The drawback for this algorithm is, it might read a value twice when the change is too big. If that happens only a few times a day, no real issue.

kodebach commented 7 months ago

fixed in v0.6.1

AndyNew2 commented 7 months ago

Just a quick question. Have checked the implementation, so you do a simple compare to max. power. Is the reading again, not an option, since it would take too long? It would read it twice in case not plausible. That would prevent gaps, and would no need for configuration. I am just curious, I am OK with this implementation as well.

kodebach commented 5 months ago

In v0.7.0 the integration tries to read a second time, not sure if it will help, but it should cause any harm.