From 70c5807976db5a43a9af381d282d862190d0c14e Mon Sep 17 00:00:00 2001 From: Anders Melchiorsen Date: Thu, 24 Jan 2019 22:37:30 +0100 Subject: [PATCH] Improve deprecation warnings (#20391) --- homeassistant/helpers/entity_component.py | 6 ++++-- homeassistant/helpers/service.py | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/homeassistant/helpers/entity_component.py b/homeassistant/helpers/entity_component.py index 21634121cd2..44213e6d7c8 100644 --- a/homeassistant/helpers/entity_component.py +++ b/homeassistant/helpers/entity_component.py @@ -169,7 +169,8 @@ class EntityComponent: 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) + 'instead: entity_id: %s', service.domain, service.service, + ENTITY_MATCH_ALL) return [entity for entity in self.entities if entity.available] @@ -182,8 +183,9 @@ class EntityComponent: """Register an entity service.""" async def handle_service(call): """Handle the service.""" + service_name = "{}.{}".format(self.domain, name) await self.hass.helpers.service.entity_service_call( - self._platforms.values(), func, call + self._platforms.values(), func, call, service_name ) self.hass.services.async_register( diff --git a/homeassistant/helpers/service.py b/homeassistant/helpers/service.py index 2b7638b55ee..d2211d031f5 100644 --- a/homeassistant/helpers/service.py +++ b/homeassistant/helpers/service.py @@ -187,7 +187,7 @@ async def async_get_all_descriptions(hass): @bind_hass -async def entity_service_call(hass, platforms, func, call): +async def entity_service_call(hass, platforms, func, call, service_name=''): """Handle an entity service call. Calls all platforms simultaneously. @@ -204,9 +204,11 @@ async def entity_service_call(hass, platforms, func, call): 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 _LOGGER.warning( - 'Not passing an entity ID to a service to target all entities is ' - 'deprecated. Use instead: entity_id: "%s"', ENTITY_MATCH_ALL) + 'Not passing an entity ID to a service to target all ' + 'entities is deprecated. Update your call to %s to be ' + 'instead: entity_id: %s', service_name, ENTITY_MATCH_ALL) target_all_entities = True if not target_all_entities: