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

* Do not select all entities when omitting entity ID

* Address comments Matthew

* Require either area_id or entity_id

* Fix tests

* Fix test
This commit is contained in:
Paulus Schoutsen 2019-12-02 16:23:12 -08:00 committed by GitHub
parent 9587afc5ce
commit 02d9ed5e36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
47 changed files with 538 additions and 626 deletions

View file

@ -715,12 +715,23 @@ PLATFORM_SCHEMA = vol.Schema(
PLATFORM_SCHEMA_BASE = PLATFORM_SCHEMA.extend({}, extra=vol.ALLOW_EXTRA)
ENTITY_SERVICE_SCHEMA = vol.Schema(
{
vol.Optional(ATTR_ENTITY_ID): comp_entity_ids,
vol.Optional(ATTR_AREA_ID): vol.All(ensure_list, [str]),
}
)
def make_entity_service_schema(
schema: dict, *, extra: int = vol.PREVENT_EXTRA
) -> vol.All:
"""Create an entity service schema."""
return vol.All(
vol.Schema(
{
**schema,
vol.Optional(ATTR_ENTITY_ID): comp_entity_ids,
vol.Optional(ATTR_AREA_ID): vol.All(ensure_list, [str]),
},
extra=extra,
),
has_at_least_one_key(ATTR_ENTITY_ID, ATTR_AREA_ID),
)
EVENT_SCHEMA = vol.Schema(
{