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 authored and GitHub committed 2018-12-13 10:07:59 +01:00
1 parent 56c7e78cf2
commit 8ea0a8d40b
24 files changed
+143 -41

No files matched your search

+7 -2
View File
@@ -6,7 +6,7 @@ from os import path
import voluptuous as vol
from homeassistant.auth.permissions.const import POLICY_CONTROL
from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.const import ATTR_ENTITY_ID, ENTITY_MATCH_ALL
import homeassistant.core as ha
from homeassistant.exceptions import TemplateError, Unauthorized, UnknownUser
from homeassistant.helpers import template
@@ -197,7 +197,12 @@ async def entity_service_call(hass, platforms, func, call):
entity_perms = None
# Are we trying to target all entities
target_all_entities = ATTR_ENTITY_ID not in call.data
if ATTR_ENTITY_ID in call.data:
target_all_entities = call.data[ATTR_ENTITY_ID] == ENTITY_MATCH_ALL
else:
_LOGGER.warning('Not passing an entity ID to a service to target all '
'entities is deprecated. Use instead: entity_id: "*"')
target_all_entities = True
if not target_all_entities:
# A set of entities we're trying to target.