This repository is in no way approved by or affiliated with the official Victron Energy repository. I am not responsible for any problems or damages with your devices or this code
Only run this script if you are sure you know what you are doing!
This repository is based on https://github.com/vvvrrooomm/victron.
I use this repository to have a running version with mqtt for my camping car. If you want more information about the development and a wireshark dissector, refer to vvvrrooomm's repository.
See https://community.victronenergy.com/questions/93919/victron-bluetooth-ble-protocol-publication.html for more information about how to activate the new gatt protocol with the beta firmware.
The Bluetooth-BLE (new gatt protocol) and the serial protocol works quiet stable. The normal bluetooth protocol is the hardest to implement. Many values are still missing.
More features will be added soon.
The script is tested with python > 3.7
Bluetooth BLE:
- Smart Shunt
Bluetooth:
- Smart Shunt
- Smart Solar 100/30
- Orion Smart 12/12-30
Serial:
- Phoenix Inverter 12 800VA 230V
- Smart Shunt
- Smart Solar 100/30
- mqtt
- syslog
- json
These scripts are written for my specific config file. If you have your devices in different order, you may need to adjust them.
NOTE
If you want the serial communication with the Phoenix Inverter, you must install this library:
- vedirect: https://github.com/karioja/vedirect
There are some more commandline arguments, you can view them with python3 victron.py --help
- You need to install some requirements:
pip3 install -r requirements.txt
- Add your devices to the configuration file. See "Configuration in detail" section for examples.
- If you are using bluetooth or bluetooth ble you must be pairing your devices via bluetoothctl
# Open bluetoothctl from commandline
bluetoothctl
# Enable scanning
scan on
# Get the mac address of your device
# pair device and enter pin
pair MAC
- Start the script for your desired device:
python3 victron.py -d 0
- For autostart tweak systemd files to your need, link them to
/etc/systemd/system/
, then start and/or enable systemd file
ln -s /opt/victron/systemd/victron-shunt.service /etc/systemd/system/victron-shunt.service
systemctl enable victron-shunt.service
systemctl start victron-shunt.service
./victron.py -h
usage: victron.py [-h] [--debug] [--quiet] [-c] [-C CONFIG_FILE] [-D] [-v] [-d NUM / NAME]
Victron Reader (Bluetooth, BLE and Serial)
Current supported devices:
Full:
- Smart Shunt (Bluetooth BLE)
- Phoenix Inverter (Serial)
- Smart Shunt (Serial)
- Smart Solar (Serial)
- Blue Solar (Serial)
Partial:
- Smart Shunt (Bluetooth)
- Smart Solar (Bluetooth)
- Orion Smart (Bluetooth)
Default behavior:
1. It will connect to given device
2. Collect and log data summary as defined at the config file
3. Disconnect and start over with timers set in config file
options:
-h, --help show this help message and exit
--debug Set log level to debug
--quiet Set log level to error
-c, --collection Output only collections specified in config instead of single values
-C CONFIG_FILE, --config-file CONFIG_FILE
Specify different config file [Default: config.yml]
-D, --direct-disconnect
Disconnect direct after getting values
-v, --version Show version and exit
-d NUM / NAME, --device NUM / NAME
0: Shunt1 |
Show help.
Show version.
You need to specify the device from configuration which you want to connect to.
Set log level.
Define a collection to "merge" values in to one output instead of output every value separately. A collection must look like:
collections:
DEVICENAME:
COLLECTIONNAME:
- VALUENAME
- VALUENAME2
You need to set the DEVICENAME the same as your device. You can choose the COLLECTIONNAME freely, it will be used in json output as key. The VALUENAMES must match with the code, see config.yml for possible VALUENAMES and more examples.
Specify a config file other than default (config.yml).
Default the program will not exit on its own. If you want to collect the values from a device and exit, use this option. Be aware, that it will act different on the different connection protocols.
serial / bluetooth-ble: It will exit after the first value. To get all values once, you need to specify a collection to exit after all values are returned.
bluetooth: It will exit after the auto disconnect of the device and return all values gathered until then.
Please check if you paired the victron device correctly via bluetooth using bluetoothctl. If you changed the pin of the vicron device, delete and repair the device.
Mandatory:
Name, Type, Protocol and (MAC or serialport) depending of the type. bluetooth and bluetooth-ble need to have the bluetooth mac adress of the victron device specified.
Name: Choose yourself
Type: phoenix, smartshunt, smartsolar, orionsmart
Protocol: serial, bluetooth, bluetooth-ble
- name: Phoenix1
type: phoenix
protocol: serial
port: /dev/victron-phoenix
or
- name: Shunt1
type: smartshunt
protocol: bluetooth-ble
mac: fd:d4:50:0f:6c:1b
or
- name: Solar1
type: smartsolar
protocol: bluetooth
mac: F9:8E:1C:EC:9C:72
Optional:
You can choose between:
logger: mqtt
or
logger: syslog
or
logger: print
or
logger: json
Choose host, port, base_topic and if you want to use HomeAssistant Discovery (Yet only supported on serial devices). SSL and authentication will be added later.
mqtt:
host: 192.168.3.2
port: 1883
base_topic: victron
hass: True
You can specify if you want the values get summarized into one json output statement. Otherwise it will send out every value as soon as it is collected from victron device. See configfile for more information!
- The devices with bluetooth protocol are currently auto disconnecting after 30 seconds. This may prevent some values from being gathered.
- Orion Smart must be more reverse engineered to get some more interesting values
- Bluetooth: From smart solar you can't get the history values. The protocol itself is decoded (and working) for this part, but the smart solar doesn't send the data. I guess we need to send another init sequence. I didn't figure out the corrent sequence yet!
- Serial: Smart Solar history currently not gathered
Feel free to help improving this repository.
- Choose via config file which values should be printed
- Choose how often values should be printed (especially bluettooth with notifications)
- CMD Parameter instead of config (easier testing of new devices)
- SmartSolar history values
- Get device settings via serial and bluetooth
- Add a config checker to avoid invalid config parameter