GitHub repository: mr-manuel/venus-os_dbus-mqtt-grid
I wrote this script for myself. I'm not responsible, if you damage something using my script.
The script emulates a physical Grid Meter in Venus OS. It gets the MQTT data from a subscribed topic and publishes the information on the dbus as the service com.victronenergy.grid.mqtt_grid
with the VRM instance 31
.
Copy or rename the config.sample.ini
to config.ini
in the dbus-mqtt-grid
folder and change it as you need it.
Minimum required
{
"grid": {
"power": 0.0
}
}
Minimum required with L1
{
"grid": {
"power": 0.0,
"L1": {
"power": 0.0
}
}
}
Minimum required with L1, L2
{
"grid": {
"power": 0.0,
"L1": {
"power": 0.0
},
"L2": {
"power": 0.0
}
}
}
Minimum required with L1, L2, L3
{
"grid": {
"power": 0.0,
"L1": {
"power": 0.0
},
"L2": {
"power": 0.0
},
"L3": {
"power": 0.0
}
}
}
Full
{
"grid": {
"power": 0.0,
"voltage": 0.0,
"current": 0.0,
"energy_forward": 0.0,
"energy_reverse": 0.0,
"L1": {
"power": 0.0,
"voltage": 0.0,
"current": 0.0,
"energy_forward": 0.0,
"energy_reverse": 0.0,
},
"L2": {
"power": 0.0,
"voltage": 0.0,
"current": 0.0,
"energy_forward": 0.0,
"energy_reverse": 0.0,
},
"L3": {
"power": 0.0,
"voltage": 0.0,
"current": 0.0,
"energy_forward": 0.0,
"energy_reverse": 0.0,
}
}
}
-
Copy the
dbus-mqtt-grid
folder to/data/etc
on your Venus OS device -
Run
bash /data/etc/dbus-mqtt-grid/install.sh
as rootThe daemon-tools should start this service automatically within seconds.
Run /data/etc/dbus-mqtt-grid/uninstall.sh
Run /data/etc/dbus-mqtt-grid/restart.sh
The logs can be checked with tail -n 100 -f /data/log/dbus-mqtt-grid/current | tai64nlocal
The service status can be checked with svstat svstat /service/dbus-mqtt-grid
This will output somethink like /service/dbus-mqtt-grid: up (pid 5845) 185 seconds
If the seconds are under 5 then the service crashes and gets restarted all the time. If you do not see anything in the logs you can increase the log level in /data/etc/dbus-mqtt-grid/dbus-mqtt-grid.py
by changing level=logging.WARNING
to level=logging.INFO
or level=logging.DEBUG
If the script stops with the message dbus.exceptions.NameExistsException: Bus name already exists: com.victronenergy.grid.mqtt_grid"
it means that the service is still running or another service is using that bus name.
It's possible to have multiple instances, but it's not automated. Follow these steps to achieve this:
-
Save the new name to a variable
driverclone=dbus-mqtt-grid-2
-
Copy current folder
cp -r /data/etc/dbus-mqtt-grid/ /data/etc/$driverclone/
-
Rename the main script
mv /data/etc/$driverclone/dbus-mqtt-grid.py /data/etc/$driverclone/$driverclone.py
-
Fix the script references for service and log
sed -i 's:dbus-mqtt-grid:'$driverclone':g' /data/etc/$driverclone/service/run sed -i 's:dbus-mqtt-grid:'$driverclone':g' /data/etc/$driverclone/service/log/run
-
Change the
device_name
and increase thedevice_instance
in theconfig.ini
Now you can install and run the cloned driver. Should you need another instance just increase the number in step 1 and repeat all steps.
It was tested on Venus OS Large v2.92
on the following devices:
- RaspberryPi 4b
- MultiPlus II (GX Version)
You like the project and you want to support me?