nuki_hub: ioBroker nuki mqtt -> Cannot parse "lock/json"

Hi, it seems that there’s an issue parsing the JSON string that I receiving in ioBroker. This error is hard to reproduce as it doesn’t occur consistently (maybe once a day):

Client [nukihub] Cannot parse "nuki/lock/json": {"lock_state":"locked","trigger":"manual","last_lock_action":"Lock","lock_completion_status":"success","door_sensor_state":"unavailable","auth_id":0,"auth_name":"��?"}

Typically, the JSON string looks like this:

{"lock_state":"locked","trigger":"manual","last_lock_action":"Lock","lock_completion_status":"success","door_sensor_state":"unavailable","auth_id":0,"auth_name":""}

I guess, the parse error is likely due to the strange characters in the “auth_name” field? Is this known, or does anyone know a solution for it?

MQTT works with the Nuki Hub without any problems, I can see all the data and operate the lock. Therefore, I think that this error does not come from ioBroker. Only this error is irritating. I don’t actually need this json data field.

  • Tested with Nuki Hub 8.33 and 8.34-pre-4
  • ioBroker Admin 6.13.16 with MQTT v5.2.0 as Server Broker

About this issue

  • Original URL
  • State: open
  • Created 2 months ago
  • Comments: 26 (10 by maintainers)

Most upvoted comments

@jolichter: Would you give this binary a try?

esp32-s3-assets.zip

Note: Use the nuki_hub.bin to do an OTA update from the Web configurator. Version should show 8.33 not 8.34-pre4

Hi,

Usually one would indeed use strcpy, but in this case memcpy is better. strcpy basically copies zero-terminated strings, so it copies until it finds a 0 in memory. The Nuki API sends 32 characters, and the name can be up to 32 characters long. It’s either 0 terminated, or it fills the maximum length of 32 chracters. That’s why the authName character array is 33 characters long and initialized with 0s before copying. Either it copies the 0 terminated string from the Nuki API, or it copies all 32 characters, and character number 33 in the authName array is 0 and thus terminates the string. Quite a special case indeed.