-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
1,500 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# dbus-mqtt-battery - Emulates a physical PV Inverter from MQTT data | ||
|
||
<small>GitHub repository: https://github.com/mr-manuel/venus-os_dbus-mqtt-battery</small> | ||
|
||
### Disclaimer | ||
|
||
I wrote this script for myself. I'm not responsible, if you damage something using my script. | ||
|
||
|
||
### Purpose | ||
|
||
The script emulates a battery in Venus OS. It gets the MQTT data from a subscribed topic and publishes the information on the dbus as the service `com.victronenergy.battery.mqtt_battery` with the VRM instance `41`. | ||
|
||
|
||
### 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 | ||
|
||
<details><summary>Required data</summary> | ||
|
||
```json | ||
{ | ||
"dc": { | ||
"power": 79.6, | ||
"voltage": 58.1, | ||
"current": 1.4, | ||
"temperature": 23 | ||
}, | ||
"consumed_amphours": 2.9, | ||
"soc": 99, | ||
"history": { | ||
"voltageMin": 0, | ||
"voltageMax": 0 | ||
} | ||
} | ||
``` | ||
</details> | ||
|
||
|
||
### Install | ||
|
||
1. Copy the `dbus-mqtt-battery` folder to `/data/etc` on your Venus OS device | ||
|
||
2. Run `bash /data/etc/dbus-mqtt-battery/install.sh` as root | ||
|
||
The daemon-tools should start this service automatically within seconds. | ||
|
||
### Uninstall | ||
|
||
Run `/data/etc/dbus-mqtt-battery/uninstall.sh` | ||
|
||
### Restart | ||
|
||
Run `/data/etc/dbus-mqtt-battery/restart.sh` | ||
|
||
### Debugging | ||
|
||
The logs can be checked with `tail -n 100 -f /data/log/dbus-mqtt-battery/current | tai64nlocal` | ||
|
||
The service status can be checked with svstat `svstat /service/dbus-mqtt-battery` | ||
|
||
This will output somethink like `/service/dbus-mqtt-battery: 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-battery/dbus-mqtt-battery.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.battery.mqtt_battery"` it means that the service is still running or another service is using that bus name. | ||
|
||
### Compatibility | ||
|
||
It was tested on following devices: | ||
|
||
* RaspberryPi 4b | ||
* MultiPlus II (GX Version) | ||
|
||
### Screenshots | ||
|
||
<details><summary>MQTT Battery</summary> | ||
|
||
 | ||
 | ||
 | ||
|
||
</details> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
[BATTERY] | ||
; lower voltage when warning alarm is triggered | ||
; default: 3.0 * cell count | ||
VoltageLowWarning = 48.0 | ||
; lower voltage when critical alarm is triggered | ||
; default: 2.9 * cell count | ||
VoltageLowCritical = 46.4 | ||
; higher voltage when warning alarm is triggered | ||
; default: 3.5 * cell count | ||
VoltageHighWarning = 56.0 | ||
; higher voltage when critical alarm is triggered | ||
; default: 3.6 * cell count | ||
VoltageHighCritical = 57.6 | ||
|
||
; low SoC in percent (%) when warning alarm is triggered | ||
LowSocWarning = 10.0 | ||
; low SoC in percent (%) when critical alarm is triggered | ||
LowSocCritical = 5.0 | ||
|
||
|
||
[MQTT] | ||
; IP addess or FQDN from MQTT server | ||
broker_address = IP_ADDR_OR_FQDN | ||
|
||
; Port of the MQTT server | ||
; default plaintext: 1883 | ||
; default TLS port: 8883 | ||
broker_port = 1883 | ||
|
||
; Enables TLS | ||
;tls_enabled = 1 | ||
|
||
; Absolute path to the Certificate Authority certificate file that is to be treated as trusted by this client | ||
;tls_path_to_ca = /data/keys/mosquitto.crt | ||
|
||
; Disables verification of the server hostname in the server certificate | ||
;tls_insecure = 1 | ||
|
||
; Username used for connection | ||
;username = myuser | ||
|
||
; Password used for connection | ||
;password = mypassword | ||
|
||
; Topic where the meters data as JSON string is published | ||
topic = enphase/battery |
Oops, something went wrong.