Skip to content

This Venus OS driver gets the data from MQTT and displays it as grid meter.

License

Notifications You must be signed in to change notification settings

m3h7/venus-os_dbus-mqtt-grid

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dbus-mqtt-grid - Emulates a physical Grid Meter from MQTT data

GitHub repository: mr-manuel/venus-os_dbus-mqtt-grid

Disclaimer

I wrote this script for myself. I'm not responsible, if you damage something using my script.

Purpose

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.

Config

Copy or rename the config.sample.ini to config.ini in the dbus-mqtt-grid folder and change it as you need it.

JSON structure

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,
        }
    }
}

Install

  1. Copy the dbus-mqtt-grid folder to /data/etc on your Venus OS device

  2. Run bash /data/etc/dbus-mqtt-grid/install.sh as root

    The daemon-tools should start this service automatically within seconds.

Uninstall

Run /data/etc/dbus-mqtt-grid/uninstall.sh

Restart

Run /data/etc/dbus-mqtt-grid/restart.sh

Debugging

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.

Multiple instances

It's possible to have multiple instances, but it's not automated. Follow these steps to achieve this:

  1. Save the new name to a variable driverclone=dbus-mqtt-grid-2

  2. Copy current folder cp -r /data/etc/dbus-mqtt-grid/ /data/etc/$driverclone/

  3. Rename the main script mv /data/etc/$driverclone/dbus-mqtt-grid.py /data/etc/$driverclone/$driverclone.py

  4. 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
    
  5. Change the device_name and increase the device_instance in the config.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.

Compatibility

It was tested on Venus OS Large v2.92 on the following devices:

  • RaspberryPi 4b
  • MultiPlus II (GX Version)

Screenshots

Power and/or L1

Grid power L1 - pages Grid power L1 - device list Grid power L1 - device list - mqtt grid 1 Grid power L1 - device list - mqtt grid 2

Power, L1 and L2

Grid power L1, L2 - pages Grid power L1, L2 - device list Grid power L1, L2 - device list - mqtt grid 1 Grid power L1, L2 - device list - mqtt grid 2

Power, L1, L2 and L3

Grid power L1, L2, L3 - pages Grid power L1, L2, L3 - device list Grid power L1, L2, L3 - device list - mqtt grid 1 Grid power L1, L2, L3 - device list - mqtt grid 2

Supporting/Sponsoring this project

You like the project and you want to support me?

About

This Venus OS driver gets the data from MQTT and displays it as grid meter.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 96.6%
  • Shell 3.4%