I have recently started using zigbee sensors (very small so SHMBO likes that they can be hidden). I already have a variety of 433Mhz sensors chatting to Node-Red though rtl_433 & MQTT. There seem to be a variety of zigbee2mqtt nodes so I chose node-red-contrib-zigbee2mqtt (the bridge node allows editing the friendly name and groups without manually editing the configuration.yaml file)
However, once I added the zigbee2mqtt in node the MQTT node displayed a status of 'not connected', even though it was, and was sending data. If I add another MQTT node it does not display its status (even if added to another flow on the same Node-Red instance). The MQTT out node DOES display status, as do any other in nodes using the same MQTT broker on other Node-Red instances.
Although, as the data is still being provided by the MQTT node, this is not an end of the world event I wondered it anyone had any thoughts as to why this might be happening.
Apologies if this has already been raised but I couldn't find anything when I searched.
What exactly do the nodes do? Does it provide an mqtt broker? If not then what is the server node? I am wondering whether you have a conflict between brokers.
What are you using for your broker and have you looked at its logs?
The broker is Mosquitto and seems to be OK when I look at the output with MQTT Explorer and I cannot see anything that leaps out in the log. The MQTT node does collect the zigbee data because the Zigbee2MQTT.io is broadcasting to the server. The zigbee nodes are also connected to the Mosquitto server
As far as I can tell the nodes are doing the same job as the MQTT node, on steroids. The MQTT node just receives the basic zigbee payload (temperature, humidity etc.) the zigbee2mqtt node receives that plus device data,
etc.
I am running zigbee2mqtt.io as a daemon on a Pi as per the documentation on GitHub with a basic configuration.yaml .
I am assuming that I have configured stuff correctly because it is all working, but you know what assuming does.
The logs look fine. As I said the nodes are connecting and passing data into Node-red. The only issue is the incorrect / lack of status message. Here is a snapshot of the Mosquitto log
1593206451: New client connected from 192.168.1.36 as DVES_FBFEA4 (c1, k30, u'jeff').
1593206452: New connection from 192.168.1.32 on port 1883.
1593206452: New connection from 192.168.1.31 on port 1883.
1593206452: New client connected from 192.168.1.31 as DVES_7556B9 (c1, k30, u'jeff').
1593206452: New client connected from 192.168.1.32 as DVES_C847DA (c1, k30, u'jeff').
1593206453: New connection from 192.168.1.30 on port 1883.
1593206453: New client connected from 192.168.1.30 as DVES_E15D05 (c1, k30, u'jeff').
1593206459: New connection from 192.168.1.33 on port 1883.
1593206459: New client connected from 192.168.1.33 as DVES_B0441A (c1, k30, u'jeff').
1593206857: Client DVES_FBFEA4 has exceeded timeout, disconnecting.
1593206857: Socket error on client DVES_FBFEA4, disconnecting.
1593206858: Client DVES_C847DA has exceeded timeout, disconnecting.
1593206858: Socket error on client DVES_C847DA, disconnecting.
1593206859: Client DVES_E15D05 has exceeded timeout, disconnecting.
1593206859: Socket error on client DVES_E15D05, disconnecting.
1593206876: Socket error on client DVES_7556B9, disconnecting.
1593206876: New connection from 192.168.1.31 on port 1883.
1593206876: New client connected from 192.168.1.31 as DVES_7556B9 (c1, k30, u'jeff').
1593206876: New connection from 192.168.1.32 on port 1883.
1593206876: New client connected from 192.168.1.32 as DVES_C847DA (c1, k30, u'jeff').
1593206877: New connection from 192.168.1.30 on port 1883.
1593206877: New client connected from 192.168.1.30 as DVES_E15D05 (c1, k30, u'jeff').
1593206888: New connection from 192.168.1.36 on port 1883.
1593206888: New client connected from 192.168.1.36 as DVES_FBFEA4 (c1, k30, u'jeff').
1593207132: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1593208671: New connection from 192.168.1.26 on port 1883.
1593208671: New client connected from 192.168.1.26 as mqttjs_32372e49 (c1, k60, u'jeff').
1593208708: Client mqttjs_32372e49 disconnected.
1593208771: New connection from 192.168.1.26 on port 1883.
1593208771: New client connected from 192.168.1.26 as mqttjs_26e84a71 (c1, k60, u'jeff').
1593208816: Client mqttjs_26e84a71 disconnected.
1593208848: New connection from 192.168.1.26 on port 1883.
1593208848: New client connected from 192.168.1.26 as mqttjs_36e36110 (c1, k60, u'jeff').
1593208895: Client mqtt_d6a090fc.397b4 disconnected.
1593208933: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1593208972: New connection from 192.168.1.20 on port 1883.
1593208972: New client connected from 192.168.1.20 as mqtt_622cc24b.0e9dac (c1, k60, u'jeff').
1593209081: Client mqtt_754211dc.a2694 disconnected.
1593209083: New connection from 192.168.1.21 on port 1883.
1593209083: New client connected from 192.168.1.21 as mqtt_3f74e1e.3c8bd1e (c1, k60, u'jeff').
1593210734: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1593210999: Client DVES_7556B9 has exceeded timeout, disconnecting.
1593210999: Socket error on client DVES_7556B9, disconnecting.
1593211026: Socket error on client DVES_B0441A, disconnecting.
1593211026: Socket error on client DVES_C847DA, disconnecting.
1593211027: Socket error on client DVES_E15D05, disconnecting.
1593211030: New connection from 192.168.1.30 on port 1883.
1593211030: New client connected from 192.168.1.30 as DVES_E15D05 (c1, k30, u'jeff').
1593211030: New connection from 192.168.1.31 on port 1883.
1593211030: New client connected from 192.168.1.31 as DVES_7556B9 (c1, k30, u'jeff').
As fa as I can tell tis appears normal. 192.168.1.26 is the relevant connection for the zigbee2mqtt client. The DVES clients are the Tasmota devices on rtl_433
That doesn't look very normal to me, all the devices are continually connecting and disconnecting, including 192.168.1.26. Also notice that there are multiple different client ids of the form mqttjs_nnnn which is odd.
I think many MQTT client libs generate an auto client ID if not specified by the DEV/User. Tho I am not 100% certain if that is true when just re-connecting. Perhaps his devices are re-creating MQTT object when they think they have lost connection? Or perhaps the code on the devices is just plain wrong (i.e. always generating a new MQTT connection object every time they want to send data)?
The mqttjs_nnnn is on 192.168.1.26 which is the Pi that the zigbee2MQTT is running on so I am pretty sure that is what that is (i.e they are the zibee2mqtt nodes). The DVES units disconnecting is possibly down to power cuts / outages / reboots. (I have connected them to another instance of Mosquitto I have running and they stay stable. I have reconnected them back to the original instance and again, so far, they are stable). Client mqtt-explorer is MQTT Explorer.
I have been doing some experiments and there are node disconnections and reconnections when a full Deploy is carried out.
1593883268: New client connected from 192.168.1.30 as DVES_E15D05 (c1, k30, u'j$
1593883290: New connection from 192.168.1.31 on port 1883.
1593883290: New client connected from 192.168.1.31 as DVES_7556B9 (c1, k30, u'j$
1593883311: New connection from 192.168.1.32 on port 1883.
1593883311: New client connected from 192.168.1.32 as DVES_C847DA (c1, k30, u'j$
1593883333: New connection from 192.168.1.36 on port 1883.
1593883333: New client connected from 192.168.1.36 as DVES_FBFEA4 (c1, k30, u'j$
1593884488: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1593884946: Client mqtt-explorer-a1a87eac disconnected.
1593885249: Client mqtt_e0f5c38.579854 disconnected.
1593885250: New connection from 192.168.1.21 on port 1883.
1593885250: New connection from 192.168.1.21 on port 1883.
1593885250: Client NodeRed-389a8ae8.055bd6 disconnected.
1593885250: New client connected from 192.168.1.21 as NodeRed-389a8ae8.055bd6 ($
1593885250: New client connected from 192.168.1.21 as mqtt_a40eba6.3b0c148 (c1,$
1593885251: New connection from 192.168.1.21 on port 1883.
1593885251: New client connected from 192.168.1.21 as NodeRed-389a8ae8.055bd6-t$
1593885251: Socket error on client NodeRed-389a8ae8.055bd6-tmp, disconnecting.
1593885372: New connection from 192.168.1.20 on port 1883.
The first reconnections are where I reconnected the Sonoff devices back to this instance of Mosquitto, the rest is reconnecting nodes in Node-Red and then Deploying them.
The status of the MQTT Node was showing correctly for a while until I carried out the Deploy.
The Time field of the Mosquitto log is (I assume) the time running as as a date it is sometime in 1970 so this is no help in tracking an entry.
I would like to thank everyone for their interest because I do not have a clue. Fortunately the lack of a correct status is having no effect on the transmission & reception of MQTT data.
What do you see if you use a status node linked to the mqtt node?
Can I just check, when you say the MQTT In node is not showing the status correctly, you do mean one of the standard MQTT nodes don't you?
In case this runs into a dead end, you might want to take a look at Zigbee2MqttAssistant (https://github.com/yllibed/Zigbee2MqttAssistant) for managing the connections and using regular mqtt nodes for the data.
Just thought that I would mention that at the moment the problem seems to have gone away. I updated the Node-Red instance to 1.1 and so far the MQTT Node shows Connected after each 'Deploy'