-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Asyncify rfxtrx startup and event handling #38155
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
Conversation
Hey there @Danielhiversen, mind taking a look at this pull request as its been labeled with an integration ( |
|
||
def _shutdown_rfxtrx(event): | ||
"""Close connection with RFXtrx.""" | ||
rfx_object.close_connection() | ||
|
||
listener = hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, _shutdown_rfxtrx) | ||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_START, _start_rfxtrx) |
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.
Do we need to wait until home assistant start to set the callback on rfx?
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.
Well it can start providing events, and those trigger calls to different things. For example the event handlers on platforms will call async_write_ha_state which i don't think we want before start?
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.
It should be ok to use the entity state update callbacks as soon as the entity is added to home assistant. That doesn't need to wait until home assistant start.
It's good to make sure the integration is ready before the home assistant start event, to allow automations to use the integration on that event.
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.
It is useable at that stage, just won't be getting any event updates until after the event. (you can trigger sends of commands). But i'll look at changing it. It wasn't as easy as just directly setting it. Since there are some hass.data variables that looks like they are needed to be set before we can accept events.
I'll look at it separately.
Side note: I was browsing the code and found an extra, double, state update: core/homeassistant/components/rfxtrx/switch.py Lines 131 to 132 in 686e6b8
core/homeassistant/components/rfxtrx/__init__.py Lines 487 to 521 in 686e6b8
|
yea i need to refactor the sending stuff. it's quite ugly now i think. |
Proposed change
Type of change
Additional information
Checklist
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
.The integration reached or maintains the following Integration Quality Scale: