hass-circadian_lighting icon indicating copy to clipboard operation
hass-circadian_lighting copied to clipboard

zigbee2mqtt spamming

Open irgusite opened this issue 4 years ago • 26 comments

Hi,

When using circadian at each event, the mqtt server resends an "on" value of the light that seems to retrigger circadian, who resend a new value (the same as before) and makes the server resend an "on" value, and so on.

So it spams the whole server with light changes orders even when the light is at the correct value.

(I don't know if I'm clear, don't hesitate to ask me if you want another explanation, it's late for me ^^)

irgusite avatar Jul 18 '19 20:07 irgusite

Sorry, I didn't ask my question:

Would it be possible to add a condition that it doesn't resend an order if the brightness and the color of the light already are the right value? That would, I think, solve the problem :)

irgusite avatar Jul 18 '19 20:07 irgusite

I'm actually planning on migrating my non-Hue devices to zigbee2mqtt soon, I am just waiting on the hardware to arrive (might be a few weeks still).

Are you seeing the "spamming" by monitoring MQTT, or the circadian_lighting entries in the HA log, or both?

claytonjn avatar Jul 19 '19 14:07 claytonjn

Yes I'm seeing it by the MQTT instance.

irgusite avatar Jul 19 '19 14:07 irgusite

I see what to do in the code and would gladly make a PR, but I just don't know how to get the light status back in python. (I'm starting deving on hass but didn't quite get the time to read through the doc ^^)

irgusite avatar Jul 19 '19 14:07 irgusite

Can you enable debug logging for circadian_lighting and verify that it is in fact sending spam commands? Every time Circadian Lighting sends an adjustment you should see an entry "[...] light adjusted" with the values CL is setting. I want to make sure the issue does lie within Circadian Lighting and not some quirk with zigbee2mqtt.

claytonjn avatar Jul 19 '19 14:07 claytonjn

As a quick answer I already did it 2 weeks ago and if I remember correctly (I will confirm this later when home) it was always adjusting in debug. But I will confirm that later and put the output here :)

irgusite avatar Jul 19 '19 14:07 irgusite

Hi, so I put circadian into debug mode and let it run approximately 5 seconds on one lamp:

22:09:16 DEBUG (SyncWorker_2) [] Circadian Lighting Switch Updated 22:09:18 DEBUG (SyncWorker_9) [] light.ampoule_chambre_mqtt CT Adjusted - color_temp: 453, brightness: 173.83414695831576, transition: 1 22:09:18 DEBUG (SyncWorker_0) [] light.ampoule_chambre_mqtt CT Adjusted - color_temp: 453, brightness: 173.83414695831576, transition: 1 22:09:19 DEBUG (SyncWorker_6) [] light.ampoule_chambre_mqtt CT Adjusted - color_temp: 453, brightness: 173.83414695831576, transition: 1 22:09:19 DEBUG (SyncWorker_2) [] light.ampoule_chambre_mqtt CT Adjusted - color_temp: 453, brightness: 173.83414695831576, transition: 1 22:09:19 DEBUG (SyncWorker_5) [] light.ampoule_chambre_mqtt CT Adjusted - color_temp: 453, brightness: 173.83414695831576, transition: 1 22:09:19 DEBUG (SyncWorker_9) [] light.ampoule_chambre_mqtt CT Adjusted - color_temp: 453, brightness: 173.83414695831576, transition: 1 22:09:20 DEBUG (SyncWorker_3) [] light.ampoule_chambre_mqtt CT Adjusted - color_temp: 453, brightness: 173.83414695831576, transition: 1 22:09:20 DEBUG (SyncWorker_0) [] light.ampoule_chambre_mqtt CT Adjusted - color_temp: 453, brightness: 173.83414695831576, transition: 1 22:09:21 DEBUG (SyncWorker_4) [] light.ampoule_chambre_mqtt CT Adjusted - color_temp: 453, brightness: 173.83414695831576, transition: 1 22:09:21 DEBUG (SyncWorker_5) [] light.ampoule_chambre_mqtt CT Adjusted - color_temp: 453, brightness: 173.83414695831576, transition: 1 22:09:21 DEBUG (SyncWorker_8) [] light.ampoule_chambre_mqtt CT Adjusted - color_temp: 453, brightness: 173.83414695831576, transition: 1 22:09:22 DEBUG (SyncWorker_4) [] light.ampoule_chambre_mqtt CT Adjusted - color_temp: 453, brightness: 173.83414695831576, transition: 1 22:09:22 DEBUG (SyncWorker_6) [] Circadian Lighting off - not adjusting 22:09:22 DEBUG (SyncWorker_7) [] Circadian Lighting off - not adjusting 22:09:23 DEBUG (SyncWorker_9) [] Circadian Lighting off - not adjusting 22:09:23 DEBUG (SyncWorker_4) [] Circadian Lighting off - not adjusting 22:09:24 DEBUG (SyncWorker_6) [] Circadian Lighting off - not adjusting 22:09:24 DEBUG (SyncWorker_7) [] Circadian Lighting off - not adjusting 22:09:24 DEBUG (SyncWorker_9) [] Circadian Lighting off - not adjusting 22:09:25 DEBUG (SyncWorker_4) [] Circadian Lighting off - not adjusting 22:09:26 DEBUG (SyncWorker_3) [] Circadian Lighting off - not adjusting

(I removed some parts for clarity)

And yes, the lamp did take the right color and brightness

irgusite avatar Jul 19 '19 20:07 irgusite

Thanks! Checking the state before adjusting should work...I'll try to get that implemented ASAP.

claytonjn avatar Jul 19 '19 23:07 claytonjn

Any news about the implementation? :)

irgusite avatar Jul 26 '19 09:07 irgusite

Just got the rest of the hardware for Zigbee2MQTT a couple days ago and haven't had a chance to migrate anything over yet. I'm hoping to have some time next week to work on it.

claytonjn avatar Jul 26 '19 17:07 claytonjn

Haven't gotten Zigbee2MQTT set up yet, but I just pushed out a beta release that checks light attributes before adjusting it. Let me know if it fixes the issue.

claytonjn avatar Jul 30 '19 22:07 claytonjn

It seems to work, At least I have no spamming as i can turn off my lights instantly. But I confirm that later when I get home to check the zigbee2mqtt intance.

Thank you very much :)

irgusite avatar Jul 31 '19 14:07 irgusite

I made another change per some discussions on the HA forum, and I believe it makes the state check before adjustment unnecessary. Could you try out 1.0.8b when you get a change and make sure the spamming isn't happening?

claytonjn avatar Jul 31 '19 19:07 claytonjn

Using 1.0.8b without any problems. Just didn't get the time to check the z2m logs

irgusite avatar Aug 02 '19 07:08 irgusite

same here

gericho avatar Aug 02 '19 08:08 gericho

I just came home and looked at the z2m instance, and I can confirm that there is no more spamming occuring :)

Thank you a lot, your integration is a must and I'm very happy to use it again :)

irgusite avatar Aug 02 '19 16:08 irgusite

So apparently I screwed up the 1.0.8b release and it was actually the same as 1.0.6. @irgusite @gericho how did you download/install 1.0.8b? I'm curious if you got the correct files or not if it actually fixed the issue.

claytonjn avatar Aug 04 '19 19:08 claytonjn

I downloaded it from the link above https://github.com/claytonjn/hass-circadian_lighting/releases/tag/1.0.8b

at this point I'm confused, the spamming may be caused by the availability_timeout in zigbee2mqtt configuration.yaml that was disabled yesterday... BTW thank you very much for the update, just installed on the HA server, I'll keep you updated

gericho avatar Aug 04 '19 20:08 gericho

I updated it from hacs. But something changed and I only changed your plug-in ^^ what happened if it wasn't expected to work?

irgusite avatar Aug 04 '19 20:08 irgusite

my HACS shows only "master" branch, so the latest is the 1.0.6, I did the manual installation, so copied the files in custom_components

gericho avatar Aug 04 '19 20:08 gericho

So the betas are on the dev branch and stables are on master. When I created the 1.0.8b release I was a doofus and forgot to switch the branch to dev, so it ended up being the same as release. The changes were all there on the dev branch, but the release didn't have them. I should have noticed because the order of releases was messed up, but apparently I just have too much going on 🙄

Anyway, upgrading from HACS or using that link would have downloaded the "bad" 1.0.8b which was the 1.0.6 code. It basically should have meant that the "spamming" behavior would be occurring again - the fact that it didn't baffles me. Regardless, I feel the changes are for the best so as long as there are no issues with the new 1.0.9b release, I plan on pushing everything to stable.

@gericho you can install betas in HACS by opening up Circadian Lighting, going to the menu in the upper right, and clicking "Show beta"

claytonjn avatar Aug 04 '19 23:08 claytonjn

1.0.9b doesn't work, the light don't change color, if I manually change it, it doesnt get back instantly, it take like 1 minute to react

irgusite avatar Aug 05 '19 12:08 irgusite

I think this is by design since it triggers only ON state, right?

gericho avatar Aug 05 '19 12:08 gericho

Oh, yeah seems logic ^^

irgusite avatar Aug 05 '19 12:08 irgusite

Okay, so I'm not at home, but I have some weird things happening with 1.0.9b, I will look at it when I get back and report here :)

irgusite avatar Aug 05 '19 13:08 irgusite

1.0.9b doesn't work, the light don't change color, if I manually change it, it doesnt get back instantly, it take like 1 minute to react

Yes, this is by design. That's what I changed to prevent the "infinite loop" of CL adjustments triggering more CL adjustments and also to fix the issue reported in the HA forum where you couldn't disable CL based on the state of the lights. It should also minimize occurrences of not being able to turn lights off when the CL switch is enabled.

So basically, if a light and CL switch are both on and you adjust the light, it won't get corrected until the next interval, and will use the configured/default transition. If you turn on the CL switch and there are lights on, or if you turn on a light and the CL switch is on, the lights should adjust immediately (1 sec transition). Also going in/out of "sleep" or "disabled" mode should react immediately.

@irgusite, what type of weird things are happening?

claytonjn avatar Aug 05 '19 13:08 claytonjn