basnijholt / adaptive-lighting

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

Light turned on within 1-2 minutes after being turned off (only if AL is enabled) #920

Closed bcutter closed 6 months ago

bcutter commented 8 months 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-02-11 18:45:13.625 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Called 'adaptive_lighting.set_manual_control' service with '{'manual_control': True, 'entity_id': ['switch.adaptive_lighting'], 'lights': ['light.licht_aussenbereich_alle']}'
2024-02-11 18:45:13.625 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Expanded light.licht_aussenbereich_alle to ['light.licht_wintergarten_bulb']
2024-02-11 18:45:13.625 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] 'adaptive_lighting.manual_control' event fired for switch.adaptive_lighting for light light.licht_wintergarten_bulb
2024-02-11 18:45:13.625 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Marking 'light.licht_wintergarten_bulb' as manually controlled.
2024-02-11 18:45:13.631 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] (0) _service_interceptor_turn_on_handler: call.context.id='01HPCMBVHDBJ24RM1HK4Z0CF2X', is_skipped_hash='False'
2024-02-11 18:45:13.632 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] (1) _service_interceptor_turn_on_handler: call='<ServiceCall light.turn_on (c:01HPCMBVHDBJ24RM1HK4Z0CF2X): entity_id=['light.licht_aussenbereich_alle'], params=transition=1.0, brightness=255>', service_data='{'entity_id': ['light.licht_aussenbereich_alle'], 'params': {'transition': 1.0, 'brightness': 255}}'
2024-02-11 18:45:13.632 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] No switch found for entity_id='light.licht_aussenbereich_alle', skipped='['light.licht_aussenbereich_alle']'
2024-02-11 18:45:13.633 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] (2) _service_interceptor_turn_on_handler: switch_to_eids='{}', skipped='['light.licht_aussenbereich_alle']'
2024-02-11 18:45:13.638 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.licht_wintergarten_bulb']')' event with context.id='01HPCMBVHDBJ24RM1HK4Z0CF2X'
2024-02-11 18:45:13.638 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] (0) _service_interceptor_turn_on_handler: call.context.id='01HPCMBVHDBJ24RM1HK4Z0CF2X', is_skipped_hash='False'
2024-02-11 18:45:13.639 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] (1) _service_interceptor_turn_on_handler: call='<ServiceCall light.turn_on (c:01HPCMBVHDBJ24RM1HK4Z0CF2X): entity_id=['light.licht_wintergarten_bulb'], params=transition=1.0, brightness=255>', service_data='{'entity_id': ['light.licht_wintergarten_bulb'], 'params': {'transition': 1.0, 'brightness': 255}}'
2024-02-11 18:45:13.639 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Switch is off or light is already on for entity_id='light.licht_wintergarten_bulb', skipped='[]' (is_on='True', is_state='False', manual_control='True', switch._intercept='True')
2024-02-11 18:45:13.639 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] (2) _service_interceptor_turn_on_handler: switch_to_eids='{}', skipped='['light.licht_wintergarten_bulb']'
2024-02-11 18:45:13.786 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.licht_wintergarten_bulb' 'state_changed' event: '{'supported_color_modes': [<ColorMode.BRIGHTNESS: 'brightness'>], 'color_mode': <ColorMode.BRIGHTNESS: 'brightness'>, 'brightness': 254, 'is_deconz_group': False, 'friendly_name': 'Licht Wintergarten Bulb', 'supported_features': <LightEntityFeature.TRANSITION|FLASH: 40>}' with context.id='01HPCMBVHDBJ24RM1HK4Z0CF2X'
2024-02-11 18:45:13.786 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'off' → 'on' event for 'light.licht_wintergarten_bulb' with context.id='01HPCMBVHDBJ24RM1HK4Z0CF2X'
2024-02-11 18:45:13.786 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01HPCMBVHDBJ24RM1HK4Z0CF2X'
2024-02-11 18:45:13.786 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] just_turned_off: State change 'off' → 'on' triggered by 'light.turn_on'
2024-02-11 18:45:13.787 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01HPCMBVHDBJ24RM1HK4Z0CF2X'
2024-02-11 18:45:13.787 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Alle Lichter: '_update_attrs_and_maybe_adapt_lights' called with context.id='01HPCMBVSV:al:IFWG:lght:72' lights: '['light.licht_wintergarten_bulb']', transition: '1.0', force: 'True'
2024-02-11 18:45:13.790 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Alle Lichter: filtered_lights: '['light.licht_wintergarten_bulb']'
2024-02-11 18:45:13.790 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Alle Lichter: 'light.licht_wintergarten_bulb' is being manually controlled, stop adapting, context.id=01HPCMBVSV:al:IFWG:lght:72.
2024-02-11 18:45:13.807 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.licht_wintergarten_bulb' 'state_changed' event: '{'supported_color_modes': [<ColorMode.BRIGHTNESS: 'brightness'>], 'color_mode': <ColorMode.BRIGHTNESS: 'brightness'>, 'brightness': 1, 'is_deconz_group': False, 'friendly_name': 'Licht Wintergarten Bulb', 'supported_features': <LightEntityFeature.TRANSITION|FLASH: 40>}' with context.id='01HPCMBVHDBJ24RM1HK4Z0CF2X'
2024-02-11 18:45:14.970 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.licht_wintergarten_bulb' 'state_changed' event: '{'supported_color_modes': [<ColorMode.BRIGHTNESS: 'brightness'>], 'color_mode': <ColorMode.BRIGHTNESS: 'brightness'>, 'brightness': 252, 'is_deconz_group': False, 'friendly_name': 'Licht Wintergarten Bulb', 'supported_features': <LightEntityFeature.TRANSITION|FLASH: 40>}' with context.id='01HPCMBVHDBJ24RM1HK4Z0CF2X'
2024-02-11 18:45:16.694 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.licht_wintergarten_bulb' 'state_changed' event: '{'supported_color_modes': [<ColorMode.BRIGHTNESS: 'brightness'>], 'color_mode': <ColorMode.BRIGHTNESS: 'brightness'>, 'brightness': 254, 'is_deconz_group': False, 'friendly_name': 'Licht Wintergarten Bulb', 'supported_features': <LightEntityFeature.TRANSITION|FLASH: 40>}' with context.id='01HPCMBVHDBJ24RM1HK4Z0CF2X'
...
2024-02-11 18:46:15.985 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Called 'adaptive_lighting.set_manual_control' service with '{'manual_control': False, 'entity_id': ['switch.adaptive_lighting'], 'lights': ['light.licht_aussenbereich_alle']}'
2024-02-11 18:46:15.986 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Expanded light.licht_aussenbereich_alle to ['light.licht_wintergarten_bulb']
2024-02-11 18:46:15.986 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Alle Lichter: '_update_attrs_and_maybe_adapt_lights' called with context.id='01HPCMDRHJ:al:IFWG:srvc:73' lights: '['light.licht_wintergarten_bulb']', transition: '1.0', force: 'True'
2024-02-11 18:46:15.994 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Alle Lichter: filtered_lights: '['light.licht_wintergarten_bulb']'
2024-02-11 18:46:15.994 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01HPCMBVHDBJ24RM1HK4Z0CF2X'
2024-02-11 18:46:15.994 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Alle Lichter: Calling _adapt_light from _update_attrs_and_maybe_adapt_lights: 'light.licht_wintergarten_bulb' with transition 1.0 and context.id=01HPCMDRHJ:al:IFWG:srvc:73
2024-02-11 18:46:16.020 DEBUG (MainThread) [custom_components.adaptive_lighting.adaptation_utils] Preparing adaptation data for light.licht_wintergarten_bulb with service data {'entity_id': 'light.licht_wintergarten_bulb', 'transition': 1.0, 'brightness': 172}
2024-02-11 18:46:16.020 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Alle Lichter: execute_cancellable_adaptation_calls with data: AdaptationData(entity_id=light.licht_wintergarten_bulb, context_id=01HPCMDRHJ:al:IFWG:srvc:73, sleep_time=1.0, force=True, max_length=1, which=brightness, initial_sleep=False)
2024-02-11 18:46:16.021 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Alle Lichter: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.licht_wintergarten_bulb', 'brightness': 172, 'transition': 1.0} with context.id='01HPCMDRHJ:al:IFWG:srvc:73'
2024-02-11 18:46:16.022 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.licht_wintergarten_bulb']')' event with context.id='01HPCMDRHJ:al:IFWG:srvc:73'
2024-02-11 18:46:16.022 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] (0) _service_interceptor_turn_on_handler: call.context.id='01HPCMDRHJ:al:IFWG:srvc:73', is_skipped_hash='False'
2024-02-11 18:46:16.212 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_off('['light.licht_wintergarten_bulb']', transition=1.0)' event with context.id='01HPCMCV4RYJ4F2EJWE6C8F14A'
2024-02-11 18:46:16.233 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.licht_wintergarten_bulb' 'state_changed' event: '{'supported_color_modes': [<ColorMode.BRIGHTNESS: 'brightness'>], 'color_mode': <ColorMode.BRIGHTNESS: 'brightness'>, 'brightness': 172, 'is_deconz_group': False, 'friendly_name': 'Licht Wintergarten Bulb', 'supported_features': <LightEntityFeature.TRANSITION|FLASH: 40>}' with context.id='01HPCMCV4RYJ4F2EJWE6C8F14A'
2024-02-11 18:46:16.243 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'on' → 'off' event for 'light.licht_wintergarten_bulb' with context.id='01HPCMCV4RYJ4F2EJWE6C8F14A'
...
2024-02-11 18:47:18.151 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.licht_wintergarten_bulb' 'state_changed' event: '{'supported_color_modes': [<ColorMode.BRIGHTNESS: 'brightness'>], 'color_mode': <ColorMode.BRIGHTNESS: 'brightness'>, 'brightness': 1, 'is_deconz_group': False, 'friendly_name': 'Licht Wintergarten Bulb', 'supported_features': <LightEntityFeature.TRANSITION|FLASH: 40>}' with context.id='01HPCMFN7BQKA57GTA2NQ09QV6'
2024-02-11 18:47:18.152 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'off' → 'on' event for 'light.licht_wintergarten_bulb' with context.id='01HPCMFN7BQKA57GTA2NQ09QV6'
2024-02-11 18:47:18.152 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01HPCMFN7BQKA57GTA2NQ09QV6'
2024-02-11 18:47:18.152 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] just_turned_off: delta_time='61.910505' > delay='5'
2024-02-11 18:47:18.153 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01HPCMFN7BQKA57GTA2NQ09QV6'
2024-02-11 18:47:18.153 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Alle Lichter: Ignoring 'off' → 'on' event for 'light.licht_wintergarten_bulb' with context.id='01HPCMFN7BQKA57GTA2NQ09QV6' because 'light.turn_on' was not called by HA and 'detect_non_ha_changes' is False
2024-02-11 18:47:18.153 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Marking 'light.licht_wintergarten_bulb' as manually controlled.
...
  1. Your Adaptive Lighting configuration:

I think this issue template is outdated. I don't have a YAML for my AL configuration, it's all done in the UI!

So manually:

  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)
      Not using ZB2MQTT or ZHA, using deCONZ.
  2. Describe the bug and how to reproduce it:

If AL is enabled, one light is turned on 1 to 2 minutes after it has been turned off (by an automation).

Currently only one light, a Classic A60 W clear - LIGHTIFY is affected by this.

  1. Steps to reproduce the behavior:

Right after step 3: grafik

grafik

bcutter commented 8 months ago

Edit: even with the light removed from AL integraiton it seems the issue persists:

grafik

I wonder why it made a difference to my first discovery earlier today with

If the switch.adaptive_lighting is disabled, the light does NOT (!) get turned on again.

Can someone please have a look at the debug log and tell me what to conclude of it?

bcutter commented 8 months ago

Latest update:

  1. 1st discovery: if I turn the light on and off manually, the issue does NOT occur (light does not get turned on again)
  2. So I had a look at my automation which handles that light at 95 % during the day:
    • Until now I had this order:
      - delay:
        hours: 0
        minutes: 0
        seconds: 30
        milliseconds: 0
      - service: adaptive_lighting.set_manual_control
      data:
        manual_control: false
        entity_id: switch.adaptive_lighting
        lights: light.licht_aussenbereich_alle
      - service: input_boolean.turn_off
      data: {}
      target:
        entity_id: input_boolean.licht_aussenbereich_nachtmodus
      - service: light.turn_off
      data:
        transition: 1
      target:
        entity_id: light.licht_aussenbereich_alle
    • Now I tested this sequence:
      - delay:
        hours: 0
        minutes: 0
        seconds: 30
        milliseconds: 0
      - service: input_boolean.turn_off
      data: {}
      target:
        entity_id: input_boolean.licht_aussenbereich_nachtmodus
      - service: light.turn_off
      data:
        transition: 1
      target:
        entity_id: light.licht_aussenbereich_alle
      - service: adaptive_lighting.set_manual_control
      data:
        manual_control: false
        entity_id: switch.adaptive_lighting
        lights: light.licht_aussenbereich_alle

So basically what I just did is: grafik

And the result: the issue seems to have disappeared.

I need to test this a bit longer to see if it actually resolved the issue this way.

As neither the automation nor Adaptive Lighting integration updated but only deCONZ got updated, my theory is that deCONZ handles things a bit different which now conflicts with the Adaptive Lighting behavior so the actual order gets important.

In detail I have no idea why it makes a difference from an AL view if the light is turned off first and then the manual control is turned off, or vice versa. But obviously it does...

alinelena commented 8 months ago

I can confirm this issue... but the random light in question is an ikea rgb tradfri...no color_temperature

th3w1zard1 commented 8 months ago

I think this issue template is outdated. I don't have a YAML for my AL configuration, it's all done in the UI!

The template isn't outdated, you can put a screenshot of your ui config or look at hass's entity output under developer. Some users use yaml to configure their adaptive lighting switches

basnijholt commented 8 months ago

[Copy pasting this message in a few recent open issues]

I just wanted to take a moment to express my heartfelt thanks to everyone that is active in this repo. Your contributions, from answering questions to addressing issues, have been invaluable. It's amazing to see how supportive and helpful our community is!

Adaptive Lighting is all about enhancing your living spaces with smart, sunlight-responsive lighting. We've had quite a few discussions and open issues recently, and I see this as a positive sign of our community's engagement and growth. If you come across anything in the documentation that's unclear or if you have suggestions for improvement, please don't hesitate to share!. Your feedback is crucial for making Adaptive Lighting better for everyone.

On a personal note, I've recently welcomed twin boys into my family, which has been an incredible and life-changing experience. As you can imagine, my time is now more limited, and while I'm doing my best to keep up with the project, there may be delays in my responses. I appreciate your understanding and patience during this time.

Rest assured, I'm fully committed to addressing any bugs, especially those related to new Home Assistant updates, as swiftly as possible. I understand that many issues may stem from hardware limitations or misunderstandings about things like Zigbee groups. Your continued support and collaboration in helping each other out not only strengthen our community but also enhance the Adaptive Lighting experience for all.

Thank you once again for your understanding, patience, and support. Let's keep our houses well lit and adaptive for maximal enjoyment of life! 🌞🏠🌙

bcutter commented 8 months ago

Note regarding https://github.com/basnijholt/adaptive-lighting/issues/920#issuecomment-1937903397: did not happen again.

ncd7 commented 6 months ago

If this is resolved, I would close the issue to keep @basnijholt sane :).

bcutter commented 6 months ago

I'd do so as my specific issue seems to be solved. Did not close this issue yet because of e. g. @alinelena sending a +1 on this at https://github.com/basnijholt/adaptive-lighting/issues/920#issuecomment-1938123299.

alinelena commented 6 months ago

I have retired my rgb ideas changed to some cheap tuya... and did not see any issue... by the way using deconz too