homebridge-z2m: [Bug] Turned off lights don't retain brightness on Homebridge restart
Is there an existing issue for this?
- I have searched the existing issues
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.
https://github.com/itavero/homebridge-z2m/blob/31b0fd9c4624bfd84e3e6e5bc62f6ee2f27baf3e/src/platformAccessory.ts#L100-L110
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
- Turn on a light and set its brightness to e.g. 50% (ensure retain in Z2M is enabled)
- Turn off the light (doesn’t matter how)
- Restart Homebridge (ensure Mosquitto & Z2M are still running)
- Turn on the light (via Home.app or a Zigbee remote)
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
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 20 (19 by maintainers)
Nice! 💪 I‘ll have to do some more testing to see if #982 is working as intended. Keeping you posted.
Already pushed a new release that should solve that 🤞
I’m not using the availability stuff myself, or I’m using a different format.
@burmistrzak Can you check if the latest beta release at least prevents the behavior you mentioned?
Probably should still keep this issue open for now, as I think it’s still good to think about making better use of the Zigbee2MQTT configuration to determine if we should request certain data or not.
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
retainis on in the device config (or default config) andcache_stateis enabled in the “advanced” settings of Zigbee2MQTT.