changed on callback to trigger on brightness

This commit is contained in:
John Lancaster
2023-12-02 12:48:34 -06:00
parent 8b00faceb6
commit 145aeca667

View File

@@ -35,7 +35,7 @@ class Motion(Hass):
immediate=True, # avoids needing to sync the state
)
# don't need to await these because they'll already get turned into a task by the utils.sync_wrapper decorator
self.listen_state(**base_kwargs, new='on', callback=self.callback_light_on)
self.listen_state(**base_kwargs, attribute='brightness', callback=self.callback_light_on)
self.listen_state(**base_kwargs, new='off', callback=self.callback_light_off)
@utils.sync_wrapper
@@ -69,6 +69,7 @@ class Motion(Hass):
async def callback_light_on(self, entity=None, attribute=None, old=None, new=None, kwargs=None):
"""Called when the light turns on
"""
if new is not None:
self.log(f'{entity} turned on')
# need this one to finish before continuing to the next line
await self.cancel_motion_callback(new='on')