question

derrick thomas avatar image
derrick thomas asked

need quick help with mqtt

I have enabled the mqtt broker on the cerbo, and I can successfully publish a value to dbus. I use this to sync the bms (Daly) SOC with the victron smart shunt SOC, because Daly is not very accurate and drifts pretty quickly. There are some other values that I would like to pull from dbus to use in my node red dashboard, but after several days of scouring threads and internet searches I have had no success subscribing to topics.

I can successfully publish the bms soc using mqtt out with the topic W/xxxxxxx/battery/1/Settings/ResetSoc, but when I try to subscribe using mqqt in and the topic N/xxxxxx/battery/1/Settings/ResetSoc or R/xxxxxx/battery/1/Settings/ResetSoc I get no response. I have tried to subscribe to several other topics as well and get no response. If I publish to a topic of "test" or whatever you want to put in there, and subscribe to the same topic I get a response back every time I publish a value.

I'm sure I'm missing something simple but I just cant figure it out. Ive spent days on this before coming here to bother you'all. Help?

MQTT
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

3 Answers
satmaster200 avatar image
satmaster200 answered ·

Did you think of the "keep alive" venus mqtt needs to keep sending data?


https://github.com/victronenergy/dbus-mqtt#keep-alive


bildschirmfoto-2023-06-05-um-190707.png


My inject node sends a keep alive every 5 minutes. You might want to reduce this value to 1 minute, because every "keep alive" keeps venus mqtt alive for aprox. 1 minute.


Here is my flow to copy to your system. make sure to replace the XXXXXX to your venus Mac-Adress and make sure to change your venus IP-Adress in the MQTT node as well (mine is: 192.168.1.120)


[{"id":"74a4a7dd3e2d176a","type":"mqtt in","z":"d7073b3d536a1113","name":"","topic":"N/XXXXXXXXXXXX/system/0/Dc/Battery/Voltage/#","qos":"2","datatype":"auto-detect","broker":"f668d7764587acb0","nl":false,"rap":true,"rh":0,"inputs":0,"x":270,"y":2840,"wires":[["27db869d00046a54"]]},{"id":"a41c7bc5fa4c4bc7","type":"inject","z":"d7073b3d536a1113","name":"system/0/Dc/Battery/Voltage","props":[{"p":"payload"}],"repeat":"300","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"[\"system/0/Dc/Battery/Voltage\"]","payloadType":"str","x":230,"y":2740,"wires":[["38575f747f9f7136"]]},{"id":"38575f747f9f7136","type":"mqtt out","z":"d7073b3d536a1113","name":"","topic":"R/XXXXXXXXXXXX/keepalive","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"f668d7764587acb0","x":540,"y":2740,"wires":[]},{"id":"27db869d00046a54","type":"debug","z":"d7073b3d536a1113","name":"debug 50","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":560,"y":2840,"wires":[]},{"id":"f668d7764587acb0","type":"mqtt-broker","name":"Venus.os","broker":"192.168.1.120","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]


bildschirmfoto-2023-06-05-um-191325.png

bildschirmfoto-2023-06-05-um-191502.png


good luck!



2 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

arminf avatar image arminf commented ·
Tx, this worked for me.


What helped me: Copy the code above to my own Node Red and study what goes where. I never got my code working because I was sloppy with the MQTT paths to the objects, and with what had to go into Topic vs Payload.

0 Likes 0 ·
arminf avatar image arminf commented ·
One question remains: Why does everybody here and in other posts inject their own keepalive message - is the field in the form above without function? I understand it as "Set your keepalive here!".
0 Likes 0 ·
derrick thomas avatar image
derrick thomas answered ·

I did finally figure that part out but I'm only getting messages at the interval set in the inject node. I shortened it to 1 minute and even less. I'm not getting any messages at all between the interval but I can see constant updates on the dbus using dbus-spy. Right now I've got the inject node set to 5 second interval.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

satmaster200 avatar image
satmaster200 answered ·

I get messages for one minute, as soon (or as often) as a value is changing.

bildschirmfoto-2023-06-05-um-221808.png

Perhaps the "Battery Voltage" (as in my example) is not ideal, as it might not change that often, if the battery is just sitting there. SOC might also not be an ideal value to test against, but you can swap with any other Modbus register, List here: https://www.victronenergy.com/upload/documents/CCGX-Modbus-TCP-register-list-2.90.xlsx


cheers Satmaster


2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Related Resources