RFC: Deprecate auto target all for services and introduce entity_id: * (#19006)

* Deprecate auto target all

* Match on word 'all'
This commit is contained in:
Paulus Schoutsen 2018-12-13 10:07:59 +01:00 committed by GitHub
parent 56c7e78cf2
commit 8ea0a8d40b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 143 additions and 41 deletions

View file

@ -7,7 +7,7 @@ import logging
from homeassistant import config as conf_util
from homeassistant.setup import async_prepare_setup_platform
from homeassistant.const import (
ATTR_ENTITY_ID, CONF_SCAN_INTERVAL, CONF_ENTITY_NAMESPACE)
ATTR_ENTITY_ID, CONF_SCAN_INTERVAL, CONF_ENTITY_NAMESPACE, MATCH_ALL)
from homeassistant.core import callback
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import config_per_platform, discovery
@ -161,7 +161,15 @@ class EntityComponent:
This method must be run in the event loop.
"""
if ATTR_ENTITY_ID not in service.data:
data_ent_id = service.data.get(ATTR_ENTITY_ID)
if data_ent_id in (None, MATCH_ALL):
if data_ent_id is None:
self.logger.warning(
'Not passing an entity ID to a service to target all '
'entities is deprecated. Update your call to %s.%s to be '
'instead: entity_id: "*"', service.domain, service.service)
return [entity for entity in self.entities if entity.available]
entity_ids = set(extract_entity_ids(self.hass, service, expand_group))