I have implemented a Nuki app in Appdaemon for Home Assistant. However, I am having real issues with the Web API. Often after sending a command, nothing happens. I have thus already implemented a loop, which should really not be needed, but even then I have issues.
For example, the log from last night:
2020-04-23 23:20:52.265130 INFO Nuki: lock_door_event: input_boolean.night
2020-04-23 23:20:52.272324 INFO Nuki: lock_door_action
2020-04-23 23:21:02.018549 INFO Nuki: lock_door_action
2020-04-23 23:21:02.125474 INFO Nuki: lock_door_repeat: try: 0, r.status_code: 423
2020-04-23 23:21:12.036646 INFO Nuki: lock_door_action
2020-04-23 23:21:12.143880 INFO Nuki: lock_door_repeat: try: 1, r.status_code: 423
2020-04-23 23:21:22.027391 INFO Nuki: lock_door_action
2020-04-23 23:21:22.131888 INFO Nuki: lock_door_repeat: try: 2, r.status_code: 423
2020-04-23 23:21:32.036903 INFO Nuki: lock_door_action
2020-04-23 23:21:32.173512 INFO Nuki: lock_door_repeat: try: 3, r.status_code: 423
2020-04-23 23:21:42.034066 INFO Nuki: lock_door_action
2020-04-23 23:21:42.139362 INFO Nuki: lock_door_repeat: try: 4, r.status_code: 204
When I go to bed, the Nuki should lock. The first attempt (lock_door_action) doesn’t result in a locked or locking state, thus it tries again. Notice the resulting status codes.
Even after attempt 5, the door was still not locked, and by then it gives up. So the door remains unlocked over night.
The lock door action basically does:
hed = {‘Authorization’: 'Bearer ’ + self.auth_token}
data = {‘action’: action}
url = ‘https://api.nuki.io/smartlock/507613268/action’
r = requests.post(url, json=data, headers=hed)
With action = 2 in this case.
I am seeing similar effects with unlocking as well as with the Opener RTO. Any idea what’s going on here and/or how to fix this?