-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
[Bug] Turned off lights don't retain brightness on Homebridge restart #882
Comments
I'll have to test if the scheduled updates are also affected. We'll see... 👀 |
Never noticed this myself, so I'm not sure if every light behaves the same in this situation. Anyway, instead of not requesting it, it might be better to ignore the brightness if the state is off (and perhaps if the brightness is also below a certain level). After all, Homebridge is not the only source that can change the brightness or state. |
At least for Philips Hue, when you
Well, it's the act of requesting the brightness level itself, that's changing the cached state in Z2M. 😅 @itavero Also, doesn't requesting the state of every single device, generate a lot of unnecessary Zigbee traffic, especially in larger setups? Shouldn't we be a bit more efficient here? |
I don't have any retained state on my setup as far as I'm aware. The traffic is only once on startup, so I don't see an issue with that. We could probably add a configuration to disable getting the state on startup, or look at the configuration of Zigbee2MQTT to see if it has a retained state (I reckon the information would be available there?). |
Z2M essentially has two types of cache.
I guess it depends on your network's size. Ours is on the bigger side, with 121 Zigbee devices in total, and 95 of them exposed to HomeKit. Also, aren't we getting all keys regularly, like every four hours? homebridge-z2m/src/platformAccessory.ts Lines 100 to 106 in 31b0fd9
Yes, but we probably should add two options: The first to disable getting all keys on startup, the second to turn off the scheduled updates (~ every 4h) mentioned above.
It's possible to see if a device has |
I don't think I have either of them enabled, which is probably why I ended up with this implementation.
My "production" environment is only about 80 devices.
This timer only elapses if there wasn't any state update for 4 hours (timer gets reset on every state update).
Just to be clear, it doesn't get all keys. Only the ones marked as "gettable". Still the default for the startup should be based off of the Zigbee2MQTT device configuration, I guess. For the other one, it's difficult. If reporting is enabled (can probably also be found in the config) and working properly, the updates should not be needed. Once I have some time I can look into implementing something like that, although I'm not planning to test this on my own environment. |
Yea, the internal Z2M cache is enabled by default, so we should probably take this into account going forward.
You'll get there. 😉
Aha, hoped it would be implemented this way. Does any state update (incl. set) reset the timer?
Sure, but that's potentially still a lot of traffic. A single Zigbee light has about five gettable keys on average.
Yes,
Fetching the
You mean the scheduled state updates (~ 4h)?
Happy to do the extensive testing for you. 😊 |
Note to self: Zigbee2MQTT configuration is already being parsed in platform.ts for the availability feature. Should probably clean up that code and add a model there. The check should probably be that both |
@itavero Ok, so we would add an option (per device and default) to indicate whether |
@itavero I have a rough draft ready, but I'm currently not checking if |
This comment was marked as outdated.
This comment was marked as outdated.
@itavero Hmm, my initial idea of simply skipping the What about not requesting homebridge-z2m/src/platformAccessory.ts Lines 296 to 305 in 4f405a1
|
@itavero I've implemented an experimental option in #931 based on my previous #882 (comment). |
Is there an existing issue for this?
Describe the bug
When restarting Homebridge, lights that are turned off don't retain their brightness level.
This seems to be cause by the plugin getting the all keys (including brightness) from Z2M on startup.
homebridge-z2m/src/platformAccessory.ts
Lines 100 to 110 in 31b0fd9
Because the light is already off, Z2M naturally reports
1
as current brightness.A possible solution could be to simply not
/get
the current brightness when we know a light is turned off?Related devices
No response
Related Devices
No response
Steps To Reproduce
Expected behavior
Light turns on at 50% brightness
Device entry
No response
Status update
No response
Messages from this plugin
No response
This plugin
1.11.0-beta.5
Homebridge
1.7.0
Zigbee2MQTT
1.38.0-dev
Homebridge Config UI X (if applicable)
No response
The text was updated successfully, but these errors were encountered: