VictronGX_Custom_Sensors/README.md

121 lines
5.2 KiB
Markdown
Raw Permalink Normal View History

2022-08-09 21:30:41 +02:00
# VictronGX_Custom_Sensors
2022-08-09 23:44:59 +02:00
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.
2023-06-11 01:04:46 +02:00
## Thoughts on Node RED service
2022-08-09 23:44:59 +02:00
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.
2023-06-11 01:04:46 +02:00
# Batrium Native CAN protocol support
I created a dbus python script to implement Batriums Native 1.0 (and 2.0 but there are mandatory items missing) protocol, to gather more informations in Victrons OS.
A forum user started some time ago the same approach but the script was outdated and lacking of some datapoints.
I try to integrate every datapoint from Batriums BMS to fill Victrons registers.
## What is working or improved against Victron default or Pylontech emulation
- faster update rate
- transfer of most alarms (instead of only voltage low alarm)
- number of cells balancing
- time to empty or full
2023-06-12 09:28:04 +02:00
- capacity used and total Ah discharged
- daily stats like kWh charged, discharged (calculated)
- time since last full charge
- correct transmitting of CVL (Stock implementation fixed with Batrium version 2.17.40.0 or downgrade to 2.17.27)
2023-06-11 01:04:46 +02:00
## What is not working, needs improvement
- capacity to full or to empty is not transmitted by Batrium (transmission of 0x00111900 is missing against documentation)
2023-06-12 09:28:04 +02:00
- Ah, kWh charged and discharged is calcualated by script (see above)
2023-06-11 01:04:46 +02:00
- Capacity of battery must be entered into script batrium.py (see above)
2023-08-08 23:36:53 +02:00
- <del>dbus script is started by rc.local which gets executed last, so all mppts and multiplus' showing temporarily "BMS missing" and need to be cleared after (re-)boot of Venus OS</del> fixed
2023-06-12 21:58:42 +02:00
- include calculation of State Of Health, based on Ah discharge and SoC State after full charge, because Batrium does not have
2023-06-11 01:04:46 +02:00
2022-08-09 23:44:59 +02:00
# 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`
2022-08-19 23:07:45 +02:00
3. Add a symlink to the file /data/rc.local to start it at boot time:
2022-08-09 23:44:59 +02:00
`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`
2023-06-11 01:04:46 +02:00
> **_Note:_** If you install batrium dbus script, you must install python can module, you can do it with 'requirements.sh" inside batrium-dbus folder
2022-08-09 23:44:59 +02:00
### 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.
2022-08-19 23:07:45 +02:00
### 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.
2022-08-19 23:07:45 +02:00
2023-06-24 13:01:13 +02:00
#### 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.
# Backup
You can insert a SD card with FAT32 filesystem, or a blank one and format it with the GX device itself.
Simply add to cron following command, to copy data folder with some exceptions for node-red node modules every day at 2 am
2022-08-09 23:44:59 +02:00
2023-06-24 13:01:13 +02:00
`crontab -e`
2022-08-09 23:44:59 +02:00
2023-06-24 13:01:13 +02:00
`0 2 * * * /usr/bin/rsync rsync -rlptD --progress --exclude /data/home/nodered/.cache/ --exclude /data/home/nodered/.npm --exclude /data/home/nodered/.node-red/node_modules /data /run/media/mmcblk0p1/data-backup`
2022-08-09 23:44:59 +02:00
### Sources
Used https://github.com/victronenergy/velib_python/blob/master/dbusdummyservice.py as basis for my custom services.
2022-08-09 23:47:41 +02:00
DBus service descriptor are located at https://github.com/victronenergy/venus/wiki/dbus