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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use entity.async_request_call in service helper #31454

merged 5 commits into from Feb 4, 2020


Copy link

balloob commented Feb 4, 2020

Breaking change

Proposed change

The entity base class has an async_request_call helper that will limit the number of simultaneous requests that we make to a platform based on the PARALLEL_UPDATES value. This migrates the entity service helper to use this method. This means that for platforms that support it, we now run as many requests in parallel as we can.

Previously this was only implemented in light.turn_on.

I also noticed that the verify domain control tests were passing Entity objects instead of EntityRegistryEntry objects. Cleaned up those tests once I started using MockEntity to be able to access async_request_call.

Docs; home-assistant/developers.home-assistant#402

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

# Example configuration.yaml

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:


  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 馃 Silver
  • 馃 Gold
  • 馃弳 Platinum
@balloob balloob requested a review from home-assistant/core as a code owner Feb 4, 2020
@probot-home-assistant probot-home-assistant bot added the core label Feb 4, 2020
@project-bot project-bot bot added this to Needs review in Dev Feb 4, 2020
@balloob balloob mentioned this pull request Feb 4, 2020
8 of 20 tasks complete
homeassistant/helpers/ Show resolved Hide resolved
homeassistant/helpers/ Outdated Show resolved Hide resolved
homeassistant/helpers/ Outdated Show resolved Hide resolved
@@ -297,6 +299,7 @@ def listener(event):
await asyncio.sleep(0)

This comment has been minimized.

Copy link

MartinHjelmare Feb 4, 2020


We normally use hass.async_block_till_done, right?

This comment has been minimized.

Copy link

balloob Feb 4, 2020

Author Member

This is a test about interweaving requests. Very fragile :( if we block till done or call with blocking=True, it's already done before we get the 2nd call !


This comment has been minimized.

Copy link

codecov bot commented Feb 4, 2020

Codecov Report

Merging #31454 into dev will increase coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##              dev   #31454   +/-   ##
  Coverage   94.62%   94.63%           
  Files         749      749           
  Lines       54282    54304   +22     
+ Hits        51365    51389   +24     
+ Misses       2917     2915    -2     
Impacted Files Coverage 螖
homeassistant/components/vizio/ 100.00% <0.00%> (酶) 猬嗭笍
homeassistant/components/uk_transport/ 94.20% <0.00%> (+0.72%) 猬嗭笍

Continue to review full report at Codecov.

Legend - Click here to learn more
螖 = absolute <relative> (impact), 酶 = not affected, ? = missing data
Powered by Codecov. Last update db6449c...7173b43. Read the comment docs.

pvizeli approved these changes Feb 4, 2020
Dev automation moved this from Needs review to Reviewer approved Feb 4, 2020

This comment has been minimized.

Copy link

pvizeli commented Feb 4, 2020

Let's test it on dev


This comment has been minimized.

Copy link
Member Author

balloob commented Feb 4, 2020

balloob added 5 commits Feb 4, 2020
@balloob balloob force-pushed the entity-request-call-service branch from 7173b43 to 44eeb09 Feb 4, 2020
@balloob balloob merged commit e970177 into dev Feb 4, 2020
8 checks passed
8 checks passed
CI Build #20200204.71 succeeded
CI (FullCheck Mypy) FullCheck Mypy succeeded
CI (FullCheck Pylint) FullCheck Pylint succeeded
CI (Overview CheckFormat) Overview CheckFormat succeeded
CI (Overview Lint) Overview Lint succeeded
CI (Overview Validate) Overview Validate succeeded
CI (Tests PyTest Python37) Tests PyTest Python37 succeeded
cla-bot Everyone involved has signed the CLA
Dev automation moved this from Reviewer approved to Done Feb 4, 2020
@delete-merged-branch delete-merged-branch bot deleted the entity-request-call-service branch Feb 4, 2020
@lock lock bot locked and limited conversation to collaborators Feb 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can鈥檛 perform that action at this time.