basnijholt / adaptive-lighting

Adaptive Lighting custom component for Home Assistant
https://basnijholt.github.io/adaptive-lighting/
Apache License 2.0
1.78k stars 133 forks source link

adaptive_lighting.manual_control event not fired when making changes outside of Home Assistant #34

Closed MarvinSchenkel closed 2 years ago

MarvinSchenkel commented 3 years ago

Hi,

Not sure if this is a bug or a feature, but it seems that the adaptive_lighting.manual_control event is not fired whenever I make changes to my lights using my IKEA TRADFRI remote. I do expect this to happen, so I can turn off adaptive lights whenever I manually adjust my lights using a remote control.

I am using the following configuration:

name: bedroom
lights:
  - light.bedside_left
  - light.bedside_right
detect_non_ha_changes: true
interval: 5
basnijholt commented 3 years ago

From the docs

Whether to detect state changes and stop adapting lights, even not from light.turn_on. Needs take_over_control to be enabled.

MarvinSchenkel commented 3 years ago

Also from the docs take_over_control boolean (optional, default: true

I'll try to explicitly set this to true and see if it makes a difference, but I did expect this to be enabled by default.

basnijholt commented 3 years ago

Oh, a very good point. That is indeed the default. I am AFK now but will look into this when I get home.

basnijholt commented 3 years ago

Do you perhaps use ZHA? If so, you might need to wait until https://github.com/home-assistant/core/pull/42413 is merged.

basnijholt commented 3 years ago

Due to lights not always doing what you're telling them to do, lights only become marked as manually controlled whenever two update periods have happened (to make sure that the command isn't delayed or anything).

It should happen right here: https://github.com/basnijholt/adaptive-lighting/blob/17ac3951240a65e75e79a548b85d50d7319d9f9b/custom_components/adaptive_lighting/switch.py#L1327-L1334

MarvinSchenkel commented 3 years ago

I am not using ZHA. My tradfri lights are connected to home assistant via WiFi using the ikea hub. The remote just controls the lights and is not connected to home assistant. Even after changing the brightness from 0-100 in increments using just the remote, it's still not reporting a manual change in home assistent. I'd say this should pass the significant changes condition, so I don't see why it isn't.

basnijholt commented 3 years ago

Perhaps homeassistant.update_entity isn't implemented correctly for the IKEA hub.

How long does it take for the brightness changes to show up in Home Assistant after using the remote?

And could you use the homeassistant.update_entity service immediately after making a change with the remote and see if the light has the correct state?

MarvinSchenkel commented 3 years ago

The brightness changes show up nearly instantly if I open the app and change the brightness with my remote. I'm afk now, but I'll try manually calling update entity. Or can be assume it's been correctly implemented, as the changes show up in the mobile app?

milutt commented 3 years ago

Hi,

I am experiencing the same issue. I use Hue lights integrated to HA via Hue integration. Changes from HA activate manual_control, but changes from Hue app or remote are not picked up. I even tried executing homeassistant.update_entity right after change, does not help.

config:


- name: "Living Room"
  lights:
    - light.living_room
  min_brightness: 30
  take_over_control: true
  detect_non_ha_changes: true
basnijholt commented 3 years ago

Could either one share logs? See https://github.com/basnijholt/adaptive-lighting#having-problems

That is the only way I can find out what the problem is.

milutt commented 3 years ago

Here is my log. Scenario: turn on light (AL adjusted brightness) decrease brightness in Hue app (AL restored initial brightness) decrease brightness 2nd time in Hue app (AL restored initial brightness again) home-assistant.log

milutt commented 3 years ago

I found culprit in my environment. I have two AL switches, default and living_room. Both must have been applied to the same light entity, conflicting each other. After disabling default switch, everything works fine. Is there a way to list light entities that AL switch is controlling (including dynamically applied ones)?

basnijholt commented 3 years ago

@MarvinSchenkel, I have the suspicion that this issue has the same cause as https://github.com/basnijholt/adaptive-lighting/issues/39 which I have just fixed.

Could you perhaps try again and report whether the issue is solved?

RicardoCst commented 3 years ago

109640412-bd644f80-7b50-11eb-83d9-42cb73bc6151 I have the same issue, adaptive_lighting.manual_control doesnt fire I was listening using the dev tools and waited 90 seconds and I switched the light using a hue dimmer, I got nothing. im using 2x hue bulbs, im using it to turn off adaptive lighting whenever something changes. Manual control also has no variable in the switch.

EDIT: I can call manual control on the lights, but it doesnt seem to want to automagically do it if the state of the light changes. test

RicardoCst commented 3 years ago

It seems that using the hue dimmer the manual control event wont fire, and it will just reset to its adaptive light state.

basnijholt commented 3 years ago

It seems that using the hue dimmer the manual control event wont fire, and it will just reset to its adaptive light state.

Are you using a Philips Hue hub? Or via Deconz/ZHA?

RicardoCst commented 3 years ago

hue

RicardoCst commented 3 years ago

Seems to be similair to this issue:

54

RubenKelevra commented 3 years ago

@MarvinSchenkel Can you reconfirm this issue for HA 2021.7.4?

RubenKelevra commented 2 years ago

This went stale.