-
-
Notifications
You must be signed in to change notification settings - Fork 49
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] Innr SP 222 socket reports incorrect state to HomeKit #383
Comments
Never seen this before myself. It does sound that somehow messages are being handled out of order. When I've time I'll see if I can somehow reproduce this. Strange though that the |
Thanks, I appreciate you looking into it!
Yes, I mentioned |
I am consistently running into this bug with my setup: zigbee2mqtt + homebridge + homebridge-z2m. All lamps and switches are affected |
I'm still running Zigbee2MQTT 1.22.2. I'm also on Homebridge 1.4.0. I'll see what happens if I update Zigbee2MQTT. |
I tried downgrading back to Zigbee2MQTT 1.22.2, but I didn’t see any difference in behaviour. |
I've updated Zigbee2MQTT to 1.23.0, but I don't see similar behavior with any of the smart plugs I have, unfortunately. |
I wonder if this might be related to #358 |
Hi folks! Same behaviour here with a Tuya TS130F blind cover switch, all works fine using the Zigbee2MQTT UI, but the state reported to Homekit is incorrect (swapped). When the blinds are closed (covering the window) Homekit says "Open" and viceversa. Thanks in advance |
Did anyone try downgrading Homebridge to an older version (from before v1.4.0, i.e. v1.3.9)? In #395, it is indicated that this improved the user experience. If so, it might be a regression in Homebridge (as mentioned in homebridge/homebridge#3073). If anyone else gives this a try, please share your results. |
I just downgraded Homebridge from1.4.0 to 1.3.9 and it fixed the issue for me. I'm using homebridge-z2m v1.7.0. |
Interestingly I upgraded homebridge back to 1.4.0 and was able to repeat the issue. I then downgraded hap-nodejs to 0.9.8 and it fixed the issue. Homebridge 1.4.0 saw hap-nodejs upgraded from 0.9.8 to 0.10.0. |
@lyonanderson Would you be able to provide some HAP-NodeJS logs (as mentioned in the issue on the Homebridge repo)? |
Here you go. Note that with debug turned on it was harder to make it go wrong. Turning off seemed to trigger it the most. I can see that in 0.10.0 there are two events in the Sending HAP event message. Hope this helps: Turn On Accessory 0.9.8
Turn Off Accessory 0.9.8
Turn On Accessory 0.10.0
Turn Off Accessory 0.10.0
|
As reported in the issue on the Homebridge repository, a workaround seems to be to turn off I think I actually already had this off in my setup, so that could explain why I'm not seeing this behavior. Something changed in Homebridge, which is now making this behavior evident. Previously events would get "merged", if they were occuring in a very short timespan (which Zigbee2MQTT can apparently trigger with the cache). This is no longer the case, resulting in two events now (one with the cached state, one with the new state) being published by Homebridge at the same time for the same attribute. The Home.app doesn't seem to like that though. Initially I thought adding filtering where the data comes in would solve this, but I think I actually expect the same value to be received at least twice in a row in some locations (e.g. for covers to determine that it moving). |
This work around is working for me. Thanks! ✨
Leaving this issue open, since it sounds like you’re working on a deeper fix, but I’ll update the issue description with the work around for other folk who search for this issue. |
It appears that this issue did not have an update in quite some time. Please check if you can provide any additional information to help resolve this issue. If there isn't any activity in the next two weeks, this issue will be closed automatically. Thank you for your contributions! |
Vote to reopen this issue as disabling the cache state is not a great workaround (my device states toggle like crazy when caching is disabled). |
🎉 ✨ 🚨 Update: there’s a workaround, as @itavero says in #383 (comment) …
Describe the bug
This socket has to be switched on or off twice in the Apple Home app for the state in HomeKit to sync with the state of the device.
The first time it is switched the device state changes, but the HomeKit state immediately resets to what it was before. The second time it is switched, the device state doesn’t change, and the HomeKit state is updated to reflect the real state of the device.
This is an intermittent bug: it happens almost every time, but very occasionally it will work as expected, or the Home app will catch up on its own (e.g. switch on, HomeKit immediately toggles off, and then toggles back on within a second).
Related devices
Innr SP 222
To Reproduce
Starting with the socket “off” and shown as “off” in the Home app:
zigbee2mqtt/Front bedroom socket
:{"last_seen":"2022-02-12T13:20:54.237Z","linkquality":255,"state":"OFF"}
{"last_seen":"2022-02-12T13:20:54.237Z","linkquality":255,"state":"ON"}
The device is now “on,” and the state shown in the zigbee2mqtt Web UI includes
{"state": "ON"}
, but the state in the Home app is “off.”Starting with the socket “on” and shown as “off” in the Home app, it is possible to get them back in sync:
zigbee2mqtt/Front bedroom socket
:{"last_seen":"2022-02-12T13:26:32.776Z","linkquality":255,"state":"ON"}
All of this then happens in reverse when starting with the device “on” and trying to turn it to “off.”
Expected behavior
Expect the device and HomeKit to stay in sync.
Wild speculation
The multiple messages, and the intermittent nature of the bug, make me wonder if there is a race condition somewhere.
The first message contains the current state of the device, and the second message the desired state of the device (e.g. when switching on, the messages are “off” then “on”). The three behaviours I’m seeing seem to map to:
Take all of this with a large grain of salt: I’ve looked at the code a bit, but nowhere near enough to be confident in this theory, it just kinda feels like a race condition 🙂
Debugging attempts
“eager”“optimistic” option is switched off. With this option switched on, the behaviour is the same but with an extra MQTT message (e.g. switching to “on” would produce “off, on, on” messages instead of just “off, on” messages)MQTT messages
The device entry from
zigbee2mqtt/bridge/devices
Status update from
zigbee2mqtt/Front bedroom socket
A series of messages from repeatedly toggling the lamp on and off via the Home app.
Messages published by this plugin that might be related to your issue
Logs from running
homebridge -D
and toggling the switch on and off.Interestingly in this configuration, I couldn’t reproduce the typical behaviour where the device and HomeKit get out of sync, instead I consistently saw the behaviour where HomeKit would toggle twice and end up in the correct state (e.g. I switch the device “on”, the Home app immediately changes back to “off”, and then quickly changes back to “on”).
I think this lends credence to the theory that part of this is a race condition on the basis that adding more logging to code with race conditions often adds enough I/O delay to change the outcome of the race.
Versions used
Please provide the version of the following pieces of software:
The text was updated successfully, but these errors were encountered: