Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Manually controlled not set when issuing multiple entity id's in same light.turn_on #39

Closed
Jopinder opened this issue Nov 6, 2020 · 9 comments

Comments

@Jopinder
Copy link

Jopinder commented Nov 6, 2020

I'm using Node-RED for most of my automation, and when issuing multiple entity ID's in the same service call the lights changes, but they are overridden by AL on the next interval.

Separating them into different service calls for each light makes AL pick up that they have been manually controlled.

This might be related to #10 if they are also issuing multiple entity id's in the same call?

Single service call
Single service call, manual control not triggered.txt

Multiple service call, manual control triggered.txt

@Jopinder Jopinder changed the title [BUG] Manually controlled not set when issuing multiple entity id's in same light.turn_on [Bug] Manually controlled not set when issuing multiple entity id's in same light.turn_on Nov 6, 2020
@basnijholt
Copy link
Owner

I can confirm that this is a bug! I will attempt to fix it ASAP.

@basnijholt basnijholt self-assigned this Nov 23, 2020
@basnijholt
Copy link
Owner

Actually, scratch my previous comment, I simply didn't wait long enough.

What I did:
image

and then I saw

image

Or did you do something different?

@basnijholt basnijholt removed their assignment Nov 23, 2020
@Jopinder
Copy link
Author

Jopinder commented Nov 23, 2020

Using Node-RED and a single service call to light.turn_on changes both light.couch_right and light.window_left, but AL only picks up that light.couch_right should be manually controlled.

2020-11-23 16:04:04 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.window_left' 'state_changed' event: '{'brightness': 128, 'is_deconz_group': False, 'friendly_name': 'Window_Left', 'supported_features': 41}' with context.id='49f42743fa4379c73cb8c06b04929201'
2020-11-23 16:04:04 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.couch_right' 'state_changed' event: '{'min_mireds': 140, 'max_mireds': 650, 'brightness': 128, 'color_temp': 400, 'is_deconz_group': False, 'friendly_name': 'Couch_Right', 'supported_features': 43}' with context.id='49f42743fa4379c73cb8c06b04929201'
2020-11-23 16:04:04 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.couch_right']')' event with context.id='d2d8ddc213c9c846fcfdb90b3ff0f0c6'
2020-11-23 16:04:05 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.window_left' 'state_changed' event: '{'brightness': 246, 'is_deconz_group': False, 'friendly_name': 'Window_Left', 'supported_features': 41}' with context.id='49f42743fa4379c73cb8c06b04929201'
2020-11-23 16:04:10 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.window_left' 'state_changed' event: '{'brightness': 128, 'is_deconz_group': False, 'friendly_name': 'Window_Left', 'supported_features': 41}' with context.id='d13875f57fce7e1ed7f7eaabe4a6ad71'
2020-11-23 16:04:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Hallway: '_update_attrs_and_maybe_adapt_lights' called with context.id='adapt_lgt_4699_interval_10'
2020-11-23 16:04:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Adaptive Lighting: Hallway: '_adapt_lights(['light.color_temperature_light_2'], None, force=False, context.id=adapt_lgt_4699_interval_10)' called
2020-11-23 16:04:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Hallway: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.color_temperature_light_2', 'transition': 30.0, 'brightness': 248, 'color_temp': 400} with context.id='adapt_lgt_4699_interval_10'
2020-11-23 16:04:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: '_update_attrs_and_maybe_adapt_lights' called with context.id='adapt_lgt_25ff_interval_13'
2020-11-23 16:04:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Adaptive Lighting: Living room: '_adapt_lights(['light.window_right', 'light.couch_right', 'light.window_left', 'light.window_middle', 'light.couch_left'], None, force=False, context.id=adapt_lgt_25ff_interval_13)' called
2020-11-23 16:04:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.window_right', 'transition': 30.0, 'brightness': 248} with context.id='adapt_lgt_25ff_interval_13'
2020-11-23 16:04:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] 'light.couch_right' was already on and 'light.turn_on' was not called by the adaptive_lighting integration (context.id='d2d8ddc213c9c846fcfdb90b3ff0f0c6'), the Adaptive Lighting will stop adapting the light until the switch or the light turns off and then on again.
2020-11-23 16:04:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: 'light.couch_right' is being manually controlled, stop adapting, context.id=adapt_lgt_25ff_interval_13.
2020-11-23 16:04:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.window_left', 'transition': 30.0, 'brightness': 248} with context.id='adapt_lgt_25ff_interval_13'
2020-11-23 16:04:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.window_middle', 'transition': 30.0, 'brightness': 248} with context.id='adapt_lgt_25ff_interval_13'
2020-11-23 16:04:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.couch_left', 'transition': 30.0, 'brightness': 248, 'color_temp': 400} with context.id='adapt_lgt_25ff_interval_13'
2020-11-23 16:04:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Kitchen: '_update_attrs_and_maybe_adapt_lights' called with context.id='adapt_lgt_0186_interval_10'
2020-11-23 16:04:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Adaptive Lighting: Kitchen: '_adapt_lights(['light.kitchen_sink', 'light.kitchen_stove'], None, force=False, context.id=adapt_lgt_0186_interval_10)' called
2020-11-23 16:04:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.color_temperature_light_2']')' event with context.id='adapt_lgt_4699_interval_10'
2020-11-23 16:04:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.window_right']')' event with context.id='adapt_lgt_25ff_interval_13'
2020-11-23 16:04:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.window_left']')' event with context.id='adapt_lgt_25ff_interval_13'
2020-11-23 16:04:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.window_middle']')' event with context.id='adapt_lgt_25ff_interval_13'
2020-11-23 16:04:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.couch_left']')' event with context.id='adapt_lgt_25ff_interval_13'
2020-11-23 16:04:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.window_left' 'state_changed' event: '{'brightness': 248, 'is_deconz_group': False, 'friendly_name': 'Window_Left', 'supported_features': 41}' with context.id='adapt_lgt_25ff_interval_13'
2020-11-23 16:04:52 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.window_left' 'state_changed' event: '{'brightness': 129, 'is_deconz_group': False, 'friendly_name': 'Window_Left', 'supported_features': 41}' with context.id='adapt_lgt_25ff_interval_13'
2020-11-23 16:04:52 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] State change event of 'light.window_left' is already in 'self.last_state_change' (adapt_lgt_25ff_interval_13) adding this state also
2020-11-23 16:04:57 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.window_left' 'state_changed' event: '{'brightness': 149, 'is_deconz_group': False, 'friendly_name': 'Window_Left', 'supported_features': 41}' with context.id='ca3f6d063c6e518025f46221c74d1b88'
2020-11-23 16:05:02 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.window_left' 'state_changed' event: '{'brightness': 169, 'is_deconz_group': False, 'friendly_name': 'Window_Left', 'supported_features': 41}' with context.id='6a898bcfcda8d8c97bc7cd32fac14b8b'
2020-11-23 16:05:04 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.couch_right']')' event with context.id='f286f4dc3024285beb4bb6269aefef9b'
2020-11-23 16:05:07 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.window_left' 'state_changed' event: '{'brightness': 189, 'is_deconz_group': False, 'friendly_name': 'Window_Left', 'supported_features': 41}' with context.id='ddbf2c6feafbeaf4323da5440befdbfe'
2020-11-23 16:05:12 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.window_left' 'state_changed' event: '{'brightness': 209, 'is_deconz_group': False, 'friendly_name': 'Window_Left', 'supported_features': 41}' with context.id='a6f0329fdeb66e453f41b249d15419f0'
2020-11-23 16:05:17 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.window_left' 'state_changed' event: '{'brightness': 229, 'is_deconz_group': False, 'friendly_name': 'Window_Left', 'supported_features': 41}' with context.id='caab251017e59d52a6992a092e603ef9'
2020-11-23 16:05:22 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.window_left' 'state_changed' event: '{'brightness': 248, 'is_deconz_group': False, 'friendly_name': 'Window_Left', 'supported_features': 41}' with context.id='2dcc0f0066a29ac5ae61953d850e2c28'


Hendelse 0 utført 16:04:

{
    "event_type": "adaptive_lighting.manual_control",
    "data": {
        "entity_id": "light.couch_right"
    },
    "origin": "LOCAL",
    "time_fired": "2020-11-23T15:04:51.655928+00:00",
    "context": {
        "id": "d2d8ddc213c9c846fcfdb90b3ff0f0c6",
        "parent_id": null,
        "user_id": "41c6af49c1da474c9d3cb3c319b94abb"
    }
}

If I recreate a single service call with HA developer tools I'm unable to recreate your results, as AL doesn't pick up any of the events as manually controlled...

image

2020-11-23 16:07:18 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.window_left' 'state_changed' event: '{'brightness': 128, 'is_deconz_group': False, 'friendly_name': 'Window_Left', 'supported_features': 41}' with context.id='623c986e878bca0e712618f4e40b658f'
2020-11-23 16:07:18 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.couch_right' 'state_changed' event: '{'min_mireds': 140, 'max_mireds': 650, 'brightness': 128, 'color_temp': 400, 'is_deconz_group': False, 'friendly_name': 'Couch_Right', 'supported_features': 43}' with context.id='623c986e878bca0e712618f4e40b658f'
2020-11-23 16:07:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Hallway: '_update_attrs_and_maybe_adapt_lights' called with context.id='adapt_lgt_4699_interval_13'
2020-11-23 16:07:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Adaptive Lighting: Hallway: '_adapt_lights(['light.color_temperature_light_2'], None, force=False, context.id=adapt_lgt_4699_interval_13)' called
2020-11-23 16:07:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Hallway: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.color_temperature_light_2', 'transition': 30.0, 'brightness': 247, 'color_temp': 400} with context.id='adapt_lgt_4699_interval_13'
2020-11-23 16:07:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: '_update_attrs_and_maybe_adapt_lights' called with context.id='adapt_lgt_25ff_interval_17'
2020-11-23 16:07:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Adaptive Lighting: Living room: '_adapt_lights(['light.window_right', 'light.couch_right', 'light.window_left', 'light.window_middle', 'light.couch_left'], None, force=False, context.id=adapt_lgt_25ff_interval_17)' called
2020-11-23 16:07:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.window_right', 'transition': 30.0, 'brightness': 247} with context.id='adapt_lgt_25ff_interval_17'
2020-11-23 16:07:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.couch_right', 'transition': 30.0, 'brightness': 247, 'color_temp': 400} with context.id='adapt_lgt_25ff_interval_17'
2020-11-23 16:07:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.window_left', 'transition': 30.0, 'brightness': 247} with context.id='adapt_lgt_25ff_interval_17'
2020-11-23 16:07:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.window_middle', 'transition': 30.0, 'brightness': 247} with context.id='adapt_lgt_25ff_interval_17'
2020-11-23 16:07:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.couch_left', 'transition': 30.0, 'brightness': 247, 'color_temp': 400} with context.id='adapt_lgt_25ff_interval_17'
2020-11-23 16:07:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Kitchen: '_update_attrs_and_maybe_adapt_lights' called with context.id='adapt_lgt_0186_interval_13'
2020-11-23 16:07:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Adaptive Lighting: Kitchen: '_adapt_lights(['light.kitchen_sink', 'light.kitchen_stove'], None, force=False, context.id=adapt_lgt_0186_interval_13)' called
2020-11-23 16:07:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.color_temperature_light_2']')' event with context.id='adapt_lgt_4699_interval_13'
2020-11-23 16:07:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.window_right']')' event with context.id='adapt_lgt_25ff_interval_17'
2020-11-23 16:07:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.couch_right']')' event with context.id='adapt_lgt_25ff_interval_17'
2020-11-23 16:07:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.window_left']')' event with context.id='adapt_lgt_25ff_interval_17'
2020-11-23 16:07:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.window_middle']')' event with context.id='adapt_lgt_25ff_interval_17'
2020-11-23 16:07:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.couch_left']')' event with context.id='adapt_lgt_25ff_interval_17'
2020-11-23 16:07:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.couch_right' 'state_changed' event: '{'min_mireds': 140, 'max_mireds': 650, 'brightness': 247, 'color_temp': 400, 'is_deconz_group': False, 'friendly_name': 'Couch_Right', 'supported_features': 43}' with context.id='adapt_lgt_25ff_interval_17'
2020-11-23 16:07:51 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.window_left' 'state_changed' event: '{'brightness': 247, 'is_deconz_group': False, 'friendly_name': 'Window_Left', 'supported_features': 41}' with context.id='adapt_lgt_25ff_interval_17'
2020-11-23 16:07:52 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.window_left' 'state_changed' event: '{'brightness': 129, 'is_deconz_group': False, 'friendly_name': 'Window_Left', 'supported_features': 41}' with context.id='adapt_lgt_25ff_interval_17'
2020-11-23 16:07:52 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] State change event of 'light.window_left' is already in 'self.last_state_change' (adapt_lgt_25ff_interval_17) adding this state also
2020-11-23 16:07:57 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.window_left' 'state_changed' event: '{'brightness': 149, 'is_deconz_group': False, 'friendly_name': 'Window_Left', 'supported_features': 41}' with context.id='9036b6a487b8a4ed00e65a533076ac5a'
2020-11-23 16:08:02 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.window_left' 'state_changed' event: '{'brightness': 168, 'is_deconz_group': False, 'friendly_name': 'Window_Left', 'supported_features': 41}' with context.id='71d3fd8fae5bbaf053519e53dfdc2227'
2020-11-23 16:08:07 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.window_left' 'state_changed' event: '{'brightness': 188, 'is_deconz_group': False, 'friendly_name': 'Window_Left', 'supported_features': 41}' with context.id='07d94a7428592e9eb92064028bbe7460'
2020-11-23 16:08:12 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.window_left' 'state_changed' event: '{'brightness': 208, 'is_deconz_group': False, 'friendly_name': 'Window_Left', 'supported_features': 41}' with context.id='6a246a3c967bd274a80fcdf5a18a25df'
2020-11-23 16:08:17 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.window_left' 'state_changed' event: '{'brightness': 228, 'is_deconz_group': False, 'friendly_name': 'Window_Left', 'supported_features': 41}' with context.id='560633e8575127746f7456282b4d68c1'
2020-11-23 16:08:22 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.window_left' 'state_changed' event: '{'brightness': 247, 'is_deconz_group': False, 'friendly_name': 'Window_Left', 'supported_features': 41}' with context.id='00cbc93f643dcbd52745bc1a4a7a4e8c'

@basnijholt
Copy link
Owner

I have pushed some small updates regarding the manual_control event.

It should also be logged when an event is fired now.

I can still not reproduce the problem you are seeing though... Could you check again after updating?

@Jopinder
Copy link
Author

Jopinder commented Dec 19, 2020

Unfortunately it's still the same, also after switching from deCONZ to ZHA just to be sure :/

Multiple lights in the same service-call:

2020-12-19 15:33:54 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.livingroom_window_left' 'state_changed' event: '{'brightness': 128, 'off_brightness': None, 'friendly_name': 'Vindu venstre', 'supported_features': 41}' with context.id='9df19d713ff2efbb07adce97692d1a8b'
2020-12-19 15:33:54 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.livingroom_couch_right' 'state_changed' event: '{'min_mireds': 250, 'max_mireds': 454, 'brightness': 128, 'color_temp': 400, 'off_brightness': None, 'friendly_name': 'Sofa høyre', 'supported_features': 43}' with context.id='9df19d713ff2efbb07adce97692d1a8b'
2020-12-19 15:34:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: '_update_attrs_and_maybe_adapt_lights' called with context.id='adapt_lgt_25ff_interval_7'
2020-12-19 15:34:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Adaptive Lighting: Living room: '_adapt_lights(['light.livingroom_window_middle', 'light.livingroom_couch_left', 'light.livingroom_window_left', 'light.livingroom_couch_right', 'light.livingroom_window_right'], None, force=False, context.id=adapt_lgt_25ff_interval_7)' called
2020-12-19 15:34:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.livingroom_window_middle', 'transition': 30.0, 'brightness': 251} with context.id='adapt_lgt_25ff_interval_7'
2020-12-19 15:34:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.livingroom_couch_left', 'transition': 30.0, 'brightness': 251, 'color_temp': 400} with context.id='adapt_lgt_25ff_interval_7'
2020-12-19 15:34:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.livingroom_window_left', 'transition': 30.0, 'brightness': 251} with context.id='adapt_lgt_25ff_interval_7'
2020-12-19 15:34:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.livingroom_couch_right', 'transition': 30.0, 'brightness': 251, 'color_temp': 400} with context.id='adapt_lgt_25ff_interval_7'
2020-12-19 15:34:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.livingroom_window_right', 'transition': 30.0, 'brightness': 251} with context.id='adapt_lgt_25ff_interval_7'
2020-12-19 15:34:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.livingroom_window_middle']')' event with context.id='adapt_lgt_25ff_interval_7'
2020-12-19 15:34:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.livingroom_couch_left']')' event with context.id='adapt_lgt_25ff_interval_7'
2020-12-19 15:34:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.livingroom_window_left']')' event with context.id='adapt_lgt_25ff_interval_7'
2020-12-19 15:34:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.livingroom_couch_right']')' event with context.id='adapt_lgt_25ff_interval_7'
2020-12-19 15:34:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.livingroom_window_right']')' event with context.id='adapt_lgt_25ff_interval_7'
2020-12-19 15:34:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.livingroom_window_middle' 'state_changed' event: '{'brightness': 251, 'off_brightness': None, 'friendly_name': 'Vindu midten', 'supported_features': 41}' with context.id='adapt_lgt_25ff_interval_7'

One service call for each light:

2020-12-19 15:35:40 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.livingroom_window_left']')' event with context.id='4b2eb89b1f8cdd22ff8d7c710c569d59'
2020-12-19 15:35:40 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.livingroom_window_left' 'state_changed' event: '{'brightness': 128, 'off_brightness': None, 'friendly_name': 'Vindu venstre', 'supported_features': 41}' with context.id='4b2eb89b1f8cdd22ff8d7c710c569d59'
2020-12-19 15:35:40 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.livingroom_couch_right']')' event with context.id='9d5a241d19a19bfafebf2aef00620a21'
2020-12-19 15:36:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: '_update_attrs_and_maybe_adapt_lights' called with context.id='adapt_lgt_25ff_interval_9'
2020-12-19 15:36:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Adaptive Lighting: Living room: '_adapt_lights(['light.livingroom_window_middle', 'light.livingroom_couch_left', 'light.livingroom_window_left', 'light.livingroom_couch_right', 'light.livingroom_window_right'], None, force=False, context.id=adapt_lgt_25ff_interval_9)' called
2020-12-19 15:36:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.livingroom_window_middle', 'transition': 30.0, 'brightness': 250} with context.id='adapt_lgt_25ff_interval_9'
2020-12-19 15:36:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.livingroom_couch_left', 'transition': 30.0, 'brightness': 250, 'color_temp': 400} with context.id='adapt_lgt_25ff_interval_9'
2020-12-19 15:36:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] 'adaptive_lighting.manual_control' event fired for switch.adaptive_lighting_living_room for light light.livingroom_window_left
2020-12-19 15:36:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] 'light.livingroom_window_left' was already on and 'light.turn_on' was not called by the adaptive_lighting integration (context.id='4b2eb89b1f8cdd22ff8d7c710c569d59'), the Adaptive Lighting will stop adapting the light until the switch or the light turns off and then on again.
2020-12-19 15:36:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: 'light.livingroom_window_left' is being manually controlled, stop adapting, context.id=adapt_lgt_25ff_interval_9.
2020-12-19 15:36:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] 'adaptive_lighting.manual_control' event fired for switch.adaptive_lighting_living_room for light light.livingroom_couch_right
2020-12-19 15:36:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] 'light.livingroom_couch_right' was already on and 'light.turn_on' was not called by the adaptive_lighting integration (context.id='9d5a241d19a19bfafebf2aef00620a21'), the Adaptive Lighting will stop adapting the light until the switch or the light turns off and then on again.
2020-12-19 15:36:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: 'light.livingroom_couch_right' is being manually controlled, stop adapting, context.id=adapt_lgt_25ff_interval_9.
2020-12-19 15:36:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living room: Scheduling 'light.turn_on' with the following 'service_data': {'entity_id': 'light.livingroom_window_right', 'transition': 30.0, 'brightness': 250} with context.id='adapt_lgt_25ff_interval_9'
2020-12-19 15:36:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.livingroom_window_middle']')' event with context.id='adapt_lgt_25ff_interval_9'
2020-12-19 15:36:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.livingroom_couch_left']')' event with context.id='adapt_lgt_25ff_interval_9'
2020-12-19 15:36:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_on('['light.livingroom_window_right']')' event with context.id='adapt_lgt_25ff_interval_9'
2020-12-19 15:36:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.livingroom_window_right' 'state_changed' event: '{'brightness': 250, 'off_brightness': None, 'friendly_name': 'Vindu høyre', 'supported_features': 41}' with context.id='adapt_lgt_25ff_interval_9'
2020-12-19 15:36:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.livingroom_window_middle' 'state_changed' event: '{'brightness': 250, 'off_brightness': None, 'friendly_name': 'Vindu midten', 'supported_features': 41}' with context.id='adapt_lgt_25ff_interval_9'
2020-12-19 15:36:26 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.livingroom_couch_left' 'state_changed' event: '{'min_mireds': 250, 'max_mireds': 454, 'brightness': 250, 'color_temp': 400, 'off_brightness': None, 'friendly_name': 'Sofa venstre', 'supported_features': 43}' with context.id='adapt_lgt_25ff_interval_9'

But as mentioned earlier, this is via Node Red. I will try to recreate the automation in HA during the holidays and see if it has the same behavior.

@basnijholt
Copy link
Owner

OK, I think I am closer to finding a solution. It seems like that when you call light.turn_on with multiple lights, my code doesn't detect the light.turn_on call event but only picks up the state_changed event.

Perhaps I couldn't reproduce it at first because you don't have the detect_non_ha_changes option enabled? (side effect of this bug is that it will see this change as a non-HA change.)

@basnijholt
Copy link
Owner

I now understand why that light.turn_on call event isn't properly detected. It is because the event_data is {'entity_id': 'light.philips_go, light.bamboo', 'brightness_pct': 50}. Where I expected the entity_id to be a list, not a comma separated string.

basnijholt added a commit that referenced this issue Dec 19, 2020
basnijholt added a commit to basnijholt/home-assistant that referenced this issue Dec 19, 2020
@basnijholt
Copy link
Owner

I am pretty sure I have fixed this bug in 4257d27.

I am closing this now. Please let me know if it works for you (or not).

@Jopinder
Copy link
Author

That update did the job 😀 Both lights are now detected as manually controlled when issued in the same service call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants