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

1.18.2 manual control broken #690

Closed broyuken closed 1 year ago

broyuken commented 1 year ago

In 1.18.2 manual control is completely broken. If I set a light to blue, shut it off, wait a few seconds/minutes then turn it back on it will stay blue and be marked as manually controlled. I’m not sure what version broke it as there were about 15 changes in the past week but it used to work perfectly before then. The only way I can get my lights to adjust now is to call manually controlled false or turn the AL switch off and on again.

basnijholt commented 1 year ago

How do you set the lights to a color? In Home Assistant?

It works for me and also in all the tests.

In order to fix this I need to see some debugging logs.

broyuken commented 1 year ago

yes, in home assistant.

This looks like the relevant debug logs for a test I just did. Lights been off for a while, just turned it on via lovelace and it came on blue and was set to manually controlled.

2023-07-31 21:58:19.180 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Intercepted TURN_ON call with data {'entity_id': ['light.office_lamp_floor'], 'params': {}} (01H6QD2JSBV1NDRFY0DEZGCEBB)
2023-07-31 21:58:19.181 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Office Lamp: Setting color_temp of light light.office_lamp_floor
2023-07-31 21:58:19.182 DEBUG (MainThread) [custom_components.adaptive_lighting.adaptation_utils] Preparing adaptation data for light.office_lamp_floor with service data {'entity_id': 'light.office_lamp_floor', 'brightness': 111, 'color_temp_kelvin': 2000}
2023-07-31 21:58:19.183 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.office_lamp_floor']')' event with context.id='01H6QD2JSBV1NDRFY0DEZGCEBB'
2023-07-31 21:58:19.184 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Office Lamp: execute_cancellable_adaptation_calls with data: AdaptationData(entity_id='light.office_lamp_floor', context=<homeassistant.core.Context object at 0x7f530e9ddd00>, sleep_time=0.0, service_call_datas=<async_generator object _create_service_call_data_iterator at 0x7f52c3319c40>, max_length=1, which='both', initial_sleep=True)
2023-07-31 21:58:19.426 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.office_lamp_floor' 'state_changed' event: '{'min_color_temp_kelvin': 1501, 'max_color_temp_kelvin': 7042, 'min_mireds': 142, 'max_mireds': 666, 'supported_color_modes': ['color_temp', 'xy'], 'color_mode': 'xy', 'brightness': 212, 'hs_color': [239.02, 96.078], 'rgb_color': [10, 14, 255], 'xy_color': [0.135988, 0.040986], 'off_with_transition': False, 'off_brightness': None, 'friendly_name': 'Office floor lamp Light', 'supported_features': 40}' with context.id='01H6QD2K1062918SBSNTWWD8JA'
2023-07-31 21:58:19.431 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Office Lamp: Detected an 'off' → 'on' event for 'light.office_lamp_floor' with context.id='01H6QD2K1062918SBSNTWWD8JA'
2023-07-31 21:58:19.431 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01H6QD2K1062918SBSNTWWD8JA'
2023-07-31 21:58:19.431 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Office Lamp: Ignoring 'off' → 'on' event for 'light.office_lamp_floor' with context.id='01H6QD2K1062918SBSNTWWD8JA' because 'light.turn_on' was not called by HA and 'detect_non_ha_changes' is False
2023-07-31 21:58:19.431 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Marking 'light.office_lamp_floor' as manually controlled.
broyuken commented 1 year ago

You know, as soon as I posted this I realized what might be the problem. I have been testing a new zigbee stick and this light I have connected to another HA instance, and sent over to my main instance with the remote home assistant custom component. This could be causing the issue because even though it is a light.turn_on event sending it, it gets turned on by the other HA.

Is there a way to work around this or do I need to run another instance of AL on the secondary HA server?

basnijholt commented 1 year ago

You should turn on detect_non_ha_changes then.

broyuken commented 1 year ago

yep, I think that solves it then. thanks for the quick response!