technyon / nuki_hub

Use an ESP32 as a Hub between a NUKI Lock and your smarthome.
MIT License
469 stars 37 forks source link

Nuki Hub gets unavailable for a couple of hours a day - also tries to reconnect every minute afterwards #413

Open DeckardCain2014 opened 1 week ago

DeckardCain2014 commented 1 week ago

PROBLEM DESCRIPTION

Nuki Hub is several times a day unavailable via MQTT for several hours.

REQUESTED INFORMATION


### TO REPRODUCE
Let Nuki Hub run a few hours. Then it is shown as unavailable in HomeAssistant for a couple of hours. Later, it automatically reappears and works as designed.

### EXPECTED BEHAVIOUR
Connection stays stable.

### SCREENSHOTS
none

### ADDITIONAL CONTEXT
Output from Mosquito broker:

2024-06-26 18:28:04: New client connected from 192.168.178.81:60166 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:28:28: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:28:34: New connection from 192.168.178.81:60167 on port 1883. 2024-06-26 18:28:34: New client connected from 192.168.178.81:60167 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:28:58: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:29:04: New connection from 192.168.178.81:60168 on port 1883. 2024-06-26 18:29:04: New client connected from 192.168.178.81:60168 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:29:28: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:29:34: New connection from 192.168.178.81:60169 on port 1883. 2024-06-26 18:29:34: New client connected from 192.168.178.81:60169 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:29:58: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:30:04: New connection from 192.168.178.81:60170 on port 1883. 2024-06-26 18:30:04: New client connected from 192.168.178.81:60170 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:30:28: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:30:39: New connection from 192.168.178.81:60171 on port 1883. 2024-06-26 18:30:39: New client connected from 192.168.178.81:60171 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:31:04: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:31:10: New connection from 192.168.178.81:60172 on port 1883. 2024-06-26 18:31:10: New client connected from 192.168.178.81:60172 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:31:34: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:31:40: New connection from 192.168.178.81:60173 on port 1883. 2024-06-26 18:31:40: New client connected from 192.168.178.81:60173 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:32:04: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:32:13: Saving in-memory database to /data//mosquitto.db. 2024-06-26 18:32:15: New connection from 192.168.178.81:60174 on port 1883. 2024-06-26 18:32:15: New client connected from 192.168.178.81:60174 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:32:40: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:32:46: New connection from 192.168.178.81:60175 on port 1883. 2024-06-26 18:32:46: New client connected from 192.168.178.81:60175 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:33:10: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:33:16: New connection from 192.168.178.81:60176 on port 1883. 2024-06-26 18:33:16: New client connected from 192.168.178.81:60176 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:33:40: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:33:46: New connection from 192.168.178.81:60177 on port 1883. 2024-06-26 18:33:46: New client connected from 192.168.178.81:60177 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:34:10: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:34:16: New connection from 192.168.178.81:60178 on port 1883. 2024-06-26 18:34:16: New client connected from 192.168.178.81:60178 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:34:40: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:34:46: New connection from 192.168.178.81:60179 on port 1883. 2024-06-26 18:34:46: New client connected from 192.168.178.81:60179 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:35:10: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:35:29: New connection from 192.168.178.81:60181 on port 1883. 2024-06-26 18:35:29: New client connected from 192.168.178.81:60181 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:35:52: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:35:58: New connection from 192.168.178.81:60182 on port 1883. 2024-06-26 18:35:58: New client connected from 192.168.178.81:60182 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:36:22: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:36:28: New connection from 192.168.178.81:60183 on port 1883. 2024-06-26 18:36:28: New client connected from 192.168.178.81:60183 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:36:52: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:36:58: New connection from 192.168.178.81:60184 on port 1883. 2024-06-26 18:36:58: New client connected from 192.168.178.81:60184 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:37:22: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:37:36: New connection from 192.168.178.81:60186 on port 1883. 2024-06-26 18:37:36: New client connected from 192.168.178.81:60186 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:37:58: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:38:04: New connection from 192.168.178.81:60187 on port 1883. 2024-06-26 18:38:04: New client connected from 192.168.178.81:60187 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:38:28: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:38:39: New connection from 192.168.178.81:60188 on port 1883. 2024-06-26 18:38:39: New client connected from 192.168.178.81:60188 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:39:04: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:39:15: New connection from 192.168.178.81:60189 on port 1883. 2024-06-26 18:39:15: New client connected from 192.168.178.81:60189 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:39:40: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:39:51: New connection from 192.168.178.81:60190 on port 1883. 2024-06-26 18:39:51: New client connected from 192.168.178.81:60190 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:40:16: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:40:26: New connection from 192.168.178.81:60191 on port 1883. 2024-06-26 18:40:26: New client connected from 192.168.178.81:60191 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:40:52: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:41:01: New connection from 192.168.178.81:60192 on port 1883. 2024-06-26 18:41:01: New client connected from 192.168.178.81:60192 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:41:28: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:41:37: New connection from 192.168.178.81:60193 on port 1883. 2024-06-26 18:41:37: New client connected from 192.168.178.81:60193 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:42:04: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:42:12: New connection from 192.168.178.81:60194 on port 1883. 2024-06-26 18:42:12: New client connected from 192.168.178.81:60194 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:42:34: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:42:47: New connection from 192.168.178.81:60195 on port 1883. 2024-06-26 18:42:47: New client connected from 192.168.178.81:60195 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:43:10: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:43:23: New connection from 192.168.178.81:60196 on port 1883. 2024-06-26 18:43:23: New client connected from 192.168.178.81:60196 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:43:46: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:43:58: New connection from 192.168.178.81:60197 on port 1883. 2024-06-26 18:43:58: New client connected from 192.168.178.81:60197 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 18:44:22: Client nukihub has exceeded timeout, disconnecting. 2024-06-26 18:47:32: New connection from 192.168.178.81:51014 on port 1883. 2024-06-26 18:47:32: New client connected from 192.168.178.81:51014 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 19:02:14: Saving in-memory database to /data//mosquitto.db. 2024-06-26 19:32:15: Saving in-memory database to /data//mosquitto.db. 2024-06-26 20:02:16: Saving in-memory database to /data//mosquitto.db. 2024-06-26 20:13:26: New connection from 192.168.178.81:54669 on port 1883. 2024-06-26 20:13:26: Client nukihub already connected, closing old connection. 2024-06-26 20:13:26: New client connected from 192.168.178.81:54669 as nukihub (p2, c0, k15, u'mqttUser'). 2024-06-26 20:15:23: New connection from 192.168.178.81:59567 on port 1883. 2024-06-26 20:15:23: Client nukihub already connected, closing old connection. 2024-06-26 20:15:23: New client connected from 192.168.178.81:59567 as nukihub (p2, c0, k15, u'mqttUser').



**(Please, remember to close the issue when the problem has been addressed)**
StefanX13 commented 1 week ago

Same here. If mosquitto Broker output is needed please just tell.

iranl commented 1 week ago

I suggest trying the latest PR with Arduino Core 3 and IDF 5.1. Besides many changes to the networking stack it also includes nuki hub specific improvements regarding MQTT.

You can find the binaries here: https://github.com/technyon/nuki_hub/actions/runs/9711394389

Do note that these binaries need to be flashed using USB/serial once because of changes to the partition table.

DeckardCain2014 commented 6 days ago

I tried flashing it with the Espressif Flash Download Tools, however it shows only 'null' in the command line and red fields in the UI

iranl commented 5 days ago

I find that to be a horrible tool and exclusively use esptools.

See https://docs.espressif.com/projects/esptool/en/latest/esp32/installation.html or https://www.flamingo-tech.nl/2021/03/21/installing-and-using-esptools/ for how to install esptools.

You can just use the command in the how-to-flash.txt file. You only need to change the COM port.

DeckardCain2014 commented 4 days ago

Worked now. Different machine, different tool. I will update here how stable it is

DeckardCain2014 commented 4 days ago

Basically it works now. However, the main lock topic is unavailable image

fir3drag0n commented 2 days ago

Is there a solution to unknown state?