Closed Liam-Whiteside closed 1 year ago
i am also seeing this with my zigbee bathroom light, it may be related to smart light switches as that light is the only one having the issue, and also the only one we really control a lot with the physical (zigbe) dimmer switch
Using Philips hue all through my house. Anytime I activate the "last switch option" it will turn on some of my lights that were off before. And I'll turn them off via the HASS App on my iPad or my iPhone and they'll come back on. When I look at my log book it says "Kitchen Soffit Lights turned on triggered by state of Kitchen soffit lights turned on" I don't have an automation set. Idk what is going on. What did I do wrong to make this keep happening?
Are these all a result of using transition?
My Sengled bulbs (the only ones I use) suffer from random turn ons when I've tried using transition to off, with or without AL at involved. The bulbs take over handling the transition locally and HA shows them as now off but they are still dimming. At some point a random bulb seems to announce its current state while still transitioning to off. HA then sees this as an on event, marks it as such and adaptive lighting resumes adapting. The only fix I've found is to not use transition.
If you're NOT using transition anywhere and a bulb randomly comes back on then, if it's rather immediate, AL could be at fault if it was in the midst of an adaption sequence and missed HAs off event. If it's sometime later then IDK ¯_(ツ)_/¯
There are many factors to be considered.
I did have a default transition time of 1s in the ZHA settings, so I'll try with that set to zero. It would be good to confirm how to actually disable AL correctly in an automation to avoid having to do this.
I did have a default transition time of 1s in the ZHA settings, so I'll try with that set to zero. It would be good to confirm how to actually disable AL correctly in an automation to avoid having to do this.
When turning on/off lights in a room I use a script (called from automations). In these scripts I disable AL for that room using the method as below. Works well enough. Started doing this because sometimes lights turned back on.
- service: switch.turn_off
data: {}
target:
entity_id: switch.adaptive_lighting_badkamer
When turning on/off lights in a room I use a script (called from automations). In these scripts I disable AL for that room using the method as below. Works well enough. Started doing this because sometimes lights turned back on.
- service: switch.turn_off data: {} target: entity_id: switch.adaptive_lighting_badkamer
I did the same for a similar reason in my bathroom light script. My 6 old non-smart Feit LED bulbs controlled by Insteon 2477D dimmer switch need a minimum of 32% to turn on and then minimum 750ms to dim down to as low as 6% (any lower and they flicker again. When AL brightness is less than 32%, AL was immediately adjusting them and they flickered. I tried adapt_delay but it did not seem to work but that was before v1.16.3. Need to re-test...
I have this problem since all the new 0.16.x came out. I can not use AL anymore, as soon as it is enabled for a light I can not switch the light off anymore. It goes off and comes straight back on. Yes there is a small transition but I never had this problem before all the updates a few days ago.
It would be very helpful to have debugging logs. Otherwise, I really have nothing to go on unfortunately.
In the below log I did the following:
2023-07-26 08:37:50.842 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom Bed: Called 'async_turn_on', current state is 'False' 2023-07-26 08:37:50.842 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Cancelled ongoing brightness adaptation calls (<Task finished name='Task-11858' coro=<AdaptiveSwitch._execute_adaptation_calls() done, defined at /config/custom_components/adaptive_lighting/switch.py:1250> result=None>) for 'light.bedroom_bed' 2023-07-26 08:37:50.842 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom Bed: Called '_setup_listeners' 2023-07-26 08:37:50.842 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom Bed: '_update_attrs_and_maybe_adapt_lights' called with context.id='01H68EP3BT:al:IJSW:trn_:0D' lights: 'None', transition: '1.0', force: 'True' 2023-07-26 08:37:50.843 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom Bed: filtered_lights: '['light.bedroom_bed']' 2023-07-26 08:37:53.757 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Intercepted TURN_ON call with data {'entity_id': ['light.bedroom_bed'], 'params': {}} (01H68EP66WDSNXA55VNT9PS9FA) 2023-07-26 08:37:53.757 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Cancelled ongoing brightness adaptation calls (<Task finished name='Task-11858' coro=<AdaptiveSwitch._execute_adaptation_calls() done, defined at /config/custom_components/adaptive_lighting/switch.py:1250> result=None>) for 'light.bedroom_bed' 2023-07-26 08:37:53.760 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom Bed: Setting color_temp of light light.bedroom_bed 2023-07-26 08:37:53.760 DEBUG (MainThread) [custom_components.adaptive_lighting.adaptation_utils] Preparing adaptation data for light.bedroom_bed with service data {'entity_id': 'light.bedroom_bed', 'transition': 1.0, 'brightness': 255, 'color_temp_kelvin': 4325} 2023-07-26 08:37:53.761 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.bedroom_bed']')' event with context.id='01H68EP66WDSNXA55VNT9PS9FA' 2023-07-26 08:37:53.762 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Cancelled ongoing brightness adaptation calls (<Task finished name='Task-11858' coro=<AdaptiveSwitch._execute_adaptation_calls() done, defined at /config/custom_components/adaptive_lighting/switch.py:1250> result=None>) for 'light.bedroom_bed' 2023-07-26 08:37:53.763 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom Bed: execute_cancellable_adaptation_calls with data: AdaptationData(entity_id='light.bedroom_bed', context=<homeassistant.core.Context object at 0x7f382dbe3560>, sleep_time=1.0, service_call_datas=<async_generator object _create_service_call_data_iterator at 0x7f382efaf840>, max_length=1, which='both', initial_sleep=True) 2023-07-26 08:37:53.980 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.bedroom_bed' 'state_changed' event: '{'min_color_temp_kelvin': 2000, 'max_color_temp_kelvin': 6535, 'min_mireds': 153, 'max_mireds': 500, 'effect_list': ['None', 'candle', 'fire', 'unknown'], 'supported_color_modes': [<ColorMode.COLOR_TEMP: 'color_temp'>, <ColorMode.XY: 'xy'>], 'color_mode': <ColorMode.COLOR_TEMP: 'color_temp'>, 'brightness': 255, 'color_temp_kelvin': 3861, 'color_temp': 259, 'hs_color': (26.885, 37.447), 'rgb_color': (255, 202, 159), 'xy_color': (0.429, 0.368), 'effect': 'None', 'mode': 'normal', 'dynamics': 'none', 'friendly_name': 'Bedroom Bed', 'supported_features': <LightEntityFeature.EFFECT|FLASH|TRANSITION: 44>}' with context.id='01H68EP66WDSNXA55VNT9PS9FA' 2023-07-26 08:37:53.982 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.bedroom_bed' 'state_changed' event: '{'min_color_temp_kelvin': 2000, 'max_color_temp_kelvin': 6535, 'min_mireds': 153, 'max_mireds': 500, 'effect_list': ['None', 'candle', 'fire', 'unknown'], 'supported_color_modes': [<ColorMode.COLOR_TEMP: 'color_temp'>, <ColorMode.XY: 'xy'>], 'color_mode': <ColorMode.COLOR_TEMP: 'color_temp'>, 'brightness': 255, 'color_temp_kelvin': 4329, 'color_temp': 231, 'hs_color': (26.723, 29.217), 'rgb_color': (255, 213, 180), 'xy_color': (0.403, 0.359), 'effect': 'None', 'mode': 'normal', 'dynamics': 'none', 'friendly_name': 'Bedroom Bed', 'supported_features': <LightEntityFeature.EFFECT|FLASH|TRANSITION: 44>}' with context.id='01H68EP66WDSNXA55VNT9PS9FA' 2023-07-26 08:37:53.992 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom Bed: Detected an 'off' → 'on' event for 'light.bedroom_bed' with context.id='01H68EP66WDSNXA55VNT9PS9FA' 2023-07-26 08:37:53.993 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom Bed: '_update_attrs_and_maybe_adapt_lights' called with context.id='01H68EP6E9:al:IJSW:lght:0F' lights: '['light.bedroom_bed']', transition: '1.0', force: 'True' 2023-07-26 08:37:53.996 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom Bed: filtered_lights: '['light.bedroom_bed']' 2023-07-26 08:37:53.996 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom Bed: Calling _adapt_light from _update_attrs_and_maybe_adapt_lights: 'light.bedroom_bed' with transition 1.0 2023-07-26 08:37:53.996 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='True', context_id='01H68EP66WDSNXA55VNT9PS9FA' 2023-07-26 08:37:53.997 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom Bed: Skipping reactive adaptation of 01H68EP66WDSNXA55VNT9PS9FA 2023-07-26 08:37:55.873 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_off('['light.bedroom_bed']', transition=None)' event with context.id='01H68EP88Z8BP1R8R3B5AF6N4K' 2023-07-26 08:37:55.873 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Cancelled ongoing brightness adaptation calls (<Task finished name='Task-47838' coro=<AdaptiveSwitch._execute_adaptation_calls() done, defined at /config/custom_components/adaptive_lighting/switch.py:1250> result=None>) for 'light.bedroom_bed' 2023-07-26 08:37:55.994 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Cancelled ongoing brightness adaptation calls (<Task finished name='Task-47838' coro=<AdaptiveSwitch._execute_adaptation_calls() done, defined at /config/custom_components/adaptive_lighting/switch.py:1250> result=None>) for 'light.bedroom_bed' 2023-07-26 08:37:56.002 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Intercepted TURN_ON call with data {'entity_id': ['light.bedroom_bed'], 'params': {'brightness': 0}} (01H68EP8CRV5BYC3NYWAT9HXCH) 2023-07-26 08:37:56.002 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Cancelled ongoing brightness adaptation calls (<Task finished name='Task-47838' coro=<AdaptiveSwitch._execute_adaptation_calls() done, defined at /config/custom_components/adaptive_lighting/switch.py:1250> result=None>) for 'light.bedroom_bed' 2023-07-26 08:37:56.004 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom Bed: Setting color_temp of light light.bedroom_bed 2023-07-26 08:37:56.005 DEBUG (MainThread) [custom_components.adaptive_lighting.adaptation_utils] Preparing adaptation data for light.bedroom_bed with service data {'entity_id': 'light.bedroom_bed', 'transition': 1.0, 'brightness': 255, 'color_temp_kelvin': 4325} 2023-07-26 08:37:56.008 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.bedroom_bed']')' event with context.id='01H68EP8CRV5BYC3NYWAT9HXCH' 2023-07-26 08:37:56.008 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Cancelled ongoing brightness adaptation calls (<Task finished name='Task-47838' coro=<AdaptiveSwitch._execute_adaptation_calls() done, defined at /config/custom_components/adaptive_lighting/switch.py:1250> result=None>) for 'light.bedroom_bed' 2023-07-26 08:37:56.009 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom Bed: execute_cancellable_adaptation_calls with data: AdaptationData(entity_id='light.bedroom_bed', context=<homeassistant.core.Context object at 0x7f382cb32c50>, sleep_time=1.0, service_call_datas=<async_generator object _create_service_call_data_iterator at 0x7f382efaf940>, max_length=1, which='both', initial_sleep=True) 2023-07-26 08:37:56.999 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.bedroom_bed' 'state_changed' event: '{'min_color_temp_kelvin': 2000, 'max_color_temp_kelvin': 6535, 'min_mireds': 153, 'max_mireds': 500, 'effect_list': ['None', 'candle', 'fire', 'unknown'], 'supported_color_modes': [<ColorMode.COLOR_TEMP: 'color_temp'>, <ColorMode.XY: 'xy'>], 'color_mode': <ColorMode.COLOR_TEMP: 'color_temp'>, 'brightness': 255, 'color_temp_kelvin': 4329, 'color_temp': 231, 'hs_color': (26.723, 29.217), 'rgb_color': (255, 213, 180), 'xy_color': (0.403, 0.359), 'effect': 'None', 'mode': 'normal', 'dynamics': 'none', 'friendly_name': 'Bedroom Bed', 'supported_features': <LightEntityFeature.EFFECT|FLASH|TRANSITION: 44>}' with context.id='01H68EP8CRV5BYC3NYWAT9HXCH' 2023-07-26 08:37:57.002 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom Bed: Detected an 'off' → 'on' event for 'light.bedroom_bed' with context.id='01H68EP8CRV5BYC3NYWAT9HXCH' 2023-07-26 08:37:57.003 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='True', context_id='01H68EP8CRV5BYC3NYWAT9HXCH' 2023-07-26 08:37:57.003 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom Bed: '_update_attrs_and_maybe_adapt_lights' called with context.id='01H68EP9CB:al:IJSW:lght:0H' lights: '['light.bedroom_bed']', transition: '1.0', force: 'True' 2023-07-26 08:37:57.006 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom Bed: filtered_lights: '['light.bedroom_bed']' 2023-07-26 08:37:57.006 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom Bed: Calling _adapt_light from _update_attrs_and_maybe_adapt_lights: 'light.bedroom_bed' with transition 1.0 2023-07-26 08:37:57.006 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='True', context_id='01H68EP8CRV5BYC3NYWAT9HXCH' 2023-07-26 08:37:57.007 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom Bed: Skipping reactive adaptation of 01H68EP8CRV5BYC3NYWAT9HXCH 2023-07-26 08:38:04.211 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Cancelled ongoing brightness adaptation calls (<Task finished name='Task-47921' coro=<AdaptiveSwitch._execute_adaptation_calls() done, defined at /config/custom_components/adaptive_lighting/switch.py:1250> result=None>) for 'light.bedroom_bed' 2023-07-26 08:38:07.370 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_off('['light.bedroom_bed']', transition=None)' event with context.id='01H68EPKG8W9Q2Z7MJ3VG6A7RY' 2023-07-26 08:38:07.370 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Cancelled ongoing brightness adaptation calls (<Task finished name='Task-47921' coro=<AdaptiveSwitch._execute_adaptation_calls() done, defined at /config/custom_components/adaptive_lighting/switch.py:1250> result=None>) for 'light.bedroom_bed' 2023-07-26 08:38:07.465 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.bedroom_bed']')' event with context.id='01H68EPKK3CTJRK9653FZ94VR9'
OMG, I just had a realization and found the problem... Because AL did first in the beginning not a good job to switch the light in Nightmode without a brief flash of bright light I added an Automation that would Send a switch on with Brightness 0% to the lights after a switch off. This worked so far without issue but I guess something change in AL and it picks up on the "Turn on" even though it is 0% and will turn off the light. I can imagine that a few people have the same automation and like me totally forgot about it... I disabled the automation and lights work normally now. I will check how night mode will be tonight.
That's a great point @pattisonmichael!
We should detect whether someone is calling light.turn_on
with 0% brightness though.
I also had a major insight yesterday after @pattisonmichael shared his logs (https://github.com/basnijholt/adaptive-lighting/issues/622#issuecomment-1651070676).
I believe the issue of lights turning on is because for some reason: the light will incorrectly report its state as on!
Because AL then notices a state change, and this state is likely not precisely what it should be according to AL, it will adapt it to the correct state, inadvertently turning the lights on.
In this PR https://github.com/basnijholt/adaptive-lighting/pull/663, I have made some changes. With that code when detect_non_ha_changes: false
and there is a state change which is not the result of a light.turn_on
, it will mark the light as manually controlled and not adapt it at all.
Hi Bas, This seems important but I think only applies to a very small number of users as majority would not turn ON a light at 0% brightness. I think the bigger issue is with select platforms/lights when trying to use transition and most people don't get it. When you use a transition to off over 10/20/30 seconds, the light shows immediately as off in HA as HA has handed over the transition to the platform/light if it supports i. But some lights/platforms seem to report their intermediate state back to HA and HA will then show the light as on at xyz brightness thus triggering AL to resume adapting it which results in it turning back on.
I found a Node-Red flow for transition which reduces a light;s brightness gradually and was engineered to solve the case when lights cannot handle transition themsleves. It uses quite a bit of processing power but works. I think HA handles transition to off internally when light doen't support transition but it does not seem to wotk when transitioning from off to on at xyz brightness, at least with my Sengleds as they come on at full brightness.
There are just too many variables in this transition equation!
did not seem to work but that was before v1.16.3. Need to re-test...
I replaced the Insteon dimmer with a Zooz Z-Wave dimmer and the Feit bulbs with KGC LED Edison Globe Light Bulb (Neutral White) dimmable non-smart bulbs and with v1.17 everything is fine now. Minimum brightness and minimum turn on is much less now. I'm happy!
I think I added the automation because somebody suggested it as a fix on the forum for the light flashing and I think a lot of people followed that advice (because it solved the problem at the time) and like me completely forgot about it. It might be an edge case, I agree, but I think this is often used when your lights struggle to accept brightness & Color at the same time to ensure the lights come one with low brightness initially.
Hi folks!
I have merged https://github.com/basnijholt/adaptive-lighting/pull/663 and released v1.18.0. Set detect_non_ha_changes: false
for the switches that contain the lights that accidentally turn on.
I will close this issue and would really appreciate folks reporting back on whether the issue is fixed. ⚙️
Thanks everyone for your support and patience in getting this issue fixed! 🙌❤️
BTW if you have debugging logging enabled you'll see messages like these:
2023-07-28 12:40:00.233 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom: Ignoring 'off' → 'on' event for 'light.baby_room' with context.id='01H6F07PV5V2HD7W30083Y8RZS' because 'light.turn_on' was not called by HA and 'detect_non_ha_changes' is False
This would previously have turned on the light 💡
I've got a Zigbee group of 4 lights (2 hue, 2 Ikea), and have Adaptive Lighting enabled on the group. I'm using an automation to turn off the lights in the morning, however sometimes I find they turn back on soon after. The history shows the lights turning on, but there's never anything in the log book that shows what caused this, however I'm assuming it's the Adaptive Lighting.
I've tried adding to the automation to ensure they stay off, but it doesn't seem to be helping. I'm not sure if you can force manual control like this. Can someone suggest how to improve this?
`alias: Drive - Sunrise turn off description: "" trigger: