-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Brightness ist set to 1 when turning light on again #13570
Comments
Can you provide the herdsman debug log of this? See https://www.zigbee2mqtt.io/guide/usage/debug.html on how to enable the herdsman debug logging. Note that this is only logged to STDOUT and not to log files. |
@Koenkk Sure, here it is: Turning light off:
Turning light on again:
|
I also need the received MQTT commands, can you provide the herdsman debug log of the following:
|
I have many connected devices, so the full log would be quite big. As I use the zigbee2mqtt UI for toggling the light I don't think there will be any received MQTT commands, or is it also using MQTT internally? |
I turned on debug log-level and now I see the received MQTT commands as well. Here are the relevant log entries: Initial ON by manually setting brightness:
Setting to OFF:
Setting to ON again:
Please let me know if you need anything else. Thank you. |
@pyos I think this is caused by Koenkk/zigbee-herdsman-converters#4211 . The
|
Because that's what onLevel does. As described in ZCLv7 chapter 3.10.2.1.1, it sets the brightness to which an "on" command should turn the light on. If you want to keep the old brightness, it should be 255, not 1. Try publishing |
Hello @pyos, thank you for your input. I'm not sure if your reply was partly for me, but I tried anyway ;-) If I send your command I see the brightness changing to the previous value in the UI, but the light stays off:
If I change the payload to include the state it turns on, but the brightness is again set to 1:
But if I split it up in two separate commands it works as expected: 👍
Hope it helps it getting this fixed :) |
Ok I guess I didn't explain clearly. This sentence:
is not correct. The light has a configuration parameter that tells it which brightness to use when turned on. If it's set to "previous" (or 255), then it'll be the brightness when it was turned off; otherwise it'll be some other value. You can change that configuration parameter by sending So the behavior you're seeing is 100% correct - when on_level is set to 1, What I don't understand though are the timestamps in your logs. At 08:58:51, you set on_level to "previous", then at 09:00:51 that seems to have worked fine - but at 09:02:04, on_level reverted back to 1 by itself? |
@pyos Yes, it's quite strange. I did some further tests and it seems setting the state to on always somehow generates another message (at least according to the zigbee2mqtt logs). Do you have any idea where this is coming from/ why it is generated?
It seems setting the state to off resets the level_config "somewhere". I write "somewhere" because the correct on_level is still shown as "previous" in any subsequent logs. For example, if I publish turn off three times, the last two messages still show the on_level as previous:
But as soon as I set the state to on, the on_level is set/ shown as 1 in the weird additional message generated and also the brightness is that to that level:
If I set the level_config to previous between turning the light off and on again, the previous value is correctly used:
If you like we could also schedule a quick screensharing session... BTW: I put a sleep between the mqtt publish commands, so one can easily see, which logs belong to which command. Setting the state to on generates always two log entries (no idea why), all other command just one (as expected). |
The extra publish when you send
My guess is that the light does that by itself; zigbee2mqtt will not notice the change until it actually tries to read the value again. I think you should be able to force that by sending |
Ok, that makes sense. And yes, it seems the light resets the configuration when the state is set to off:
Imo it's strange that the get command also generates two messages. Unfortunately, no OTA is available (checked https://update.ledvance.com/firmware-overview). So I assume a workaround for this device is needed? Why is it needed to re-read the values to turn the light on? |
That's because level_config has two suboptions (on_level and execute_if_off), and each triggers a separate update.
Yes, one option is to just not re-read on_level from the device if it's already present in the state and assume that it shouldn't change otherwise. For now you should be able to fix this with an extension: https://gist.github.com/pyos/2e2a768dd1eba25bb8bc8396368463ca - add that, send |
Thank you very much @pyos, your patch works perfectly. Is there an easy way to set the on_level for all devices? Perhaps using a startup script? Also, why isn't the on_level property exposed in the UI (or am I just missing it?)? |
This actually helped me for adaptive lighting, to not get blinded at turn-on. Irrelevant to the op's issue, but thanks nonetheless. |
Hi @gucki, Thanks for your concern. Here, as I see that you have already received the support from the community as well. |
Hi @dhanukapulkit, so you say it's a bug in zigbee2mqtt? |
Hi @gucki , when we are testing the lamps with our partner gateways than the "previous" function is working. |
I had the same bug with zigbee2mqtt. The interesting part was, that on first installation it worked fine. Only after I changed the transition to 0, it stopped working properly. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days |
Is there anything I can do to get this issue resolved? Will your patch, @pyos, be merged? |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days |
@Koenkk Can you please reopen it because it's not really fixed? How to push this forward? Thank you. |
The patch from @pyos got merged (Koenkk/zigbee-herdsman-converters#4596), but if I understand correctly this did not fix the issue? (z2m 1.28.2) |
You reverted it, then I forgot to fix the thing you mentioned in the comment. |
I see, any chance you could take a look at it? |
Fix from @pyos is merged now, @gucki can you check again? Changes will be available in the dev branch in a few hours from now. (https://www.zigbee2mqtt.io/advanced/more/switch-to-dev-branch.html) |
Hello @Koenkk , I just tried (using docker latest-dev tag, 1.28.2-dev (commit #50cb421)), but unfortunately, it doesn't seem to work. After turning the light on again, the brightness is not reset to the previous value. Here's the log output:
I didn't manually set the brightness as mentioned in #13570 (comment). Is this still necessary? |
@pyos could you check what goes wrong here? |
Yes, you need to manually change on_level one last time - zigbee2mqtt has no way to determine that the value that's already in the state is wrong |
@pyos Ok, I'll try this tomorrow then. But it means I'll not only have to do this for all existing lights but also whenever I add a new light? |
I don't know, that depends on what settings the bulbs will report when at factory state. |
Sorry, it took a bit longer but I can confirm now that it works as expected after manually setting the brightness as mentioned in #13570 (comment). |
What happened?
When I turned off a light and back on again using an old version of zigbee2mqtt the brightness was the same as before. After I upgraded zigbee2mqtt, the brightness is always set to 1 when I turn off a light and back on again. Unfortunately, I don't know which version I was using before (I already cleaned up the unused docker images & containers).
FWIW, the color temperature seems to be remembered 👍
What did you expect to happen?
When turning a light back on again, the brightness should be set to the previous value, before the light was turned off.
I debugged the mqtt messages sent by zigbee2mqtt and it seems zigbee2mqtt is (surprisingly) sending two mqtt messages when a light is turned on. The first message still contains the previous brightness and state off, the second brightness 1 and state on. So this really looks like a bug too me.
Turning light off:
Zigbee2MQTT:info 2022-08-16 18:49:46: MQTT publish: topic 'zigbee2mqtt/light1', payload '{"brightness":254,"color_mode":"color_temp","color_temp":253,"device":{"applicationVersion":1,"dateCode":"Sep 29 2021\u0000\u0000\u0000\u0000\u0000","friendlyName":"light1","hardwareVersion":1,"ieeeAddr":"0xf0d1b8000011becd","manufacturerID":4489,"manufacturerName":"LEDVANCE","model":"4058075148338","networkAddress":50978,"powerSource":"Mains (single phase)","softwareBuildID":"01056400","stackVersion":2,"type":"Router","zclVersion":2},"level_config":{"on_level":1},"linkquality":255,"state":"OFF","update":{"state":"idle"},"update_available":false}'
Turning light back on again:
Zigbee2MQTT:info 2022-08-16 18:49:59: MQTT publish: topic 'zigbee2mqtt/light1', payload '{"brightness":254,"color_mode":"color_temp","color_temp":253,"device":{"applicationVersion":1,"dateCode":"Sep 29 2021\u0000\u0000\u0000\u0000\u0000","friendlyName":"light1","hardwareVersion":1,"ieeeAddr":"0xf0d1b8000011becd","manufacturerID":4489,"manufacturerName":"LEDVANCE","model":"4058075148338","networkAddress":50978,"powerSource":"Mains (single phase)","softwareBuildID":"01056400","stackVersion":2,"type":"Router","zclVersion":2},"level_config":{"on_level":1},"linkquality":255,"state":"OFF","update":{"state":"idle"},"update_available":false}'
Zigbee2MQTT:info 2022-08-16 18:49:59: MQTT publish: topic 'zigbee2mqtt/light1', payload '{"brightness":1,"color_mode":"color_temp","color_temp":253,"device":{"applicationVersion":1,"dateCode":"Sep 29 2021\u0000\u0000\u0000\u0000\u0000","friendlyName":"light1","hardwareVersion":1,"ieeeAddr":"0xf0d1b8000011becd","manufacturerID":4489,"manufacturerName":"LEDVANCE","model":"4058075148338","networkAddress":50978,"powerSource":"Mains (single phase)","softwareBuildID":"01056400","stackVersion":2,"type":"Router","zclVersion":2},"level_config":{"on_level":1},"linkquality":255,"state":"ON","update":{"state":"idle"},"update_available":false}'
How to reproduce it (minimal and precise)
Turn off/on a light using the zigbee2mqtt UI. The same issue happens when using home assistant to toggle the light.
Zigbee2MQTT version
1.27.0 commit: a9b8808
Adapter firmware version
0x26720700
Adapter
ConBee2/RaspBee2
Debug log
No response
The text was updated successfully, but these errors were encountered: