ZHA Light debug logging. (#22776)
This commit is contained in:
parent
144632a81b
commit
8dfbfae270
1 changed files with 15 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue