question

paulm avatar image
paulm asked

Struggling with local access to MQTT data

I have a simple home solar PV system - 2 panels, MPPT 100/20 charger, AGM batteries & Phoenix 24/800 inverter. It's up and running and I've added a Raspberry Pi 3 running Venus OS, connected to the two Victron devices with VE.Direct USB cables. I can connect to the Venus system with a browser and can see the devices data fine. I can connect using the VRM portal and can also see the devices data fine.

I've enabled the Venus MQTT broker for SSL and PlainText and can connect to it from MQTT Explorer but all I see is the following :

mqttexplorer.png

I know there is a 'keepalive' requirement I've seen discussed in the forums, but as I understand it the Venus MQTT broker is enabled when accessed from the VRM portal and should be accessible from the LAN when that happens.

My problem at present is I cannot see any data from the two victron devices in MQTT Explorer. I assume I've missed something, but trawled the forums for a while and cannot see what it is ??

My aim is to bridge the central MQTT broker in my existing home automation system to the Venus MQTT broker so I can add the Victron data into my home automation database (InfluxDB) and display it, along with other data, using Grafana.

I've spent hours reading forums posts etc. but cannot see where I've gone wrong. It would be much appreciated if someone could give some guidance as to how I can achieve my aim of adding the Venus MQTT data into my existing home automation system, with the 'keepalive' function and without using the VRM portal. I have no need to se the VRM portal as I have already have VPN access to my existing system, so will be able to see the PV data when added into the system.

Regards

PaulM


Venus OSMQTT
mqttexplorer.png (92.1 KiB)
2 |3000

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

2 Answers
paulm avatar image
paulm answered ·

Solved this one myself ....

The Venus MQTT broker is locally accessible all the time but only publishes it's ID in the data topic.

Contrary to what I read in the forums accessing my system through the VRM portal does not wake up or keep alive the data side of the Venus MQTT broker no matter what data is displayed through the VRM portal. The only way I found to publish any data locally from the Venus MQTT server is to send it a 'keep alive' message which I failed to manage to do through the MQTT Explorer program, probably due to lack of experience.

I ended up running this python script on my desktop PC :

import paho.mqtt.client as mqtt             # MQTT support

mqttBroker ="victronpi"                     # define MQTT broker address
client = mqtt.Client("KeepAlive")           # identify client
client.connect(mqttBroker)                  # connect to broker
print("VictronPi MQTT broker connected...")

client.publish("R/b123abc12345/keepalive")  # send 'keepalive' message
print("VictronPi KeepAlive sent)

... and the victron data instantly appeared in the MQTT Explorer app. As explained in the Victron docs the data times out after 60 seconds and vanishes, so the 'keepalive' has to be repeated to keep updating the data. NOTE - you will need to edit your ID into the 'client.publish...' statement.

PaulM


2 |3000

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

nasha avatar image
nasha answered ·

Hi,

To send the 'keep alive' single in MQTT Explorer enter 'R/<Serial Number>/keepalive' into the Publish section and push the 'Publish' Button.... you'll then see the latest data... which will then disappear after a few seconds...

1663150487138.png


--Andy



1663150487138.png (355.9 KiB)
1 comment
2 |3000

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

marceldb avatar image marceldb commented ·

Thank you, that works... for a minute or so. Can you tell me how it keeps alive forever?

Thanks!

0 Likes 0 ·

Related Resources