nuki_hub: Inconsistent lock binaryState/state in MQTT
Today I noticed that lock sensor in HA was reporting unlocked when Nuki was locked, I checked MQTT and noticed this:

You will notice that lock/binaryState is unlocked but lock/state is locked.
I restarted Nuki Hub to force it to reset the states from the lock and everything was good again.
BTW: is it possible to add a restart button in the UI? right now I go into settings and hit save to force it to restart)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 136 (36 by maintainers)
With the previous one.
Actually not so fast! Persistent connections in MQTT are configured via the clean sessions flag (what a misleading name). Settings it to false makes connections persistent, of course it defaults to true.
Try this binary with clean sessions set to false:
nuki_hub-7.0-cs-false.zip
I’ve added the check from the first post in that topic. Anyone want to give it a try?
nuki_hub-6.11-tryfix-mqtt-1.zip
Actually yes, still reading:
https://github.com/knolleary/pubsubclient/issues/832
Could indeed be a library problem. As far as I understand if a an incoming messages is received while publishing, it can corrupt memory.
I didn’t intend to imply a hardware issue.
I think we’re talking about a software problem here. In C++ it’s easy to write to a memory location by accident, this would be what you refer to as memory corruption. In this case it looks like bytes are changed somehow at the memory location where the MQTT topic is stored.
I’ve reviewed the code building MQTT paths. It’s a rather simple method, still there were some stupid mistakes which should be fixed now, you can try release 6.1. If this fixes the actual issue with the binary state I don’t know, please test.
Thanks, I’ll look into it.