Add configurable reporting interval#15
Open
poolski wants to merge 5 commits into
Open
Conversation
Agent-Logs-Url: https://github.com/poolski/pytap/sessions/c67ff8ad-19f3-4cf4-8d07-983b2bc09efb Co-authored-by: poolski <[email protected]>
… step Agent-Logs-Url: https://github.com/poolski/pytap/sessions/dc53ebe2-17ef-480f-bcf1-7ab9f5dec747 Co-authored-by: poolski <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Because the TAP emits a packet every time one of the optimizers sends an update, there is no way to know the volume of events on the wire ahead of time. During periods of low activity (i.e. at night), there's not a lot of activity on the wire.
In the morning/throughout the day, however, I was finding that the sheer volume of events from my 13 panels (which isn't all that much) was causing a huge amount of CPU and IO overhead on my Home Assistant machine, to the point where the frontend was disconnecting and timing out.
My Home Assistant instance is no slouch:
CPU: 12-core Intel(R) Core(TM) i7-10710U,
RAM: 32GB RAM
Storage: 512GB NVMe SSD
HAOS is running on bare metal.
The sheer volume of events that PyTAP was processing from the wire was causing issues, which was a bit unexpected.
Proposed solution
After having a bit of a poke through the code, I added a reporting interval setting to the coordinator (and wired that through the setup screens). I'd imagine few people want down-to-the-second resolution for their panel/TS4 telemetry, so my thinking is that an average of the values across
reporting_intervalis a reasonable compromise.The updated implementation
reporting_intervalThis approach also makes things like ApexCharts much more responsive. By default, ApexCharts loads all data points for a given series, so frequent state updates result in even simple charts with one series being sluggish.
By spacing the state updates out a bit more and having the option to customise the reporting interval (5-300s seems plenty big a range) people can tune their PyTAP setup to their particular needs.
UI Changes