basnijholt / adaptive-lighting

Adaptive Lighting custom component for Home Assistant
https://basnijholt.github.io/adaptive-lighting/
Apache License 2.0
1.81k stars 134 forks source link

Using adapt_only_on_bare_turn_on and apply results in manual_control #723

Closed basnijholt closed 1 year ago

basnijholt commented 1 year ago

See logs here for light.bamboo

2023-08-07 22:09:03.545 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Called 'adaptive_lighting.apply' service with '{'entity_id': ['switch.adaptive_lighting_living_room'], 'lights': ['light.bamboo'], 'turn_on_lights': True, 'prefer_rgb_color': False, 'adapt_brightness': True, 'transition': 1.0, 'adapt_color': True}'
2023-08-07 22:09:03.548 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: Setting color_temp of light light.bamboo
2023-08-07 22:09:03.548 DEBUG (MainThread) [custom_components.adaptive_lighting.adaptation_utils] Preparing adaptation data for light.bamboo with service data {'entity_id': 'light.bamboo', 'transition': 1.0, 'brightness': 212, 'color_temp_kelvin': 2000}
2023-08-07 22:09:03.548 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: execute_cancellable_adaptation_calls with data: AdaptationData(entity_id=light.bamboo, context_id=01H79RRVXS:al:JRUX:srvc:YK, sleep_time=0.5, force=True, max_length=2, which=both, initial_sleep=False)
2023-08-07 22:09:03.549 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.bamboo', 'brightness': 212, 'transition': 0.5} with context.id='01H79RRVXS:al:JRUX:srvc:YK'
2023-08-07 22:09:03.550 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.bamboo']')' event with context.id='01H79RRVXS:al:JRUX:srvc:YK'
2023-08-07 22:09:03.553 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] (0) _service_interceptor_turn_on_handler: call.context.id='01H79RRVXS:al:JRUX:srvc:YK', is_skipped_hash='False'
2023-08-07 22:09:03.680 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.bamboo' 'state_changed' event: '{'min_color_temp_kelvin': 2000, 'max_color_temp_kelvin': 6535, 'min_mireds': 153, 'max_mireds': 500, 'effect_list': ['blink', 'breathe', 'okay', 'channel_change', 'candle', 'fireplace', 'colorloop', 'finish_effect', 'stop_effect', 'stop_hue_effect'], 'supported_color_modes': ['color_temp', 'xy'], 'color_mode': <ColorMode.XY: 'xy'>, 'brightness': 211, 'hs_color': (27.429, 13.725), 'rgb_color': (255, 236, 220), 'xy_color': (0.355, 0.344), 'friendly_name': 'Bamboo', 'supported_features': <LightEntityFeature.EFFECT|FLASH|TRANSITION: 44>}' with context.id='01H79RRVXS:al:JRUX:srvc:YK'
2023-08-07 22:09:03.680 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] AdaptiveLightingManager: New adapt '<state light.bamboo=on; min_color_temp_kelvin=2000, max_color_temp_kelvin=6535, min_mireds=153, max_mireds=500, effect_list=['blink', 'breathe', 'okay', 'channel_change', 'candle', 'fireplace', 'colorloop', 'finish_effect', 'stop_effect', 'stop_hue_effect'], supported_color_modes=['color_temp', 'xy'], color_mode=xy, brightness=211, hs_color=(27.429, 13.725), rgb_color=(255, 236, 220), xy_color=(0.355, 0.344), friendly_name=Bamboo, supported_features=44 @ 2023-08-07T22:09:03.673693-07:00>' found for light.bamboo
2023-08-07 22:09:03.680 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Start transition timer of 0.5 seconds for light light.bamboo
2023-08-07 22:09:03.681 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'off' → 'on' event for 'light.bamboo' with context.id='01H79RRVXS:al:JRUX:srvc:YK'
2023-08-07 22:09:03.681 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01H79RRVXS:al:JRUX:srvc:YK'
2023-08-07 22:09:03.681 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Cancelled ongoing brightness adaptation calls (<Task pending name='Task-601870' coro=<AdaptiveSwitch._execute_adaptation_calls() running at /config/custom_components/adaptive_lighting/switch.py:1275> wait_for=<Future pending cb=[Task.task_wakeup()]> cb=[Task.task_wakeup()]>) for 'light.bamboo'
2023-08-07 22:09:03.682 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] just_turned_off: State change 'off' → 'on' triggered by 'light.turn_on'
2023-08-07 22:09:03.683 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01H79RRVXS:al:JRUX:srvc:YK'
2023-08-07 22:09:03.683 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] _mark_manual_control_if_non_bare_turn_on: entity_id='light.bamboo', service_data='{'entity_id': 'light.bamboo', 'brightness': 212, 'transition': 0.5}'
2023-08-07 22:09:03.684 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Marking 'light.bamboo' as manually controlled.
2023-08-07 22:09:03.684 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Skipping responding to 'off' → 'on' event for 'light.bamboo' with context.id='01H79RRVXS:al:JRUX:srvc:YK' because we only adapt on bare `light.turn_on` events and not on service_data: '{'entity_id': 'light.bamboo', 'brightness': 212, 'transition': 0.5}'
2023-08-07 22:09:03.691 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: Ongoing adaptation of light.bamboo cancelled, with AdaptationData: AdaptationData(entity_id=light.bamboo, context_id=01H79RRVXS:al:JRUX:srvc:YK, sleep_time=0.5, force=True, max_length=2, which=both, initial_sleep=False)
2023-08-07 22:09:03.714 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Called 'adaptive_lighting.apply' service with '{'entity_id': ['switch.adaptive_lighting_living_room'], 'lights': ['light.bed_led'], 'turn_on_lights': True, 'prefer_rgb_color': False, 'adapt_brightness': True, 'transition': 1.0, 'adapt_color': True}'
2023-08-07 22:09:03.716 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: Setting color_temp of light light.bed_led
2023-08-07 22:09:03.717 DEBUG (MainThread) [custom_components.adaptive_lighting.adaptation_utils] Preparing adaptation data for light.bed_led with service data {'entity_id': 'light.bed_led', 'transition': 1.0, 'brightness': 212, 'color_temp_kelvin': 2000}
2023-08-07 22:09:03.717 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: execute_cancellable_adaptation_calls with data: AdaptationData(entity_id=light.bed_led, context_id=01H79RRW33:al:JRUX:srvc:YL, sleep_time=0.5, force=True, max_length=2, which=both, initial_sleep=False)
2023-08-07 22:09:03.718 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.bed_led', 'brightness': 212, 'transition': 0.5} with context.id='01H79RRW33:al:JRUX:srvc:YL'
2023-08-07 22:09:03.719 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.bed_led']')' event with context.id='01H79RRW33:al:JRUX:srvc:YL'
2023-08-07 22:09:03.719 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] (0) _service_interceptor_turn_on_handler: call.context.id='01H79RRW33:al:JRUX:srvc:YL', is_skipped_hash='False'
2023-08-07 22:09:03.883 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.bed_led' 'state_changed' event: '{'min_color_temp_kelvin': 2000, 'max_color_temp_kelvin': 6535, 'min_mireds': 153, 'max_mireds': 500, 'effect_list': ['blink', 'breathe', 'okay', 'channel_change', 'candle', 'fireplace', 'colorloop', 'finish_effect', 'stop_effect', 'stop_hue_effect'], 'supported_color_modes': ['color_temp', 'xy'], 'color_mode': <ColorMode.XY: 'xy'>, 'brightness': 211, 'hs_color': (30.252, 93.333), 'rgb_color': (255, 137, 17), 'xy_color': (0.599, 0.382), 'friendly_name': 'Bed LED', 'supported_features': <LightEntityFeature.EFFECT|FLASH|TRANSITION: 44>}' with context.id='01H79RRW33:al:JRUX:srvc:YL'
2023-08-07 22:09:03.883 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] AdaptiveLightingManager: New adapt '<state light.bed_led=on; min_color_temp_kelvin=2000, max_color_temp_kelvin=6535, min_mireds=153, max_mireds=500, effect_list=['blink', 'breathe', 'okay', 'channel_change', 'candle', 'fireplace', 'colorloop', 'finish_effect', 'stop_effect', 'stop_hue_effect'], supported_color_modes=['color_temp', 'xy'], color_mode=xy, brightness=211, hs_color=(30.252, 93.333), rgb_color=(255, 137, 17), xy_color=(0.599, 0.382), friendly_name=Bed LED, supported_features=44 @ 2023-08-07T22:09:03.878349-07:00>' found for light.bed_led
2023-08-07 22:09:03.884 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Start transition timer of 0.5 seconds for light light.bed_led
2023-08-07 22:09:03.884 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'off' → 'on' event for 'light.bed_led' with context.id='01H79RRW33:al:JRUX:srvc:YL'
2023-08-07 22:09:03.884 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01H79RRW33:al:JRUX:srvc:YL'
2023-08-07 22:09:03.884 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Cancelled ongoing brightness adaptation calls (<Task pending name='Task-601883' coro=<AdaptiveSwitch._execute_adaptation_calls() running at /config/custom_components/adaptive_lighting/switch.py:1275> wait_for=<Future pending cb=[Task.task_wakeup()]> cb=[Task.task_wakeup()]>) for 'light.bed_led'
2023-08-07 22:09:03.884 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] just_turned_off: State change 'off' → 'on' triggered by 'light.turn_on'
2023-08-07 22:09:03.885 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01H79RRW33:al:JRUX:srvc:YL'
2023-08-07 22:09:03.885 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom LED: '_update_attrs_and_maybe_adapt_lights' called with context.id='01H79RRW8D:al:IJSW:lght:ZC' lights: '['light.bed_led']', transition: '1.0', force: 'True'
2023-08-07 22:09:03.887 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom LED: filtered_lights: '['light.bed_led']'
2023-08-07 22:09:03.887 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01H79RRW33:al:JRUX:srvc:YL'
2023-08-07 22:09:03.887 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom LED: Calling _adapt_light from _update_attrs_and_maybe_adapt_lights: 'light.bed_led' with transition 1.0 and context.id=01H79RRW8D:al:IJSW:lght:ZC
2023-08-07 22:09:03.898 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom LED: Setting rgb_color of light light.bed_led
2023-08-07 22:09:03.899 DEBUG (MainThread) [custom_components.adaptive_lighting.adaptation_utils] Preparing adaptation data for light.bed_led with service data {'entity_id': 'light.bed_led', 'transition': 1.0, 'brightness': 212, 'rgb_color': (255, 136.86832541739756, 13.904070298965905)}
2023-08-07 22:09:03.899 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom LED: execute_cancellable_adaptation_calls with data: AdaptationData(entity_id=light.bed_led, context_id=01H79RRW8D:al:IJSW:lght:ZC, sleep_time=1.0, force=True, max_length=1, which=both, initial_sleep=False)
2023-08-07 22:09:03.903 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: Ongoing adaptation of light.bed_led cancelled, with AdaptationData: AdaptationData(entity_id=light.bed_led, context_id=01H79RRW33:al:JRUX:srvc:YL, sleep_time=0.5, force=True, max_length=2, which=both, initial_sleep=False)
2023-08-07 22:09:03.903 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom LED: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.bed_led', 'transition': 1.0, 'brightness': 212, 'rgb_color': (255, 136.86832541739756, 13.904070298965905)} with context.id='01H79RRW8D:al:IJSW:lght:ZC'
2023-08-07 22:09:03.907 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.bed_led']')' event with context.id='01H79RRW8D:al:IJSW:lght:ZC'
2023-08-07 22:09:03.908 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] (0) _service_interceptor_turn_on_handler: call.context.id='01H79RRW8D:al:IJSW:lght:ZC', is_skipped_hash='False'
2023-08-07 22:09:03.923 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Called 'adaptive_lighting.apply' service with '{'entity_id': ['switch.adaptive_lighting_living_room'], 'lights': ['light.philips_go'], 'turn_on_lights': True, 'prefer_rgb_color': False, 'adapt_brightness': True, 'transition': 1.0, 'adapt_color': True}'
2023-08-07 22:09:03.926 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: Setting color_temp of light light.philips_go
2023-08-07 22:09:03.926 DEBUG (MainThread) [custom_components.adaptive_lighting.adaptation_utils] Preparing adaptation data for light.philips_go with service data {'entity_id': 'light.philips_go', 'transition': 1.0, 'brightness': 212, 'color_temp_kelvin': 2000}
2023-08-07 22:09:03.926 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: execute_cancellable_adaptation_calls with data: AdaptationData(entity_id=light.philips_go, context_id=01H79RRW9K:al:JRUX:srvc:YM, sleep_time=0.5, force=True, max_length=2, which=both, initial_sleep=False)
2023-08-07 22:09:03.927 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.philips_go', 'brightness': 212, 'transition': 0.5} with context.id='01H79RRW9K:al:JRUX:srvc:YM'
2023-08-07 22:09:03.943 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.philips_go']')' event with context.id='01H79RRW9K:al:JRUX:srvc:YM'
2023-08-07 22:09:03.943 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] (0) _service_interceptor_turn_on_handler: call.context.id='01H79RRW9K:al:JRUX:srvc:YM', is_skipped_hash='False'