{"id":845,"date":"2023-05-18T13:30:28","date_gmt":"2023-05-18T11:30:28","guid":{"rendered":"https:\/\/spoton.cz\/?p=845"},"modified":"2023-05-18T13:30:30","modified_gmt":"2023-05-18T11:30:30","slug":"victron-venus-gx-and-how-to-get-data-from-it-locally","status":"publish","type":"post","link":"https:\/\/spoton.cz\/index.php\/2023\/05\/18\/victron-venus-gx-and-how-to-get-data-from-it-locally\/","title":{"rendered":"Victron Venus GX and how to get data from it locally"},"content":{"rendered":"\n<p>I was struggling for quite some time with how to get the statistical and realtime data from a victron Venus GX control block. Everything connects to it and so it should know about all the numbers that all the devices push to it. <\/p>\n\n\n\n<p>Luckily, there is quite a simple solution I was not aware of. Tons of documentation and quite easy to set up.<\/p>\n\n\n\n<p>Here&#8217;s what you will need:<\/p>\n\n\n\n<ul><li>Linux computer in the same network<\/li><li>Port 1883 open between you linux server and the Venus system<\/li><li>mosquitto, maybe other compatible mqqt broker<\/li><li>telegraf data acquisition suite<\/li><li>influx database (or any other) to store the data<\/li><\/ul>\n\n\n\n<h2>Linux system setup<\/h2>\n\n\n\n<p>First, we need a Linux server that will be the mqtt broker to receive the data from the Venus GX. I will use a Arch Linux installation, as I like the distribution quite a lot. There are some extra steps to consider for this distro though. <\/p>\n\n\n\n<p>As part of the installation, you&#8217;ll need to install a helper, such as yay! to take advantage of the AUR packages and easy installation. You&#8217;ll need a couple things to get you started.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># get the yay git cloned, getting the sources\ngit clone https:\/\/aur.archlinux.org\/yay-git.git\ncd yay-git\/\n# next line requires packages: make, fakeroot, gcc. Install them with sudo pacman -S make fakeroot gcc\n# Make the package and install it\nmakepkg -si<\/pre>\n\n\n\n<p>Next on the list is to make the telegraf suite run on the server. Now telegraf is present in the AUR, so after a successful installation of yay, this should be a breeze. Of course, you can install it from git as well. This package is not present in the standard Arch repositories<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\n# install the suite from AUR\nyay -S aur\/telegraf-bin\nsudo systemctl enable telegraf\n# don't forget to install the mosquitto package\nsudo pacman -S mosquitto\nsudo pacman -Ss mosquitto\ncommunity\/mosquitto 2.0.15-2 [installed]\n    An Open Source MQTT Broker\n\n\n<\/pre>\n\n\n\n<h2>Setup of Victron Venus GX<\/h2>\n\n\n\n<p>MQTT service is not enabled on the Victron device by default. Let&#8217;s quickly navigate the right place to enable it:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"808\" height=\"349\" src=\"https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image.png\" alt=\"\" class=\"wp-image-846\" srcset=\"https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image.png 808w, https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-300x130.png 300w, https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-768x332.png 768w, https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-480x207.png 480w\" sizes=\"(max-width: 808px) 100vw, 808px\" \/><\/figure>\n\n\n\n<p>Click anywhere into the overview to get a menu<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"814\" height=\"343\" src=\"https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-1.png\" alt=\"\" class=\"wp-image-847\" srcset=\"https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-1.png 814w, https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-1-300x126.png 300w, https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-1-768x324.png 768w, https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-1-480x202.png 480w\" sizes=\"(max-width: 814px) 100vw, 814px\" \/><\/figure>\n\n\n\n<p>Go to Settings<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"816\" height=\"341\" src=\"https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-2.png\" alt=\"\" class=\"wp-image-848\" srcset=\"https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-2.png 816w, https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-2-300x125.png 300w, https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-2-768x321.png 768w, https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-2-480x201.png 480w\" sizes=\"(max-width: 816px) 100vw, 816px\" \/><\/figure>\n\n\n\n<p>In Settings, find services, second to last from the bottom<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"800\" height=\"328\" src=\"https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-3.png\" alt=\"\" class=\"wp-image-849\" srcset=\"https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-3.png 800w, https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-3-300x123.png 300w, https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-3-768x315.png 768w, https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-3-480x197.png 480w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p>Enable SSL MQTT. If on local network only, you can enable the plaintext MQTT as well. Otherwise I&#8217;d discourage from this. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"806\" height=\"335\" src=\"https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-4.png\" alt=\"\" class=\"wp-image-850\" srcset=\"https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-4.png 806w, https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-4-300x125.png 300w, https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-4-768x319.png 768w, https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-4-480x200.png 480w\" sizes=\"(max-width: 806px) 100vw, 806px\" \/><\/figure>\n\n\n\n<p>There you go, you just enabled the MQTT services for the Victron GX.<\/p>\n\n\n\n<h2>Testing the connection and evironment details<\/h2>\n\n\n\n<p>Now, with the MQTT service enabled on the Victron Venus GX and the mosquitto package installed on the Linux system and these two being on the same network, let&#8217;s test it out. -v is verbous -I is the client name prefix, choose whatever you want, -h is the host and -p is port. -t is the transmit message.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># In short, this will just subscribe (read) all the output from the MQTT from that particular IP address, # being the wildcard in MQTT. \n\nmosquitto_sub -I myclient_ -v -h 192.168.1.104 -p 1883 -t '#'\n\n# The result here:\n\nN\/38d26970ba3a\/system\/0\/Ac\/ConsumptionOnOutput\/L1\/Current {\"value\": 0.9200000166893005}\nN\/38d26970ba3a\/system\/0\/Ac\/Consumption\/L1\/Power {\"value\": 204}\nN\/38d26970ba3a\/system\/0\/Ac\/Consumption\/L1\/Current {\"value\": 0.9200000166893005}\nN\/38d26970ba3a\/system\/0\/Dc\/Vebus\/Current {\"value\": -4.099999904632568}\nN\/38d26970ba3a\/system\/0\/Dc\/Vebus\/Power {\"value\": -204}\nN\/38d26970ba3a\/system\/0\/Batteries {\"value\": [{\"id\": \"com.victronenergy.battery.socketcan_can1\", \"temperature\": 27.799999237060547, \"power\": 79, \"current\": 1.600000023841858, \"soc\": 52, \"active_battery_service\": true, \"instance\": 512, \"state\": 1, \"name\": \"Pylontech battery\", \"voltage\": 49.45000076293945}]}\n<\/pre>\n\n\n\n<p>All you need to do is find the proper metrics you want to monitor, for example the voltage of battery:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mosquitto_sub -I myclient_ -v -h 192.168.1.104 -p 1883 -t 'N\/+\/system\/0\/Dc\/Battery\/Voltage'\n\n# and the result\nN\/38d26970ba3a\/system\/0\/Dc\/Battery\/Voltage {\"value\": 49.13999938964844}\nN\/38d26970ba3a\/system\/0\/Dc\/Battery\/Voltage {\"value\": 49.130001068115234}\nN\/38d26970ba3a\/system\/0\/Dc\/Battery\/Voltage {\"value\": 49.099998474121094}\nN\/38d26970ba3a\/system\/0\/Dc\/Battery\/Voltage {\"value\": 49.09000015258789}\nN\/38d26970ba3a\/system\/0\/Dc\/Battery\/Voltage {\"value\": 49.08000183105469}\n\n# or using wildcards\nmosquitto_sub -I victron_ -v -h 192.168.1.104 -p 1883 -t 'N\/+\/+\/+\/+\/Battery\/+'\n\n# result\nN\/38d26970ba3a\/system\/0\/Dc\/Battery\/BatteryService {\"value\": \"com.victronenergy.battery.socketcan_can1\"}\nN\/38d26970ba3a\/system\/0\/Dc\/Battery\/ConsumedAmphours {\"value\": null}\nN\/38d26970ba3a\/system\/0\/Dc\/Battery\/Current {\"value\": 2.0}\nN\/38d26970ba3a\/system\/0\/Dc\/Battery\/Power {\"value\": 98}\nN\/38d26970ba3a\/system\/0\/Dc\/Battery\/ProductId {\"value\": 45065}\nN\/38d26970ba3a\/system\/0\/Dc\/Battery\/Soc {\"value\": 52}\nN\/38d26970ba3a\/system\/0\/Dc\/Battery\/State {\"value\": 1}\nN\/38d26970ba3a\/system\/0\/Dc\/Battery\/Temperature {\"value\": 27.799999237060547}\nN\/38d26970ba3a\/system\/0\/Dc\/Battery\/TemperatureService {\"value\": \"com.victronenergy.battery.socketcan_can1\"}\nN\/38d26970ba3a\/system\/0\/Dc\/Battery\/TimeToGo {\"value\": null}\nN\/38d26970ba3a\/system\/0\/Dc\/Battery\/Voltage {\"value\": 49.459999084472656}\nN\/38d26970ba3a\/system\/0\/Dc\/Battery\/VoltageService {\"value\": \"com.victronenergy.battery.socketcan_can1\"}\nN\/38d26970ba3a\/system\/0\/Dc\/Battery\/Current {\"value\": 1.899999976158142}\nN\/38d26970ba3a\/system\/0\/Dc\/Battery\/Power {\"value\": 93}\nN\/38d26970ba3a\/system\/0\/Dc\/Battery\/Current {\"value\": 2.0}\nN\/38d26970ba3a\/system\/0\/Dc\/Battery\/Power {\"value\": 98}\nN\/38d26970ba3a\/system\/0\/Dc\/Battery\/Current {\"value\": 1.899999976158142}\nN\/38d26970ba3a\/system\/0\/Dc\/Battery\/Power {\"value\": 93}\nN\/38d26970ba3a\/system\/0\/Dc\/Battery\/Current {\"value\": 2.0}\nN\/38d26970ba3a\/system\/0\/Dc\/Battery\/Power {\"value\": 98}\n<\/pre>\n\n\n\n<p>There is one little caveat to this. The information relayed, does end after a certain period of time (found 5 minutes). This can be avoided by opening another window and sending a keepalive signal to keep the stream flowing. <strong>Please note the mosquitto_pub and not mosquitto_sub<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mosquitto_pub  -h 192.168.1.104 -m '' -t 'R\/38d26970ba3a\/keepalive'<\/pre>\n\n\n\n<p>I recommend putting this command into the crontab of the Linux server:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># Either with crontab -e\n*\/5 * * * * mosquitto_pub -h 192.168.1.104 -m '' -t 'R\/38d26970ba3a\/keepalive'\n\n# Or a one-liner to add the line to crontab\n(crontab -l 2>\/dev\/null; echo \"*\/5 * * * * mosquitto_pub -h 192.168.1.104 -m '' -t 'R\/38d26970ba3a\/keepalive'\") | crontab -<\/pre>\n\n\n\n<h2>Configure the automated data acquisition via telegraf<\/h2>\n\n\n\n<p>Now to configure the mqqt consumer module of telegraf. The config files are located under \/etc\/telegraf\/telegraf.d and we make a new file here, called input.mqtt or whatever you wish it to be called, with this content. Keep in mind, this is the setup for my installation. You can look up your <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[[inputs.mqtt_consumer]]\n  servers = [\"tcp:\/\/192.168.1.104:1883\"]\n  topics = [\"N\/+\/vebus\/+\/Ac\/Out\/P\", \"N\/+\/system\/0\/Batteries\",\"N\/+\/vebus\/+\/Ac\/ActiveIn\/P\",\"N\/+\/solarcharger\/+\/Yield\/Power\n\",\"N\/+\/system\/0\/Dc\/Battery\/Voltage\"]\n  data_format = \"json\"\n\n#[[inputs.mqtt_consumer.topic_parsing]]\n#  topic = \"\/38d26970ba3a\/system\/0\/Dc\/Battery\/Voltage\"\n#  measurement = \"\/measurement\/_\/_\/_\/_\/_\"\n#  tags = \"\/id\/_\/_\/type\/_\/_\"\n#  fields = \"\/_\/_\/_\/_\/_\/volts\" <\/pre>\n\n\n\n<p>The load into a database is not really part of this short article, but just for the sake of information, consider this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@archfiler ~]# cat \/etc\/telegraf\/telegraf.d\/output.influx.conf \n[[outputs.influxdb]]\n  urls = [\"http:\/\/influxdb-telegraf\"]\n  database = \"telegraf\"\n  # retention_policy = \"\"\n\n  ## Write consistency (clusters only), can be: \"any\", \"one\", \"quorum\", \"all\".\n  ## Only takes effect when using HTTP.\n  # write_consistency = \"any\"\n\n  ## Timeout for HTTP messages.\n  timeout = \"20s\"\n<\/pre>\n\n\n\n<p>And then a grafana configured display of these values over time:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"597\" src=\"https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-5-1024x597.png\" alt=\"\" class=\"wp-image-852\" srcset=\"https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-5-1024x597.png 1024w, https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-5-300x175.png 300w, https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-5-768x448.png 768w, https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-5-480x280.png 480w, https:\/\/spoton.cz\/wp-content\/uploads\/2023\/05\/image-5.png 1526w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Pretty simple, or? Let me know in the comments. <\/p>\n\n\n\n<p>Cheers. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was struggling for quite some time with how to get the statistical and realtime data from a victron Venus [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":853,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,4,5,8,9],"tags":[23,124,122,125,123,121],"_links":{"self":[{"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/posts\/845"}],"collection":[{"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/comments?post=845"}],"version-history":[{"count":2,"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/posts\/845\/revisions"}],"predecessor-version":[{"id":854,"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/posts\/845\/revisions\/854"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/media\/853"}],"wp:attachment":[{"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/media?parent=845"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/categories?post=845"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/tags?post=845"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}