Hi All,
Apologies in advance for the ignorance on this one, especially if there’s a simple answer. I’ve found lots of posts in the ‘configuration’ area of the forums but not one specific to development.
As part of the Growatt integration (which I co-maintain) there is one specific entity (lifetime usage) that drops it’s value drops to 0 every night before returning to the non-zero value the next day (there have been several bugs posted about it). The problem is that this is a 3rd Party/Cloud integration and there’s no way that we can get this fixed in the correct place (i.e. server side).
As a work-around/hack/fix what I want to do is store the previous non-zero value of the entity and if the value ever drops to 0, just return the last non-zero value. I can happily do this within the integration itself in memory/during a run, however, if the user ever restarts the server during the night it’ll drop to 0 until the next day causing the stats to be all over the place.
Instead, at initialisation, what I’d prefer to do is to lookup the most recent non-zero value from the historic values for that sensor/entity. I just have no idea how to do it!
Could anyone direct me towards documentation/code examples/snippets/hints that may have done something similar?
I’m aware of the history integration, but no idea if that’s callable internally? There must be some way for an integration to refer to it’s own history surely?
Any help would be greatly appreciated.
Thanks in advance!