mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
ZHA Light debug logging. (#22776)
This commit is contained in:
parent
144632a81b
commit
8dfbfae270
@ -167,6 +167,7 @@ class Light(ZhaEntity, light.Light):
|
|||||||
duration = transition * 10 if transition else DEFAULT_DURATION
|
duration = transition * 10 if transition else DEFAULT_DURATION
|
||||||
brightness = kwargs.get(light.ATTR_BRIGHTNESS)
|
brightness = kwargs.get(light.ATTR_BRIGHTNESS)
|
||||||
|
|
||||||
|
t_log = {}
|
||||||
if (brightness is not None or transition) and \
|
if (brightness is not None or transition) and \
|
||||||
self._supported_features & light.SUPPORT_BRIGHTNESS:
|
self._supported_features & light.SUPPORT_BRIGHTNESS:
|
||||||
if brightness is not None:
|
if brightness is not None:
|
||||||
@ -177,7 +178,9 @@ class Light(ZhaEntity, light.Light):
|
|||||||
level,
|
level,
|
||||||
duration
|
duration
|
||||||
)
|
)
|
||||||
|
t_log['move_to_level_with_on_off'] = success
|
||||||
if not success:
|
if not success:
|
||||||
|
self.debug("turned on: %s", t_log)
|
||||||
return
|
return
|
||||||
self._state = bool(level)
|
self._state = bool(level)
|
||||||
if level:
|
if level:
|
||||||
@ -185,7 +188,9 @@ class Light(ZhaEntity, light.Light):
|
|||||||
|
|
||||||
if brightness is None or brightness:
|
if brightness is None or brightness:
|
||||||
success = await self._on_off_channel.on()
|
success = await self._on_off_channel.on()
|
||||||
|
t_log['on_off'] = success
|
||||||
if not success:
|
if not success:
|
||||||
|
self.debug("turned on: %s", t_log)
|
||||||
return
|
return
|
||||||
self._state = True
|
self._state = True
|
||||||
|
|
||||||
@ -194,7 +199,9 @@ class Light(ZhaEntity, light.Light):
|
|||||||
temperature = kwargs[light.ATTR_COLOR_TEMP]
|
temperature = kwargs[light.ATTR_COLOR_TEMP]
|
||||||
success = await self._color_channel.move_to_color_temp(
|
success = await self._color_channel.move_to_color_temp(
|
||||||
temperature, duration)
|
temperature, duration)
|
||||||
|
t_log['move_to_color_temp'] = success
|
||||||
if not success:
|
if not success:
|
||||||
|
self.debug("turned on: %s", t_log)
|
||||||
return
|
return
|
||||||
self._color_temp = temperature
|
self._color_temp = temperature
|
||||||
|
|
||||||
@ -207,10 +214,13 @@ class Light(ZhaEntity, light.Light):
|
|||||||
int(xy_color[1] * 65535),
|
int(xy_color[1] * 65535),
|
||||||
duration,
|
duration,
|
||||||
)
|
)
|
||||||
|
t_log['move_to_color'] = success
|
||||||
if not success:
|
if not success:
|
||||||
|
self.debug("turned on: %s", t_log)
|
||||||
return
|
return
|
||||||
self._hs_color = hs_color
|
self._hs_color = hs_color
|
||||||
|
|
||||||
|
self.debug("turned on: %s", t_log)
|
||||||
self.async_schedule_update_ha_state()
|
self.async_schedule_update_ha_state()
|
||||||
|
|
||||||
async def async_turn_off(self, **kwargs):
|
async def async_turn_off(self, **kwargs):
|
||||||
@ -224,7 +234,7 @@ class Light(ZhaEntity, light.Light):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
success = await self._on_off_channel.off()
|
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:
|
if not success:
|
||||||
return
|
return
|
||||||
self._state = False
|
self._state = False
|
||||||
@ -243,3 +253,7 @@ class Light(ZhaEntity, light.Light):
|
|||||||
async def refresh(self, time):
|
async def refresh(self, time):
|
||||||
"""Call async_update at an interval."""
|
"""Call async_update at an interval."""
|
||||||
await self.async_update()
|
await self.async_update()
|
||||||
|
|
||||||
|
def debug(self, msg, *args):
|
||||||
|
"""Log debug message."""
|
||||||
|
_LOGGER.debug('%s: ' + msg, self.entity_id, *args)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user