Hi,
I have seen requests in this forum for a script for dumping excess solar power to hot water tank based on system conditions like SOC, PV power and loads. Here is an example of a possible solution using dbus and a system relay for firing on and off the water tank heater
#!/bin/bash
# Fire ON Relay1 only if all of the folowing conditions are met:
# - Battery SOC >= 80%
# - Solarmax Power >= 1900 W
# - CriticalLoads power <= 1200 W
echo
DATE="Run at $(date +"%a %d%b %Hh%M") UTC"
echo $DATE
GONOGO_SM=`dbus -y com.victronenergy.grid.cgwacs_ttyUSB2_di32_mb1 /Connected GetValue | awk '{printf("%d\n",$3 + 0.5);}'`
GONOGO_BAT=`dbus -y com.victronenergy.battery.socketcan_can0 /Connected GetValue | awk '{printf("%d\n",$3 + 0.5);}'`
GONOGO_MULTI=`dbus -y com.victronenergy.vebus.ttyUSB0 /Connected GetValue | awk '{printf("%d\n",$3 + 0.5);}'`
# Run this script only if PV Inverter, CAN-BUS Battery and Multi are up and running, otherwise turn OFF Relay1
if [ $GONOGO_SM -eq 1 ] && [ $GONOGO_BAT -eq 1 ] && [ $GONOGO_MULTI -eq 1 ]
then
echo "---------------------------------------"
# Read output power of Solarmax, battery SOC and critical loads power consumption
SMP=`dbus -y com.victronenergy.pvinverter.cgwacs_ttyUSB2_di30_mb2 /Ac/L1/Power GetValue | awk '{printf("%d\n",$3 + 0.5);}'`
SOC=`dbus -y com.victronenergy.battery.socketcan_can0 /Soc GetValue | awk '{printf("%d\n",$3 + 0.5);}'`
CLP=`dbus -y com.victronenergy.system /Ac/ConsumptionOnOutput/L1/Power GetValue | awk '{printf("%d\n",$1 + 0.5);}'`
echo "Battery SOC $SOC"%
echo "SolarMax Power $SMP"W
echo "UPSloads Power $CLP"W
# Fire ON relay1 if SOC >= 80, SolarPower >= 1.9kW and Critical Loads <= 1.2kW
STATE=`dbus -y com.victronenergy.system /Relay/1/State GetValue`
if [ $SOC -ge 80 ] && [ $SMP -ge 1900 ] && [ $CLP -le 1200 ]
then
if [ $STATE -eq 0 ]
then
echo "---------------------------------------"
echo "Fire ON Relay1"
dbus -y com.victronenergy.system /Relay/1/State SetValue 1
else
echo "Relay1 is already ON"
fi
else
if [ $STATE -eq 1 ]
then
echo "---------------------------------------"
echo "Power OFF Relay1"
dbus -y com.victronenergy.system /Relay/1/State SetValue 0
else
echo "Relay1 is already OFF"
fi
fi
else
echo "---------------------------------------"
if [ $GONOGO_SM -eq 1 ]
then
echo "Warning! EM111 SOLARMAX PV Inverter meter not responding. Check RS485 connection or EM111!"
fi
if [ $GONOGO_BAT -eq 1 ]
then
echo "Warning! REC-BMS not responding. Check the unit or CAN connection!"
fi
if [ $GONOGO_MULTI -eq 1 ]
then
echo "Warning! MultiPlus not responding. Check the unit status!"
fi
echo "Power OFF Relay1"
dbus -y com.victronenergy.system /Relay/1/State SetValue 0
fi
echo
echo "***************************************"
This script should be executed every minute by crond system daemon using #crontab -e command with the following syntax:
0-59 * * * * /home/root/.ControlRelay1.sh > /dev/null 2>&1
Regards,
Mihai