basnijholt / adaptive-lighting

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

transition not working with action adaptive_lighting.apply #1045

Open chpego opened 1 month ago

chpego commented 1 month ago

Home Assistant Adaptive Lighting Issue Template

Bug Reports

If you need help with using or configuring Adaptive Lighting, please open a Q&A discussion thread here instead.

Before submitting a bug report, please follow these troubleshooting steps:

Please confirm that you have completed the following steps:

Required information for bug reports:

Please include the following information in your issue.

Issues missing this information may not be addressed.

  1. Debug logs captured while the issue occurred. See here for instructions on enabling debug logging:
2024-08-30 23:58:30.718 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Called 'adaptive_lighting.apply' service with '{'entity_id': ['switch.adaptive_lighting_al'], 'lights': ['light.signify_netherlands_b_v_lcl001_lumiere'], 'adapt_brightness': True, 'adapt_color': True, 'turn_on_lights': True, 'transition': 60.0, 'prefer_rgb_color': False}'
2024-08-30 23:58:30.719 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] al: Setting color_temp of light light.signify_netherlands_b_v_lcl001_lumiere
2024-08-30 23:58:30.719 DEBUG (MainThread) [custom_components.adaptive_lighting.adaptation_utils] Preparing adaptation data for light.signify_netherlands_b_v_lcl001_lumiere with service data {'entity_id': 'light.signify_netherlands_b_v_lcl001_lumiere', 'transition': 60.0, 'brightness': 23, 'color_temp_kelvin': 2000}
2024-08-30 23:58:30.719 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] al: execute_cancellable_adaptation_calls with data: AdaptationData(entity_id=light.signify_netherlands_b_v_lcl001_lumiere, context_id=01J6JMR3HY:al:MFWA:srvc:07, sleep_time=30.0, force=True, max_length=2, which=both, initial_sleep=False)
2024-08-30 23:58:30.719 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] al: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.signify_netherlands_b_v_lcl001_lumiere', 'brightness': 23, 'transition': 30.0} with context.id='01J6JMR3HY:al:MFWA:srvc:07'
2024-08-30 23:58:30.719 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.signify_netherlands_b_v_lcl001_lumiere']')' event with context.id='01J6JMR3HY:al:MFWA:srvc:07'
2024-08-30 23:58:30.719 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] (0) _service_interceptor_turn_on_handler: call.context.id='01J6JMR3HY:al:MFWA:srvc:07', is_skipped_hash='False'
2024-08-30 23:58:30.752 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.signify_netherlands_b_v_lcl001_lumiere' 'state_changed' event: '{'min_color_temp_kelvin': 2000, 'max_color_temp_kelvin': 6535, 'min_mireds': 153, 'max_mireds': 500, 'effect_list': ['colorloop'], 'supported_color_modes': [<ColorMode.COLOR_TEMP: 'color_temp'>, <ColorMode.XY: 'xy'>], 'effect': None, 'color_mode': <ColorMode.COLOR_TEMP: 'color_temp'>, 'brightness': 23, 'color_temp_kelvin': 2000, 'color_temp': 500, 'hs_color': (30.601, 94.547), 'rgb_color': (255, 136, 13), 'xy_color': (0.599, 0.382), 'off_with_transition': False, 'off_brightness': None, 'friendly_name': 'Signify Netherlands B.V. LCL001 Lumière', 'supported_features': <LightEntityFeature.EFFECT|FLASH|TRANSITION: 44>}' with context.id='01J6JMR3HY:al:MFWA:srvc:07'
2024-08-30 23:58:30.752 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] AdaptiveLightingManager: New adapt '<state light.signify_netherlands_b_v_lcl001_lumiere=on; min_color_temp_kelvin=2000, max_color_temp_kelvin=6535, min_mireds=153, max_mireds=500, effect_list=['colorloop'], supported_color_modes=[<ColorMode.COLOR_TEMP: 'color_temp'>, <ColorMode.XY: 'xy'>], effect=None, color_mode=color_temp, brightness=23, color_temp_kelvin=2000, color_temp=500, hs_color=(30.601, 94.547), rgb_color=(255, 136, 13), xy_color=(0.599, 0.382), off_with_transition=False, off_brightness=None, friendly_name=Signify Netherlands B.V. LCL001 Lumière, supported_features=44 @ 2024-08-30T23:58:30.752083+02:00>' found for light.signify_netherlands_b_v_lcl001_lumiere
2024-08-30 23:58:30.752 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Start transition timer of 30.0 seconds for light light.signify_netherlands_b_v_lcl001_lumiere
2024-08-30 23:58:30.752 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'off' → 'on' event for 'light.signify_netherlands_b_v_lcl001_lumiere' with context.id='01J6JMR3HY:al:MFWA:srvc:07'
2024-08-30 23:58:30.752 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01J6JMR3HY:al:MFWA:srvc:07'
2024-08-30 23:58:30.752 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Cancelled ongoing brightness adaptation calls (<Task pending name='Task-303694' coro=<AdaptiveSwitch._execute_adaptation_calls() running at /config/custom_components/adaptive_lighting/switch.py:1295> wait_for=<Future pending cb=[Task.task_wakeup()]> cb=[Task.task_wakeup()]>) for 'light.signify_netherlands_b_v_lcl001_lumiere'
2024-08-30 23:58:30.752 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] just_turned_off: State change 'off' → 'on' triggered by 'light.turn_on'
2024-08-30 23:58:30.752 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01J6JMR3HY:al:MFWA:srvc:07'
2024-08-30 23:58:30.752 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] al: '_update_attrs_and_maybe_adapt_lights' called with context.id='01J6JMR3K0:al:MFWA:lght:08' lights: '['light.signify_netherlands_b_v_lcl001_lumiere']', transition: '1.0', force: 'True'
2024-08-30 23:58:30.752 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] al: filtered_lights: '['light.signify_netherlands_b_v_lcl001_lumiere']'
2024-08-30 23:58:30.752 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01J6JMR3HY:al:MFWA:srvc:07'
2024-08-30 23:58:30.752 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] al: Calling _adapt_light from _update_attrs_and_maybe_adapt_lights: 'light.signify_netherlands_b_v_lcl001_lumiere' with transition 1.0 and context.id=01J6JMR3K0:al:MFWA:lght:08
2024-08-30 23:58:30.753 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] al: Setting color_temp of light light.signify_netherlands_b_v_lcl001_lumiere
2024-08-30 23:58:30.753 DEBUG (MainThread) [custom_components.adaptive_lighting.adaptation_utils] Preparing adaptation data for light.signify_netherlands_b_v_lcl001_lumiere with service data {'entity_id': 'light.signify_netherlands_b_v_lcl001_lumiere', 'transition': 1.0, 'brightness': 23, 'color_temp_kelvin': 2000}
2024-08-30 23:58:30.753 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Cancelled ongoing brightness adaptation calls (<Task cancelling name='Task-303694' coro=<AdaptiveSwitch._execute_adaptation_calls() running at /config/custom_components/adaptive_lighting/switch.py:1295> wait_for=<Future cancelled> cb=[Task.task_wakeup()]>) for 'light.signify_netherlands_b_v_lcl001_lumiere'
2024-08-30 23:58:30.753 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] al: execute_cancellable_adaptation_calls with data: AdaptationData(entity_id=light.signify_netherlands_b_v_lcl001_lumiere, context_id=01J6JMR3K0:al:MFWA:lght:08, sleep_time=0.5, force=True, max_length=2, which=both, initial_sleep=False)
2024-08-30 23:58:30.753 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] al: Ongoing adaptation of light.signify_netherlands_b_v_lcl001_lumiere cancelled, with AdaptationData: AdaptationData(entity_id=light.signify_netherlands_b_v_lcl001_lumiere, context_id=01J6JMR3HY:al:MFWA:srvc:07, sleep_time=30.0, force=True, max_length=2, which=both, initial_sleep=False)
2024-08-30 23:58:39.809 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_off('['light.signify_netherlands_b_v_lcl001_lumiere']', transition=None)' event with context.id='01J6JMRCE16HV03E3MDM7ZBQ23'
2024-08-30 23:58:39.847 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'on' → 'off' event for 'light.signify_netherlands_b_v_lcl001_lumiere' with context.id='01J6JMRCE16HV03E3MDM7ZBQ23'
2024-08-30 23:58:46.082 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] al: '_update_attrs_and_maybe_adapt_lights' called with context.id='01J6JMRJJ2:al:MFWA:ntrv:09' lights: 'None', transition: '45.0', force: 'False'
2024-08-30 23:58:46.082 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] al: filtered_lights: '[]'

2024-08-30 23:58:46.816 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Called 'adaptive_lighting.apply' service with '{'entity_id': ['switch.adaptive_lighting_al'], 'lights': ['light.signify_netherlands_b_v_lcl001_lumiere'], 'adapt_brightness': True, 'adapt_color': True, 'turn_on_lights': True, 'transition': 120.0, 'prefer_rgb_color': False}'
2024-08-30 23:58:46.816 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] al: Setting color_temp of light light.signify_netherlands_b_v_lcl001_lumiere
2024-08-30 23:58:46.816 DEBUG (MainThread) [custom_components.adaptive_lighting.adaptation_utils] Preparing adaptation data for light.signify_netherlands_b_v_lcl001_lumiere with service data {'entity_id': 'light.signify_netherlands_b_v_lcl001_lumiere', 'transition': 120.0, 'brightness': 22, 'color_temp_kelvin': 2000}
2024-08-30 23:58:46.816 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] al: execute_cancellable_adaptation_calls with data: AdaptationData(entity_id=light.signify_netherlands_b_v_lcl001_lumiere, context_id=01J6JMRK90:al:MFWA:srvc:0A, sleep_time=60.0, force=True, max_length=2, which=both, initial_sleep=False)
2024-08-30 23:58:46.816 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] al: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.signify_netherlands_b_v_lcl001_lumiere', 'brightness': 22, 'transition': 60.0} with context.id='01J6JMRK90:al:MFWA:srvc:0A'
2024-08-30 23:58:46.816 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.signify_netherlands_b_v_lcl001_lumiere']')' event with context.id='01J6JMRK90:al:MFWA:srvc:0A'
2024-08-30 23:58:46.816 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] (0) _service_interceptor_turn_on_handler: call.context.id='01J6JMRK90:al:MFWA:srvc:0A', is_skipped_hash='False'
2024-08-30 23:58:46.852 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.signify_netherlands_b_v_lcl001_lumiere' 'state_changed' event: '{'min_color_temp_kelvin': 2000, 'max_color_temp_kelvin': 6535, 'min_mireds': 153, 'max_mireds': 500, 'effect_list': ['colorloop'], 'supported_color_modes': [<ColorMode.COLOR_TEMP: 'color_temp'>, <ColorMode.XY: 'xy'>], 'effect': None, 'color_mode': <ColorMode.COLOR_TEMP: 'color_temp'>, 'brightness': 22, 'color_temp_kelvin': 2000, 'color_temp': 500, 'hs_color': (30.601, 94.547), 'rgb_color': (255, 136, 13), 'xy_color': (0.599, 0.382), 'off_with_transition': False, 'off_brightness': None, 'friendly_name': 'Signify Netherlands B.V. LCL001 Lumière', 'supported_features': <LightEntityFeature.EFFECT|FLASH|TRANSITION: 44>}' with context.id='01J6JMRK90:al:MFWA:srvc:0A'
2024-08-30 23:58:46.852 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] AdaptiveLightingManager: New adapt '<state light.signify_netherlands_b_v_lcl001_lumiere=on; min_color_temp_kelvin=2000, max_color_temp_kelvin=6535, min_mireds=153, max_mireds=500, effect_list=['colorloop'], supported_color_modes=[<ColorMode.COLOR_TEMP: 'color_temp'>, <ColorMode.XY: 'xy'>], effect=None, color_mode=color_temp, brightness=22, color_temp_kelvin=2000, color_temp=500, hs_color=(30.601, 94.547), rgb_color=(255, 136, 13), xy_color=(0.599, 0.382), off_with_transition=False, off_brightness=None, friendly_name=Signify Netherlands B.V. LCL001 Lumière, supported_features=44 @ 2024-08-30T23:58:46.852374+02:00>' found for light.signify_netherlands_b_v_lcl001_lumiere
2024-08-30 23:58:46.852 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Start transition timer of 60.0 seconds for light light.signify_netherlands_b_v_lcl001_lumiere
2024-08-30 23:58:46.852 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'off' → 'on' event for 'light.signify_netherlands_b_v_lcl001_lumiere' with context.id='01J6JMRK90:al:MFWA:srvc:0A'
2024-08-30 23:58:46.852 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01J6JMRK90:al:MFWA:srvc:0A'
2024-08-30 23:58:46.852 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Cancelled ongoing brightness adaptation calls (<Task pending name='Task-305900' coro=<AdaptiveSwitch._execute_adaptation_calls() running at /config/custom_components/adaptive_lighting/switch.py:1295> wait_for=<Future pending cb=[Task.task_wakeup()]> cb=[Task.task_wakeup()]>) for 'light.signify_netherlands_b_v_lcl001_lumiere'
2024-08-30 23:58:46.852 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] just_turned_off: State change 'off' → 'on' triggered by 'light.turn_on'
2024-08-30 23:58:46.852 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01J6JMRK90:al:MFWA:srvc:0A'
2024-08-30 23:58:46.852 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] al: '_update_attrs_and_maybe_adapt_lights' called with context.id='01J6JMRKA4:al:MFWA:lght:0B' lights: '['light.signify_netherlands_b_v_lcl001_lumiere']', transition: '1.0', force: 'True'
2024-08-30 23:58:46.853 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] al: filtered_lights: '['light.signify_netherlands_b_v_lcl001_lumiere']'
2024-08-30 23:58:46.853 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01J6JMRK90:al:MFWA:srvc:0A'
2024-08-30 23:58:46.853 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] al: Calling _adapt_light from _update_attrs_and_maybe_adapt_lights: 'light.signify_netherlands_b_v_lcl001_lumiere' with transition 1.0 and context.id=01J6JMRKA4:al:MFWA:lght:0B
2024-08-30 23:58:46.853 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] al: Setting color_temp of light light.signify_netherlands_b_v_lcl001_lumiere
2024-08-30 23:58:46.853 DEBUG (MainThread) [custom_components.adaptive_lighting.adaptation_utils] Preparing adaptation data for light.signify_netherlands_b_v_lcl001_lumiere with service data {'entity_id': 'light.signify_netherlands_b_v_lcl001_lumiere', 'transition': 1.0, 'brightness': 23, 'color_temp_kelvin': 2000}
2024-08-30 23:58:46.853 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Cancelled ongoing brightness adaptation calls (<Task cancelling name='Task-305900' coro=<AdaptiveSwitch._execute_adaptation_calls() running at /config/custom_components/adaptive_lighting/switch.py:1295> wait_for=<Future cancelled> cb=[Task.task_wakeup()]>) for 'light.signify_netherlands_b_v_lcl001_lumiere'
2024-08-30 23:58:46.853 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] al: execute_cancellable_adaptation_calls with data: AdaptationData(entity_id=light.signify_netherlands_b_v_lcl001_lumiere, context_id=01J6JMRKA4:al:MFWA:lght:0B, sleep_time=0.5, force=True, max_length=2, which=both, initial_sleep=False)
2024-08-30 23:58:46.853 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] al: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.signify_netherlands_b_v_lcl001_lumiere', 'brightness': 23, 'transition': 0.5} with context.id='01J6JMRKA4:al:MFWA:lght:0B'
2024-08-30 23:58:46.853 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.signify_netherlands_b_v_lcl001_lumiere']')' event with context.id='01J6JMRKA4:al:MFWA:lght:0B'
2024-08-30 23:58:46.853 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] (0) _service_interceptor_turn_on_handler: call.context.id='01J6JMRKA4:al:MFWA:lght:0B', is_skipped_hash='False'
2024-08-30 23:58:46.854 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] al: Ongoing adaptation of light.signify_netherlands_b_v_lcl001_lumiere cancelled, with AdaptationData: AdaptationData(entity_id=light.signify_netherlands_b_v_lcl001_lumiere, context_id=01J6JMRK90:al:MFWA:srvc:0A, sleep_time=60.0, force=True, max_length=2, which=both, initial_sleep=False)
2024-08-30 23:58:46.888 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.signify_netherlands_b_v_lcl001_lumiere' 'state_changed' event: '{'min_color_temp_kelvin': 2000, 'max_color_temp_kelvin': 6535, 'min_mireds': 153, 'max_mireds': 500, 'effect_list': ['colorloop'], 'supported_color_modes': [<ColorMode.COLOR_TEMP: 'color_temp'>, <ColorMode.XY: 'xy'>], 'effect': None, 'color_mode': <ColorMode.COLOR_TEMP: 'color_temp'>, 'brightness': 23, 'color_temp_kelvin': 2000, 'color_temp': 500, 'hs_color': (30.601, 94.547), 'rgb_color': (255, 136, 13), 'xy_color': (0.599, 0.382), 'off_with_transition': False, 'off_brightness': None, 'friendly_name': 'Signify Netherlands B.V. LCL001 Lumière', 'supported_features': <LightEntityFeature.EFFECT|FLASH|TRANSITION: 44>}' with context.id='01J6JMRKA4:al:MFWA:lght:0B'
2024-08-30 23:58:46.888 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] AdaptiveLightingManager: New adapt '<state light.signify_netherlands_b_v_lcl001_lumiere=on; min_color_temp_kelvin=2000, max_color_temp_kelvin=6535, min_mireds=153, max_mireds=500, effect_list=['colorloop'], supported_color_modes=[<ColorMode.COLOR_TEMP: 'color_temp'>, <ColorMode.XY: 'xy'>], effect=None, color_mode=color_temp, brightness=23, color_temp_kelvin=2000, color_temp=500, hs_color=(30.601, 94.547), rgb_color=(255, 136, 13), xy_color=(0.599, 0.382), off_with_transition=False, off_brightness=None, friendly_name=Signify Netherlands B.V. LCL001 Lumière, supported_features=44 @ 2024-08-30T23:58:46.852374+02:00>' found for light.signify_netherlands_b_v_lcl001_lumiere
2024-08-30 23:58:46.889 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Start transition timer of 0.5 seconds for light light.signify_netherlands_b_v_lcl001_lumiere
2024-08-30 23:58:47.390 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Transition finished for light light.signify_netherlands_b_v_lcl001_lumiere
  1. Your Adaptive Lighting configuration:
by default
  1. (If using Zigbee2MQTT), provide your configuration files (remove all personal information before posting):
    • devices.yaml
    • groups.yaml
    • configuration.yaml ⚠️; Warning REMOVE ALL of the PERSONAL INFORMATION BELOW before posting ⚠️;
      • mqtt: server:
      • mqtt: user:
      • mqtt: password:
      • advanced: pan_id:
      • advanced: network_key:
      • anything in log_syslog if you use this
    • Brand and model number of problematic light(s)


4.  Describe the bug and how to reproduce it:
the transition time doesn't seem to be respected if I go to a value greater than 60 (or maybe more) but it works for a transition value of 60 but not 120. I use the adaptive_lighting.apply action
I can't understand the logs

5. Steps to reproduce the behavior:
chpego commented 5 days ago

UP please :)

djurny commented 5 days ago

Hi there, If you use the disable adaptive lighting temporarily and use home assistant's light.turn_on with transition set, does it work as you would expect?

Judging by the logging it's a Philips Hue light so I'm assuming it's Zigbee based, so can you enable debug logging of the MQTT integration as well?

Groetjes,