Hypfer / deye-microinverter-cloud-free

Documentation and tooling to use Deye microinverters without the solarman cloud
123 stars 17 forks source link

Handling Last Reported Values When Inverter Goes Offline #5

Closed k2iuh closed 1 year ago

k2iuh commented 1 year ago

I've been using the dummycloud for a few days now, and it's impressively stable and reliable. Thanks for your excellent work on this!

However, I've come across an issue. When my inverter goes offline (typically when it gets dark), the values vanish from my dashboard due to their expiration after 300 seconds. Of course, this is as designed.

But, for my use-case, I'd like to see some of the last recorded values. One straightforward fix would be to either prevent their expiration or extend the expiration time. By doing so, however, there's another problem: the values displayed would be the last the inverter could operate with, which is slightly above 0, rather than the actual value when the inverter is offline, which is 0. This approach would be super helpful, especially when I want to check the day's total production in the evening.

However, the flip side is that we wouldn't be alerted if the inverter stops sending data due to some malfunction.

Another option could be to save the last value (like the last temperature or any other relevant data) to a helper entity through automation.

Honestly, I'm a bit torn on what's the best solution and don't have a strong preference. I'd love to hear your thoughts on this. What do you think?

Hypfer commented 1 year ago

especially when I want to check the day's total production in the evening

The daily and total production counters do not expire and should be available even if the inverter is offline. Conceptually, this is because they don't have to, since - as a meter - their reported value is still correct even if the inverter is offline as that value won't change unless the inverter is awake. Those will only turn to unknown if home assistant is restarted as the values aren't published with the retain flag. Maybe you've experienced that happening?

Real-time-values on the other hand have to expire, as they refer to a measurement of some kind of parameter at a specific point in time. Having the last reading stick around indefinitely would not be just wrong but also mess with stuff such as the daily mean calculation for that entity in the long term statistics framework.

rather than the actual value when the inverter is offline, which is 0

The actual value when the inverter is offline is unknown as there is simply no measurement for that point in time.

It can mean 0, but that isn't always the case. For example, since the inverter only wakes up once ~20V on one of the PV inputs is reached, the actual measurement for PV1-4 V could be any value between 0 and 20V. However since there's nothing awake to make and report that measurement, it has to be unknown because otherwise the software would report essentially made-up data.

Honestly, I'm a bit torn on what's the best solution and don't have a strong preference. I'd love to hear your thoughts on this. What do you think?

Given the reasons above, IMO, the software can only operate as it does now which is why it was built like that :-)

What are you trying to achieve exactly that currently doesn't work as expected?

k2iuh commented 1 year ago

Thank you for the detailed explanation regarding the daily and total counters. It aligns with my observations, but I did encounter data loss upon a Home Assistant restart. Is there a technical reason why the "retain" flag isn't set for these values? This might have prevented the problem I experienced.

For all other values, you are right. It makes sense to let them expire.

Thanks for your time.

Hypfer commented 1 year ago

Is there a technical reason why the "retain" flag isn't set for these values?

Actually no 🤔

https://github.com/Hypfer/deye-microinverter-cloud-free/commit/ea2200636fc77d487d8818e18f52399b3ad7ce84

It's set now

k2iuh commented 1 year ago

Thanks and "Oh noes": docker build incoming ;)