adaptive-lighting icon indicating copy to clipboard operation
adaptive-lighting copied to clipboard

adaptive_lighting.set_manual_control doesn't have the expected outcome

Open RichEsq opened this issue 4 years ago • 10 comments

I have a series of Philips Hue 4 button switches, and have traditionally used the "dim" button to set the lights to 1% brightness, no matter their current state. (eg if they're off, they turn on with 1% brightness).

This works fine with adaptive lighting if the lights are already on, but if the lights are off, the act of turning them on triggers adaptive lighting. I've tried working around this by setting "adaptive_lighting.set_manual_control" to "true" in my automation before calling the "dim" scene but it doesn't seem to work - the lights still come on at "full" brightness.

Example automation below.

- id: '1604357677300'
  alias: Kids Room Switch - Button 2 Hold
  description: ''
  trigger:
  - platform: event
    event_type: deconz_event
    event_data:
      id: kids_room_switch
      event: 2003
  condition: []
  action:
  - service: adaptive_lighting.set_manual_control
    data:
      manual_control: true
      lights: light.kids_room
    entity_id: switch.adaptive_lighting_home
  - scene: scene.kids_room_dim
  mode: single

RichEsq avatar Nov 03 '20 03:11 RichEsq

That sounds like a bug, could you perhaps turn on logging and share the logs after the problem occurs? See https://github.com/basnijholt/adaptive-lighting#having-problems

basnijholt avatar Nov 03 '20 09:11 basnijholt

Log attached. The bedroom lights are off, and the log starts when I press automation which turns on the "turn on at 1% brightness" scene (excerpted below). adaptive_lighting_log.txt

- id: 'BedroomDim'
  name: Bedroom Dim
  icon: mdi:lightbulb-off-outline
  entities:
    light.bedroom:
      brightness: 1
      state: 'on'
    light.sun_room:
      brightness: 1
      state: 'on'

RichEsq avatar Nov 03 '20 22:11 RichEsq

I have the exact same issue. Set up an automation to enable manual control of certain light on button press, manual control shows up as “working” when checking the switch, hover the lights keep getting adapted.

Edit: in fact, when changing the settings of adaptive_lighting, neither “take_over_control” or “detect_non_ha_changes” seems to stop lights from being adapted. The only setting that stops adaption is “only_once”

dieugab avatar Nov 06 '20 10:11 dieugab

FYI @RichEsq I’ve found a way around it for now by enabling/disabling the adaptive lighting switch of the corresponding room. Something like:

alias: 'Living Room: Tradfri Switch (Long Press)'
trigger:
  - platform: event
    event_type: deconz_event
    event_data:
      id: woonkamer_tradfri_remote_control
      event: 1001
action:
  - service: switch.turn_off
    data: {}
    entity_id: switch.adaptive_lighting_living_room

And then automatically enabling the switch back on whenever lights are turned off to re-enable adaptive lighting:

alias: 'Living Room: Reset Adaptive Lighting'
trigger:
  - platform: device
    type: turned_off
    device_id: 4c37fd7e0cb111eb826f5323cf794da0
    entity_id: light.woonkamer
    domain: light
action:
  - service: switch.turn_on
    data: {}
    entity_id: switch.adaptive_lighting_living_room

Not perfect (if you have multiple lights or rooms in a single adaptive lighting instance they’ll lose adaptive lighting as well), but usable (I’ve split them up per room) until the bug is fixed

dieugab avatar Nov 06 '20 13:11 dieugab

Issue persists in latest version (008c5e4), set_manual_control doesn’t seem to be doing anything.

dieugab avatar Dec 23 '20 11:12 dieugab

@gvssr, could you elaborate on that please?

In both my personal setup and in the tests the adaptive_lighting.set_manual_control seems to work just fine. Perhaps you are not using it correctly?

basnijholt avatar Dec 23 '20 11:12 basnijholt

@basnijholt Maybe I’m doing it wrong or having the wrong expectations. Example I just tried:

Setup 1 adaptive lighting integration, setup for 2 lights. only_once is not enabled, meaning they should continuingly adapt even after having been turned on. The interval for this is the default 90 seconds.

Steps I use the service adaptive_lighting.set_manual_control to set manual control for one of the lights. As follows:

service: adaptive_lighting.set_manual_control
entity_id: switch.adaptive_lighting_woonkamer
manual_control: true
lights: light.woonkamer_eettafel_lamp

I can see it succeeded when I open up the entity switch.adaptive_lighting_woonkamer, which notes manual control is set for light.woonkamer_eettafel_lamp. I change the brightness of that lamp using HA.

Expected behavior light.woonkamer_eettafel_lamp stays at the brightness I just set.

Actual behavior After 90 seconds light.woonkamer_eettafel_lamp gets adapted and returns to the integration’s brightness.

dieugab avatar Jan 11 '21 21:01 dieugab

I think this may be related, as it's also related to manual control - if I set a light to manual control while it is off, when it is turned on, it automatically gets called to adaptive lighting, even though it was already marked as manually controlled. This seems counterintuitive to the readme where it says:

This mechanism works by listening to all light.turn_on calls that change the color or brightness and by noting that the component did not make the call.

If an automation or scene is calling the light (especially if calling it with custom values), that would suggest that it is manually controlled, right?

There doesn't seem to be a good workaround for this in the case of the transition from a light being off to wanting it to go directly to a RGB color, for example.

regoras avatar Jan 30 '21 00:01 regoras

If it´s not a bug, my proposal from https://github.com/basnijholt/adaptive-lighting/issues/89#issuecomment-778624792:

I still vote for adaptive lightning detecting if lights are turned on with custom settings and setting manual mode for those lights automatically (as it does when changes are detected when lights are on). That would save a lot of headache and many lines of YAML code.

Currently I´m testing to apply the manual_control in my automation, for the moment it seems to work:

      - choose:
          - conditions:
              - condition: device
                type: is_off
                device_id: [removed]
                entity_id: light.light_bulb
                domain: light
            sequence:
              - service: adaptive_lighting.set_manual_control
                data:
                  manual_control: true
                  lights: light.light_bulb
                entity_id: switch.adaptive_lighting
              - service: light.turn_on
                data:
                  brightness_pct: 100
                  transition: 1
                entity_id: light.light_bulb
          - conditions:
              - condition: device
                type: is_on
                device_id: [removed]
                entity_id: light.light_bulb
                domain: light
            sequence:
              - type: turn_off
                device_id: [revmoved]
                entity_id: light.light_bulb
                domain: light
              - service: adaptive_lighting.set_manual_control
                data:
                  manual_control: false
                  lights: light.light_bulb
                entity_id: switch.adaptive_lighting

Use-Case is in https://github.com/basnijholt/adaptive-lighting/issues/89#issue-804881318.

bcutter avatar Feb 13 '21 15:02 bcutter

I'm currently in the process of doing version 2. This will be added/fixed.

Keep this ticket open until you can verify that it's properly working in the upcoming version 2.

RubenKelevra avatar Jan 08 '22 00:01 RubenKelevra

I've confirmed this is fixed in the current version.

th3w1zard1 avatar Apr 01 '23 05:04 th3w1zard1