MQTT Broker Status with Nodered to PAC Control

Here is a short and simple way to know the status of your MQTT Broker (Server) from within PAC Control.


NodeRed checks the status and sends it to an integer variable in the strategy.

You need to install the node 'node-red-contrib-mqtt-connection-check '. (pancake icon / manage palette / install tab). My implementation only sends the .connected status to the strategy. You could also include the .code value to provide a bit more information to the strategy.

My strategy has only one thing in it, the integer32 variable called ‘BrokerStatus’. So I have not attached it.

Here is more detail from the node’s info:
Standard output:
mqttCheck object -An object that contains the result of the check
mqttCheck.connected boolean - True if the node connected successfully to the broker, false otherwise.
mqttCheck.code number - If available, it shows the returned code that indicates the connection status. e.g. 0 for success, 5 for unauthorized.
payload - The same payload that gets in will get out.

Nodered Flow:
[{"id":"3f0c701b.d1d51","type":"inject","z":"df630825.d6b4d8","name":"Check 1 second","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":120,"wires":[["4bcacb49.29d124"]]},{"id":"ef97f33b.5bf22","type":"debug","z":"df630825.d6b4d8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":610,"y":80,"wires":[]},{"id":"6451b56a.306abc","type":"pac-write","z":"df630825.d6b4d8","device":"12030ac3.3a560d","dataType":"int32-variable","tagName":"BrokerStatus","tableStartIndex":"","value":"mqttCheck.connected","valueType":"msg","name":"Send Status to PAC","x":650,"y":120,"wires":[[]]},{"id":"4bcacb49.29d124","type":"mqtt-check","z":"df630825.d6b4d8","host":"chariot.groov.com","port":"1883","username":"opto","password":"opto22","name":"Check Chariot Broker","x":400,"y":120,"wires":[["ef97f33b.5bf22","6451b56a.306abc"]]},{"id":"249863f6.7f218c","type":"comment","z":"df630825.d6b4d8","name":"Check MQTT Broker status and Send to PAC Control variable","info":"","x":280,"y":60,"wires":[]},{"id":"12030ac3.3a560d","type":"pac-device","z":"","address":"localhost","protocol":"https"}]

2 Likes