Async conversion HomeKit Types#14399
Closed
cdce8p wants to merge 2 commits intohome-assistant:devfrom
cdce8p:homekit-async
Closed
Async conversion HomeKit Types#14399cdce8p wants to merge 2 commits intohome-assistant:devfrom cdce8p:homekit-async
cdce8p wants to merge 2 commits intohome-assistant:devfrom
cdce8p:homekit-async
Conversation
balloob
reviewed
May 19, 2018
| current_position = new_state.attributes.get(ATTR_CURRENT_POSITION) | ||
| if isinstance(current_position, int): | ||
| self.char_current_position.set_value(current_position) | ||
| self.hass.async_add_job( |
Member
There was a problem hiding this comment.
You need to await these calls if you want to mimic the old behavior (and thus method needs to be async). However, If you're going to call to the thread pool twice, you might aswell run the whole method in a thread right away, probably more efficient.
balloob
reviewed
May 19, 2018
| self.char_current_position.set_value(position) | ||
| self.char_target_position.set_value(position) | ||
| self.char_position_state.set_value(2) | ||
| self.hass.async_add_job(self.char_current_position.set_value, position) |
Member
There was a problem hiding this comment.
This is very inefficient calling 3 times async add job. They are all queued up but will also be picked up by 3 threads at the same time.
Member
Author
|
Closing this PR, since it's probably more efficient the way it's at the moment. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description:
This is the first PR to complete the
asyncconversion for thehomekitcomponent. I focused on converting thetypeclasses. Another PR will deal with the mainHomeKitclass.As for the changes:
HAP-pythonand thus aren't executed in the same event loop. Therefore upon execution they will callhass.add_jobon theirasyncmethod.asyncsetter methods now callawait hass.services.async_callfor service execution.update_statemethod s(callbacks fortrack_change_listeners) are nowasync_update_state. I omitted thecallbackdecorator, see Async conversion HomeKit Types #14399 (review)set_valueon a characteristic inHAP-pythonis now prefixed withhass.async_add_job(inasyncmethods only).Since I haven't used
asyncfor that long, any input is welcome.Checklist:
tox. Your PR cannot be merged unless tests pass