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

adaptive_lighting.set_manual_control doesn't have the expected outcome #37

Closed
RichEsq opened this issue Nov 3, 2020 · 11 comments
Closed
Assignees
Labels
Milestone

Comments

@RichEsq
Copy link

RichEsq commented Nov 3, 2020

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 RichEsq changed the title Unable to turn a light on without triggering adaptive lighting adaptive_lighting.set_manual_control doesn't have the expected outcome Nov 3, 2020
@basnijholt
Copy link
Owner

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

@RichEsq
Copy link
Author

RichEsq commented Nov 3, 2020

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'

@dieugab
Copy link
Contributor

dieugab commented Nov 6, 2020

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
Copy link
Contributor

dieugab commented Nov 6, 2020

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

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

dieugab commented Dec 23, 2020

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

@basnijholt
Copy link
Owner

@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?

@dieugab
Copy link
Contributor

dieugab commented Jan 11, 2021

@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.

@regoras
Copy link

regoras commented Jan 30, 2021

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.

@bcutter
Copy link

bcutter commented Feb 13, 2021

If it´s not a bug, my proposal from #89 (comment):

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 #89 (comment).

@RubenKelevra
Copy link
Collaborator

RubenKelevra commented Jan 8, 2022

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.

@th3w1zard1
Copy link
Collaborator

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

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

No branches or pull requests

7 participants