Victron Node-Red instance ... does anybody know how to use MQTT Broker?

Hi all,

I am using a Victron Cerbo device with integrated Node-Red instance (Venus OS Large).
There is an integrated MQTT broker that works basically fine - I get all messages from Victron into my Node-Red instance using the prepared nodes.

BUT ... I want to send additional MQTT messages to this Cerbo MQTT broker but whatever I configure ... they to not show up if I check the broker with MQTT explorer.
I tried different ports, username, QoS .... everything ... but still no message visible.

Does anybody know this issue and a possible workaround for it ?

BR
Gawan

So sorry, explain to me (aka us) what configuration you have in the MQTT nodes in Node-Red that receive the messages?

eg: the IP address, the topic.

Because - all here after as an example:
You set up the broker's details in NR as:
192.168.0.1
Then you put a MQTT IN node and set that as the broker.
You then enter example in the topic and you receive data. What ever that is.

So, you then get a MQTT OUT node, set it up with the broker - as before.
Set it's topic to another_example and stick an inject node to that node.

Next, you get a MQTT IN node, set it to the broker and set it's topic to another_example.
Connect a debug node to it.

DEPLOY it and then press the inject node, you should see the debug node display a timestamp message each time you press the inject node.

Hi @Gawan

I have a Victron Multiplus II. Using the onboard MQTT works, but there are a great many complications. You cannot connect it to your own broker, and you have to send it keepalive messages or it will die.

I have had a lot more success using modbus to connect to it. You will need to install nodered-contrib-modbus.

On the Victron website, you will find a spreadsheet with all of the modbus codes for every single victron variable you can think of, and two way communication is supported.

Here is an example in practise:

[{"id":"84f6edcbee42578f","type":"modbus-read","z":"cd7ae4ff9ca97a6d","name":"Grid status","topic":"/site/nest/util/inverter/data/grid/status","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"showWarnings":true,"unitid":"242","dataType":"HoldingRegister","adr":"3","quantity":"1","rate":"5","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"b93afde3.dea82","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":460,"y":300,"wires":[["f9a6bed6fb53bb43"],[]]},{"id":"0852f6ea5fee1d22","type":"modbus-read","z":"cd7ae4ff9ca97a6d","name":"Battery level","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"showWarnings":true,"unitid":"242","dataType":"HoldingRegister","adr":"30","quantity":"1","rate":"5","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"b93afde3.dea82","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":460,"y":360,"wires":[["8ee9a46bd7d2488b"],[]]},{"id":"8ee9a46bd7d2488b","type":"function","z":"cd7ae4ff9ca97a6d","name":"Set Global Variables and MQTT topic","func":"var intmsg = parseInt(msg.payload)/10;\nmsg.payload = intmsg;\nmsg.topic = \"/site/nest/util/inverter/data/chargelevel/status\"\nglobal.set(\"BatteryCharge\", msg.payload);\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":750,"y":360,"wires":[["49ae1df0d1b9dcce"]]},{"id":"689b707d9f6f94e6","type":"modbus-read","z":"cd7ae4ff9ca97a6d","name":"Charging Mode","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"showWarnings":true,"unitid":"242","dataType":"HoldingRegister","adr":"31","quantity":"1","rate":"60","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"b93afde3.dea82","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":470,"y":420,"wires":[["d246934891c1cca8"],[]]},{"id":"f9a6bed6fb53bb43","type":"function","z":"cd7ae4ff9ca97a6d","name":"Set Global Variables and MQTT topic","func":"var intmsg = parseInt(msg.payload);\nif (intmsg > 2000) {\n    msg.payload = true;\n} else {\n    msg.payload = false;\n};\nglobal.set(\"GridStatus\", msg.payload);\nmsg.topic = \"/site/nest/util/inverter/data/grid/status\";\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":750,"y":300,"wires":[["49ae1df0d1b9dcce"]]},{"id":"d246934891c1cca8","type":"function","z":"cd7ae4ff9ca97a6d","name":"Set Global Variables and MQTT topic","func":"var intmsg = parseInt(msg.payload)/10;\nmsg.payload = intmsg;\nglobal.set(\"ChargeMode\", msg.payload);\nmsg.topic = \"/site/nest/util/inverter/data/chargemode/status/\"\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":750,"y":420,"wires":[["49ae1df0d1b9dcce"]]},{"id":"30117dd816aec682","type":"modbus-read","z":"cd7ae4ff9ca97a6d","name":"Solar yield","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"showWarnings":true,"unitid":"100","dataType":"HoldingRegister","adr":"850","quantity":"1","rate":"5","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"b93afde3.dea82","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":450,"y":480,"wires":[["3ee615d3e50f17d9"],[]]},{"id":"3ee615d3e50f17d9","type":"function","z":"cd7ae4ff9ca97a6d","name":"Set Global Variables and MQTT topic","func":"var intmsg = parseInt(msg.payload);\nmsg.payload = intmsg;\nglobal.set(\"SolarYield\", msg.payload);\nmsg.topic = \"/site/nest/util/inverter/data/solaryield/status/\";\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":770,"y":480,"wires":[["49ae1df0d1b9dcce"]]},{"id":"49ae1df0d1b9dcce","type":"mqtt out","z":"cd7ae4ff9ca97a6d","name":"","topic":"","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"","x":1120,"y":380,"wires":[]},{"id":"b93afde3.dea82","type":"modbus-client","name":"System","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"failureLogEnabled":false,"tcpHost":"192.168.1.32","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","serialAsciiResponseStartDelimiter":"","unit_id":"242","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true,"showErrors":false,"showWarnings":true,"showLogs":true}]

You can see that after we get the data from the modbus node, we can easily add a topic, even just with a Change node. I'm using that data elsewhere in other functions, so I push it to a global context as well.

After you have added a topic, you just send it to an MQTT out node to publish it, and then listen to your MQTT in accordingly.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.