From 8dfbfae270f457d2f45dfc10d3628321e21cf636 Mon Sep 17 00:00:00 2001 From: Alexei Chetroi Date: Fri, 5 Apr 2019 19:06:41 -0400 Subject: [PATCH] ZHA Light debug logging. (#22776) --- homeassistant/components/zha/light.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/zha/light.py b/homeassistant/components/zha/light.py index 573936d6ac2..feccbc09663 100644 --- a/homeassistant/components/zha/light.py +++ b/homeassistant/components/zha/light.py @@ -167,6 +167,7 @@ class Light(ZhaEntity, light.Light): duration = transition * 10 if transition else DEFAULT_DURATION brightness = kwargs.get(light.ATTR_BRIGHTNESS) + t_log = {} if (brightness is not None or transition) and \ self._supported_features & light.SUPPORT_BRIGHTNESS: if brightness is not None: @@ -177,7 +178,9 @@ class Light(ZhaEntity, light.Light): level, duration ) + t_log['move_to_level_with_on_off'] = success if not success: + self.debug("turned on: %s", t_log) return self._state = bool(level) if level: @@ -185,7 +188,9 @@ class Light(ZhaEntity, light.Light): if brightness is None or brightness: success = await self._on_off_channel.on() + t_log['on_off'] = success if not success: + self.debug("turned on: %s", t_log) return self._state = True @@ -194,7 +199,9 @@ class Light(ZhaEntity, light.Light): temperature = kwargs[light.ATTR_COLOR_TEMP] success = await self._color_channel.move_to_color_temp( temperature, duration) + t_log['move_to_color_temp'] = success if not success: + self.debug("turned on: %s", t_log) return self._color_temp = temperature @@ -207,10 +214,13 @@ class Light(ZhaEntity, light.Light): int(xy_color[1] * 65535), duration, ) + t_log['move_to_color'] = success if not success: + self.debug("turned on: %s", t_log) return self._hs_color = hs_color + self.debug("turned on: %s", t_log) self.async_schedule_update_ha_state() async def async_turn_off(self, **kwargs): @@ -224,7 +234,7 @@ class Light(ZhaEntity, light.Light): ) else: success = await self._on_off_channel.off() - _LOGGER.debug("%s was turned off: %s", self.entity_id, success) + self.debug("turned off: %s", success) if not success: return self._state = False @@ -243,3 +253,7 @@ class Light(ZhaEntity, light.Light): async def refresh(self, time): """Call async_update at an interval.""" await self.async_update() + + def debug(self, msg, *args): + """Log debug message.""" + _LOGGER.debug('%s: ' + msg, self.entity_id, *args)