mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
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:
@@ -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(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user