VictronGX_Custom_Sensors/README.md

3.1 KiB

VictronGX_Custom_Sensors

Add custom sensors via Node-Red instance included in Venus OS Large to my Cerbo GX Venus OS.

Node RED

I gather data from my heating control system, my energy meter (SDM630 Modbus) connected to one of my PLCs via Node RED and exported it via HTTP JSON API, see my flows under /NodeRED.

You can gather data from all available sources via Node RED easily, just export it via JSON HTTP and modify these python files, to grep JSON and push it to the DBUS daemon.

On victrons github pages there is documentation which formats and servicenames dbus is accepting and how it will display it on Venus' visualization and VRM portal.

Thoughts

It is not a perfect or efficient solution, but I want data gathering on Node Red and use only a exisiting python script to push it to Venus OS' infrastructure, because I am not an experienced python programmer, of course you can gather data directly with python.

dbus-node-red-XXX Service files

Configuration

In the Python file, you should put your data points you exported with Node-RED via JSON API.

Installation

  1. Copy the files and folders to the /data folder on your venus device:

    • /data/dbus-node-red-XXX/temp_XXX.py
    • /data/dbus-node-red-XXX/meter_XXX.py
    • /data/dbus-node-red-XXX/service/run
  2. Set executeable permissions for service file:

    chmod +x /data/dbus-node-red-XXX/service/run

  3. Add a symlink to the file /data/rc.local to start it at boot time:

    ln -s /data/dbus-node-red-XXX/service /service/dbus-node-red-XXX

    Service manager of Venus OS will start the script immediately if you run above in terminal. If you want to start it at boot time, create or append above to your /data/rc.local

    If you just created rc.local, set it executeable with

    chmod +x /data/rc.local

Debugging

You can check the status of the service with svstat:

svstat /service/dbus-node-red-temp-outside

It will show something like this:

/service/dbus-node-red-temp-outside: up (pid 1442) 406 seconds

If the number of seconds is always 0 or 1 or any other small number, it means that the service crashes and gets restarted all the time.

When you think that the script crashes, start it directly from the command line:

python /data/dbus-node-red-XXX/temp-XXX.py or /data/dbus-node-red-XXX/service/run

and see if it throws any error messages.

If the script stops with the message

dbus.exceptions.NameExistsException: Bus name already exists: com.victronenergy.SERVICENAME"

it means that the service is still running or another service is using that bus name.

Loggings

My scripts generate a logfile in working directory which you can check, every 10 min there will be a status message, with actual values and so on.

Restart the script

If you want to restart the script, for example after changing it, kill running script

The daemon-tools will restart the scriptwithin a few seconds.

Sources

Used https://github.com/victronenergy/velib_python/blob/master/dbusdummyservice.py as basis for my custom services. DBus service descriptor are located at https://github.com/victronenergy/venus/wiki/dbus