based on the project https://github.com/victronenergy/dbus-fronius
This service is meant to be run on a raspberry Pi with Venus OS from Victron.
The Python script reads energy production data (grid surplus) and controls a modbus water heater (https://github.com/transistorgit/Heizstab-Regelung) to use solar power to heat up domestic/heating water.
The Venus Device needs an USB-RS485 Converter that is connected to the modbus heater.
-
install pip:
opkg update
opkg install python3-pip
then install minimalmodbus:
pip3 install minimalmodbus
-
Clone the repo or copy the files to the folder
/data/etc/dbus_water_heater
-
Set permissions for py and .sh files if not yet executable:
chmod +x /data/etc/dbus_water_heater/service/run
chmod +x /data/etc/dbus_water_heater/*.sh
chmod +x /data/etc/dbus_water_heater/*.py
-
add service line in an existing config file (maybe you need to create one) in
/data/conf/serial-starter.d
:
service water_heater dbus_water_heater
also append our service short name "water_heater" to default alias (append it like this):
alias default gps:vedirect:sbattery:water_heater
(Hint: a service name must not contain dashes '-')
-
run
./install.sh
The daemon-tools should automatically start this service within seconds.
You can check the status of the service with svstat:
svstat /service/dbus_water_heater.ttyUSB0
try different USB Ports like ttyUSB1 as the service may use another one.
It will show something like this:
/service/dbus_water_heater: up (pid 10078) 325 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/etc/dbus_water_heater/dbus_water_heater.py
and see if it throws any error messages.
The logs can be checked here; /var/log/dbus_water_heater.ttyUSBx
If you want to restart the script, for example after changing it, just run the following command:
/data/etc/dbus_water_heater/kill_me.sh
The daemon-tools will restart the script within a few seconds.
Check if grid surplus is for 1 minute bigger than 500, 1000, ... 3500W and command the appropriate power setting to the water heater. Switch down if the power level is below the step for more than 1 min. Never switch more often than once per minute (other restrictions from grid operators my apply, you have to adjust the timing to your local regulations)
Todo:
Add setting for target temperature
Add menu: Off/Auto low/Auto high/On (Test)
Show current water temperature
Show kWh since last 24h, week
Show switch counter, hours in each power level for last 24h
python -m unittest test.py