New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve availability of Tractive entities #97091
Improve availability of Tractive entities #97091
Conversation
Hey there @Danielhiversen, @zhulik, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
I think we have a race condition here, on my production system the entities after HA start are unavailable for 2-3 minutes. Probably entities are taking too long to initialize and are not getting the first events with data from |
Now the event subscription starts when entities are initialized. On my production system, entities are available 2-3 seconds after HA starts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @bieniu 👍
My requested changes are only small code style improvements :)
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found a slight improvement. What do you think about it?
Co-authored-by: Robert Resch <robert@resch.dev>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor improvements to remove the assert
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @bieniu 🚀
@edenhaus Thanks, we got a pretty nice refactoring of the code here 😁 |
Removed this PR from the milestone, as it causes conflicts and cannot be merged cleanly on the the rc branch for including in a patch release. ../Frenck |
Breaking change
Proposed change
Sometimes the API returns
null
instead of values, this causes the sensor state to beunknown
.Also this may cause warnings for sensors that have numeric values as states and have a defined
state_class
.With this change, entities are marked as
unavailable
during init and when an event with data is received, their availability is determined based on the conditionvalue is not None
. If thevalue is None
, the entity will be unavailable.Also, the
handle_server_unavailable()
andhandle_status_update()
functions have been moved toTractiveEntity
to simplify the code.Type of change
Additional information
unknown
orunavailable
after HA start #98351Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: