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
Lights randomly come back on after shut off #10
Comments
Would it be possible to enable debugging logging with:
and post the log after it occurred? I have a suspicion as to why it is happening but not sure. |
I just enabled debugging to see if it happens again. It just happened again on the latest version before I turned on debugging. I believe the only lights I have seen this occur on are Sengled Zigbee bulbs. Hopefully I can catch the full debug going forward. |
OK great! I already anticipated that this might happen, you can see my comment in the code here adaptive-lighting/custom_components/adaptive_lighting/switch.py Lines 1328 to 1333 in 466c4b6
|
This has happened a bunch of times since I last posted but unfortunately I messed up my Zha yesterday and had to turn off the debug to fix it. I’ll try to get it going again now that things seem to be stable |
I caught one this evening in my sons room. Turned off the light via home assistant and it turned back on a few seconds later.
|
Any ideas? |
I see that this happened:
This is not really a bug of AL, but rather that the light reports that it's on, while it is actually off. Still there might be something that we can do. Maybe I can ignore any |
that could be, my zigbee network has been a little flakey lately. Unfortunately most of my zigbee devices are sengled bulbs which are only endpoint devices, not routers. Working on trying to rectify that. |
I'm sure I'm not the only one with a less than 100% stable zigbee network, so if there is some way to ignore those events then it would probably be for the best. Especially if it was an optional configuration. |
I switched to ZHA and I am now seeing these problems too. Unfortunately, it doesn't seem like there is a lot to do. I will probably switch back to deCONZ... :'( My issue is reported here zigpy/zigpy-deconz#140. |
I will watch that thread but I may need to pick up a new zigbee stick. What are you using with deconz? |
I have all my devices listed here https://github.com/basnijholt/home-assistant-config/#my-devices |
I started with Conbee II & deCONZ in HomeSeer (before I started HA) but had random turn-on's with Eria but initially only in Bedroom Lamp 2. I returned that bulb and then the Eria in Bedroom Lamp 1 randomly turned on a couple of times so I sent it back to Amazon also. I replaced them with Sengled and no more hiccups. Then I switched to HA using ZHA with Conbee II (no hiccups) but recently replaced Conbee II with CC2652 Stick which has an external antenna attached to the dongle and it has better range. The Sengled's are in bedroom but I have Osram Lightify in office and currently do not have any random turn-ons. I might try the Eria again now that my platform and controller have changed. |
I'm having this same issue. It started after I installed adaptive lighting. My Sengled bulbs will get turned off by an automation and then just turn back on for no reason. It seems to only happen at night when adaptive lighting is running. |
@profesaurus, could you please add your logs (see https://github.com/basnijholt/adaptive-lighting#having-problems)? |
Is the 'off automation' an automation in HA? ...and include your logs as requested by @basnijholt ! |
@basnijholt I have adjusted HA to log debug outputs from AL. If/when it happens again I'll post here with the logs. The automation is an automation in HA. This is the only action in the automation: Here's the logbook entry for when the automation turned the lights off, but then back on: The top log is interesting because the lights are turned on by the action above....which is a light.turn_off service??? Also, that automation is only triggered once at the time the lights initially turn off: The history does show the lights turning off, then back on: I did find a post on the HA forums about an issue with zha light groups and Circadian Lighting and AL. I am using zha light groups, so as a test, in AL's settings I unchecked the light groups and checked the individual lights within the groups. I don't know if this will fix it or if I'll need to try the recommended automation in the post. Let me know if you have any other questions, I'm happy to help. |
@basnijholt & @danielbrunt57, I've got some logs for you. I have two AL setups. As I mentioned in my previous message, in my main AL setup I unchecked the ZHA groups from the settings and checked the individual lights. I haven't seen any issues with this one since doing that. <---- EDIT: This is not true, check my next post. But I have another AL setup where I left the ZHA light groups in the settings and that one just had an issue with lights turning on after being turned off. In the settings the light.kids_bathroom_lights is the group I'm referring to: I manually turned this group off in HA and they almost immediately came back on: These lights have no automations attached to them, so there's nothing I did in HA that could be turning these lights on. Here are the relevant logs:
Please let me know if you need any further info. I'm happy to help. |
I posted too soon. Looking through my logbook I discovered that my main AL setup had another issue today. And again, these issues only occur when AL is activated in the evening, so I'm pretty confident AL is playing some role in this. I had an automation turn off a ZHA group, light.master_closet_lights, then about 20 seconds later 2 of the 3 lights in the group (light.master_closet_1 & light.master_closet_3) turned on. These lights are in the same light fixture, so it's not like two can be manually switched on without the others. Here are the logbook entries: And the logs:
|
I can also confirm that with my Osram Zigbee lamp |
I did some testing and it looks like the problem is as suggested by @basnijholt: The states of ZHA devices are a bit unreliable. If a device is seen as on in HA, adaptive light tries to adjust its brightness/temperature according to your settings. Unfortunately lights turn on, on brightness change. This seems to be an expected behavior in HA itself. @basnijholt i think it would be reasonable to add a flag |
I can confirm the same behavior with Philips and Ikea lights on a Conbee2 stick with Deconz. More then with the original circadian lighting component. Think it relates to the combination of Deconz groups, single light bulbs and HA light groups. Will make that more sophisticated on my side but would like to share my initial thought... |
Has anyone been able to figure out what is happening here? I have two Sengled bulbs which seem to be doing something similar to this... where they sometimes come on randomly, but only at night. It started with one of my bulbs, and has been happening off and on (sometimes doesn't happen at all, sometimes happens many times in a night) for a few months. It just started last night with the second bulb. Both bulbs are bound directly to one Lutron Aurora each, and none of my Zigbee devices are part of any group (HA or Zigbee). I use ZHA with an HZUSBZ-1 stick. |
I did my checkings and refactored it entirely... Using groups or not using them doesn't differ. I do have one positive thing here... it happens quite a lot and most of the time when shutting down several entities. I will raise loglevels to give some valuable input later on. |
I seem to have been able to fix it. I think the problem comes in if a light is transitioning while it is shut off, the transition continues which turns the light back on. I fixed this by setting the transition to 1 second. Haven’t had the issue since. |
Trying this right now. Additionally, I created an automation that fires a |
Following up with some newfound additional research on this issue. I realize now that most users who have this problem probably have adaptive-lighting as their only automation involving lights. At the very least, adaptive-lighting modify's lights more than any other automation inside of HASSIO. (see #427) Please allow me just a moment to explain this happening in a scenario where adaptive-lighting isn't involved: Setup: user has Zigbee lightbulbs in their bedroom connected to a LAN server running HASSIO and a zigbee mesh running the addon 'zigbee2mqtt'. No automations are running.
Here's two problematic possibilities:
These are common scenarios Zigbee light users have to deal with on initial setup. Usually, all the user needs to do is set 'power_on_state' to 'off' in the bulb itself, or fix their MQTT retention settings. If you're still reading: I thank you for sticking around this far. Let me now explain how this relates to adaptive-lighting and this issue thread #10. With adaptive-lighting, the dev in his infinite wisdom implemented a very nice and surprisingly simple 'detect_non_ha_changes' feature. It definitely runs correctly in all the tests on my end. We're all very grateful. And finally my main point. I can think of two possible causes to issue #10: 1. Update_entity causes zigbee2mqtt to ping the bulb. With 'power_on_state: last_known' setup in its device settings AND improper retain options from the switch available on the MQTT broker, zigbee2mqtt would tell the bulb to turn on like it believes it's supposed to be.2. update_entity doesn't actually grab a state report from the bulb, just the data from zigbee2mqtt available in the broker, causing adaptive-lighting to use unreliable information to do its check for a significant change.The snippet below from switch.py is only called when detect_non_ha_changes is set to true.
Scenario 1 would already have its light on right after the update_entity call. In scenario 2, old_state could have brightness at 255 and new_state according to zigbee2mqtt could be 255. The bulb hasn't even been pinged despite the update_entity call! The fix in scenario 2 would be to set bulb reporting to 'on', turn off retain in its device settings, and ensure zigbee2mqtt is actually pinging the bulb directly for its current state everytime. Yes I'm talking about zigbee2mqtt which I'm using and many of you might not be, but I think this can happen with any system sending messages through MQTT. Tasmota comes to mind as using MQTT as well. Again, please see the video Thank you for sticking around to the end! TL;DR see #447 |
see #486 |
This isn’t fully solved, one of my lights randomly turned on at 6am this morning. The logs just show that it was turned on, not called by anything. |
If you can post logs showing adaptive lighting fired the light.turn_on command I'll happily reopen this issue and get a priority status on this issue for the next release. |
That’s the problem, light.turn_on isn’t called. It just says the light was turned on. |
There's only two situations where adaptive lighting does anything to a light entity specifically:
If you're not getting the log message then only three possibilities remain, ordered most to least likely:
if See #506 to ensure you have the proper config options set for your lights for use with this integration. My guess is there's an improper z2m config option or your LQI is too high. |
Great news, there might be a solution! 🎉 🚀 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 #663, I have made some changes. With that code when 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. |
Hi folks! I have merged #663 and released v1.18.0. Set I will close this issue and would really appreciate folks reporting back on whether the issue is fixed. ⚙️ Thanks everyone for your support and patience in getting this issue fixed! 🙌❤️ |
BTW if you have debugging logging enabled you'll see messages like these:
This would previously have turned on the light 💡 |
This has only happened to me twice, and I don't have a way to replicate it, but I will turn off a light using lovelace and after 10-15 seconds or so it turns itself back on. If I find a way to replicate it I can turn on debugging but I have no way to track it down so it wouldn't do much good right now. I am running d67479d now, and if I see it happen with this version I will let you know but like I said this has only happened twice over the week or so I've been running AL.
The text was updated successfully, but these errors were encountered: