question

philippe avatar image
philippe asked

MQTT implementation

I have implemented a script on my Venus GX to keep my modem alive and running fine.
I extended the script by reporting the consumed data to MQTT (and by extension VRM) as data consumption goes beyond normal VRM data usage (approx 6 GB a month).

This should be straight forward based on dbus-mqqt (https://github.com/victronenergy/dbus-mqtt), but I got stuck on the line "import paho.mqqt.client". I tried different syntaxes but always the same error.

root@beaglebone:~# python /data/bearbendum/netgear_status_data.py
Traceback (most recent call last):
  File "/data/bearbendum/netgear_status_data.py", line 22, in <module>
    from paho.mqtt import Client
ImportError: No module named paho.mqtt
root@beaglebone:~#

Here is the extract from the code

#!/usr/bin/env python

import paho.mqtt.client as mqtt

           mqttc = mqtt.Client("")
           mqttc.connect("localhost", 1883)
           mqttc.publish("modem/billing_data", str(billing_data))
         

So i run out of ideas how to fix.

Thanks.

Venus OSModbus TCPMQTT
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.

Justin Cook avatar image Justin Cook ♦♦ commented ·

Moved to "Modifications Space" for non-supported systems and to bring to the attention of other owners working with similar systems who may be able to assist.

0 Likes 0 ·
1 Answer
rodgerd avatar image
rodgerd answered ·

The paho python modules are not on your path. i.e. in the python site-packages or similar location. On my CCGX they are in /opt/victronenergy/dbus-mqtt/ and /opt/victronenergy/mqtt-rpc

You can add one of these locations to your sys.path and then do the import.

e.g.

import sys
sys.path.append('/opt/victronenergy/dbus-mqtt/')
from paho.mqtt import client as mqtt

There are other ways to do this e.g. the PYTHONPATH environment variable or the .pth file...


2 |3000

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