basnijholt / adaptive-lighting

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

The value in the duration of transistion when "sleep mode" is toggled in seconds does not work #841

Open evergreen0057 opened 8 months ago

evergreen0057 commented 8 months ago

Hey,

The toggle to turn on sleep mode works perfectly and happens instantly. However, the issue I am finding is that no matter what value I enter in the sleep_transition field, as soon as I toggle the switch it instantly transitions the light to the minimum sleep brightness. My expectation was that if I enter 60 into the sleep_transition field, it would take 60 seconds for the lights to transition to the minimum brightness.

Not sure if it makes a difference or not but transition_until_sleep set to either True or False has no impact.

Currently running the latest version of Adaptive Lighting with a couple of different Tuya bulbs but all the bulbs behave the same and always instantly transition to sleep once the switch is toggled on.

Cheers

Logs:

2023-11-13 18:53:50.867 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living Room Lights: filtered_lights: '['light.local_living_room_light_1']'
2023-11-13 18:53:50.867 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01HF3TR7HD:al:JRUX:0slp:1L'
2023-11-13 18:53:50.867 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living Room Lights: Calling _adapt_light from _update_attrs_and_maybe_adapt_lights: 'light.local_living_room_light_1' with transition 60.0 and context.id=01HF3TRAGF:al:JRUX:0slp:1M
2023-11-13 18:53:50.880 DEBUG (MainThread) [custom_components.adaptive_lighting.adaptation_utils] Preparing adaptation data for light.local_living_room_light_1 with service data {'entity_id': 'light.local_living_room_light_1', 'brightness': 153}
2023-11-13 18:53:50.880 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living Room Lights: execute_cancellable_adaptation_calls with data: AdaptationData(entity_id=light.local_living_room_light_1, context_id=01HF3TRAGF:al:JRUX:0slp:1M, sleep_time=0.0, force=True, max_length=1, which=brightness, initial_sleep=False)
2023-11-13 18:53:50.881 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living Room Lights: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.local_living_room_light_1', 'brightness': 153} with context.id='01HF3TRAGF:al:JRUX:0slp:1M'
2023-11-13 18:53:50.882 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.local_living_room_light_1']')' event with context.id='01HF3TRAGF:al:JRUX:0slp:1M'
2023-11-13 18:53:50.883 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] (0) _service_interceptor_turn_on_handler: call.context.id='01HF3TRAGF:al:JRUX:0slp:1M', is_skipped_hash='False'
2023-11-13 18:53:50.945 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.local_living_room_light_1' 'state_changed' event: '{'min_color_temp_kelvin': 2702, 'max_color_temp_kelvin': 6535, 'min_mireds': 153, 'max_mireds': 370, 'effect_list': ['Night', 'Read', 'Meeting', 'Leasure', 'Soft', 'Rainbow', 'Shine', 'Beautiful'], 'supported_color_modes': [<ColorMode.COLOR_TEMP: 'color_temp'>, <ColorMode.HS: 'hs'>], 'color_mode': <ColorMode.COLOR_TEMP: 'color_temp'>, 'brightness': 153, 'color_temp_kelvin': 2702, 'color_temp': 370, 'hs_color': (28.391, 65.659), 'rgb_color': (255, 166, 87), 'xy_color': (0.526, 0.387), 'effect': None, 'raw_state': True, 'friendly_name': 'Local Living Room Light 1', 'supported_features': 23}' with context.id='01HF3TRAGF:al:JRUX:0slp:1M'
2023-11-13 18:53:50.945 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] AdaptiveLightingManager: New adapt '<state light.local_living_room_light_1=on; min_color_temp_kelvin=2702, max_color_temp_kelvin=6535, min_mireds=153, max_mireds=370, effect_list=['Night', 'Read', 'Meeting', 'Leasure', 'Soft', 'Rainbow', 'Shine', 'Beautiful'], supported_color_modes=[<ColorMode.COLOR_TEMP: 'color_temp'>, <ColorMode.HS: 'hs'>], color_mode=color_temp, brightness=153, color_temp_kelvin=2702, color_temp=370, hs_color=(28.391, 65.659), rgb_color=(255, 166, 87), xy_color=(0.526, 0.387), effect=None, raw_state=True, friendly_name=Local Living Room Light 1, supported_features=23 @ 2023-11-13T18:53:35.762735+11:00>' found for light.local_living_room_light_1
2023-11-13 18:53:50.946 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] No transition in last adapt for light light.local_living_room_light_1, not starting timer.
basnijholt commented 7 months ago

Thanks for reporting. Sounds like an actual bug. Will look into it when I'll have time.

evergreen0057 commented 7 months ago

Cheers, thanks for picking this up. Hopefully it's a easy fix

evergreen0057 commented 5 months ago

@basnijholt is there any update on when a fix will be ready for this issue?

Wookbrews commented 4 months ago

I recently ran into the same problem, oddly enough I found a Wiz bulb where it transitioned immediately (ignored transition time) and a Globe bulb that seemed to work correctly. Maybe this somehow related to the bulb vendor?