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

Only start adapting on light.turn_on when detect_non_ha_changes: false to prevent unwanted light turn ons #663

Merged
merged 36 commits into from
Jul 28, 2023

Conversation

basnijholt
Copy link
Owner

@basnijholt basnijholt commented Jul 26, 2023

Great news, there might be a solution to the 'lights turning on by itself'-issue! πŸŽ‰ πŸš€

I also had a major insight yesterday going through the code line-by-line.

I believe the issue of lights turning on is always because for some reason: the light will incorrectly report its state as on! (as mentioned by @th3w1zard1 above).

Because AL then notices a state change, and this state is likely not precisely what it should be according to AL, it will adapt it to the correct state, inadvertently turning the lights on.

In this PR, I have made some changes. With that code when detect_non_ha_changes: false and there is a 'off' β†’ 'on' state change which is not the result of a light.turn_on, it will mark the light as manually controlled and not adapt it at all.

I have one light at home which frequently turns on again after I turned it off, I will see whether this still happens with the changes. If not, I will merge and release a new version.

ref #10, #622, #85

@th3w1zard1
Copy link
Collaborator

I'm very lost here, but if it works, it works right? πŸ˜…

@basnijholt basnijholt changed the title Fixes in maybe_cancel_adjusting to possibly fix accidental turn on Only start adapting on light.turn_on when detect_non_ha_changes: false to prevent unwanted light turn ons Jul 28, 2023
@basnijholt basnijholt merged commit 89c90ad into main Jul 28, 2023
15 checks passed
@basnijholt basnijholt deleted the try-fixing-turn-on branch July 28, 2023 22:17
@janpf
Copy link

janpf commented Aug 8, 2023

Hi, thanks for your work :)
Quick question, does this possibly interfere with my setup?: I have a few lights behind a physical switch, which after turning on using the physical switch (non-home assistant) don't get automatically changed. This reads like this could be reason. Is there a way to make this setup work after this patch?

@basnijholt
Copy link
Owner Author

Unfortunately, the only workaround is detect_non_ha_changes: true because there is really no way to distinguish between HA:

  1. reporting a state change with state: on because you turned it on outside of HA
  2. reporting a state change with state: on which is the light reporting an incorrect state, which turns on the light (if detect_non_ha_changes: true)

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

Successfully merging this pull request may close these issues.

None yet

3 participants