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

Do not select all entities when omitting entity ID in service call #29178

Merged
merged 5 commits into from Dec 3, 2019

Conversation

@balloob
Copy link
Member

balloob commented Nov 28, 2019

Breaking Change:

It is no longer possible to target all entities by not passing both entity_id and area_id to your service data. This feature was previously deprecated and has been printing warnings. The correct way to target all entities is to set entity_id: all

Description:

Remove the feature to automatically target all entities if you did not specify an entity.

Previously attempted in #25715.

entity_id has not been set to required because it is allowed to just specify area_id to select entities.

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.
@balloob balloob requested a review from home-assistant/core as a code owner Nov 28, 2019
@project-bot project-bot bot added this to Needs review in Dev Nov 28, 2019
Copy link
Contributor

amelchio left a comment

entity_id has not been set to required because it is allowed to just specify area_id to select entities.

So we now fail silently?

It would be quite useful to have the constraint (need one or the other) encoded in the schemas.

if ATTR_ENTITY_ID in call.data:
target_all_entities = call.data[ATTR_ENTITY_ID] == ENTITY_MATCH_ALL
else:
# Remove the service_name parameter along with this warning

This comment has been minimized.

Copy link
@amelchio

amelchio Nov 28, 2019

Contributor

This comments says that further changes are needed if it is deleted :)

service_name,
ENTITY_MATCH_ALL,
)
target_all_entities = True

This comment has been minimized.

Copy link
@pvizeli

pvizeli Nov 28, 2019

Member

We should remove the auto target and convert the warning into error and fail on this service call

@balloob balloob force-pushed the entity-id-omit-no-select-all branch from 9f68c31 to 73a6d52 Nov 30, 2019
@balloob

This comment has been minimized.

Copy link
Member Author

balloob commented Nov 30, 2019

I've updated the code to always require either entity_id or area_id. I did some clean up in the process. The change was made by making sure that ENTITY_SERVICE_SCHEMA has been removed and replaced with a function that will extend the passed in schema, but also enforced either key is passed in.

@balloob balloob requested review from dgomes and fabaff as code owners Nov 30, 2019
@balloob balloob changed the title Do not select all entities when omitting entity ID Do not select all entities when omitting entity ID in service call Dec 1, 2019
@balloob balloob mentioned this pull request Dec 1, 2019
6 of 6 tasks complete
@home-assistant home-assistant deleted a comment Dec 2, 2019
@home-assistant home-assistant deleted a comment Dec 2, 2019
@balloob balloob merged commit 02d9ed5 into dev Dec 3, 2019
11 checks passed
11 checks passed
CI #20191201.15 succeeded
Details
CI (FullCheck Mypy) FullCheck Mypy succeeded
Details
CI (FullCheck Pylint) FullCheck Pylint succeeded
Details
CI (Overview CheckFormat) Overview CheckFormat succeeded
Details
CI (Overview Lint) Overview Lint succeeded
Details
CI (Overview Validate) Overview Validate succeeded
Details
CI (Tests PyTest Python36) Tests PyTest Python36 succeeded
Details
CI (Tests PyTest Python37) Tests PyTest Python37 succeeded
Details
cla-bot Everyone involved has signed the CLA
codecov/patch 100% of diff hit (target 94.43%)
Details
codecov/project 94.44% (target 90%)
Details
Dev automation moved this from Needs review to Done Dec 3, 2019
@delete-merged-branch delete-merged-branch bot deleted the entity-id-omit-no-select-all branch Dec 3, 2019
@lock lock bot locked and limited conversation to collaborators Dec 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Dev
  
Done
5 participants
You can’t perform that action at this time.