Skip to content
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

Update after service calls #4795

Merged
merged 2 commits into from
Dec 7, 2016
Merged

Update after service calls #4795

merged 2 commits into from
Dec 7, 2016

Conversation

balloob
Copy link
Member

@balloob balloob commented Dec 7, 2016

Description:
When calling a service, before async came around, we would first call turn_on on each light, after that we would go through each light and call update.

During our migration to async we initially would fire off update tasks as soon as possible while calling turn_on and just wait at the end of the service till all tasks were done. We realized quickly that this was hitting devices too hard and decided to wait till the update was done. We didn't realize by doing so we were now doing: call turn on 1, update 1, call turn on 2, update 2, etc.

This PR fixes it.

Related issue (if applicable): fixes #4783

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

@mention-bot
Copy link

@balloob, thanks for your PR! By analyzing the history of the files in this pull request, we identified @pvizeli, @turbokongen and @kk7ds to be potential reviewers.

@balloob balloob added this to the 0.34.4 milestone Dec 7, 2016
if not light.should_poll:
continue

update_coro = light.async_update_ha_state(True)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should wrap this call in hass.loop.create_task so that if we first called this on 2 async entities, and then have to wait for a sync entity, the async entities can still continue to update.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

@pvizeli pvizeli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, make more sense to do that in this way.

@balloob balloob merged commit 98fe50d into dev Dec 7, 2016
@balloob balloob deleted the fix-service-order branch December 7, 2016 06:30
balloob added a commit that referenced this pull request Dec 7, 2016
* Update after service calls

* Service update: wrap async_update in create_task
@home-assistant home-assistant locked and limited conversation to collaborators Mar 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hue lights in group are not switching at same time
3 participants