From 8c3a4ef098c105e20186f00f8c5d8f5939fd0843 Mon Sep 17 00:00:00 2001 From: Lutz Bender Date: Wed, 17 Aug 2022 10:30:17 +0200 Subject: [PATCH] formatting --- ladelog.sh | 178 +++++++++++++++++++------------------- nachtladen.sh | 210 ++++++++++++++++++++++----------------------- u1p3p.sh | 230 +++++++++++++++++++++++++------------------------- 3 files changed, 306 insertions(+), 312 deletions(-) diff --git a/ladelog.sh b/ladelog.sh index ab00a2a4f..060788403 100755 --- a/ladelog.sh +++ b/ladelog.sh @@ -10,11 +10,11 @@ fi openwbDebugLog "CHARGESTAT" 1 "### start (->$monthlyfile)" # check for special charge modes -nachtladenstate=$(<"${RAMDISKDIR}/nachtladenstate") # "Nachtladen" LP1 -nachtladen2state=$(<"${RAMDISKDIR}/nachtladen2state") # "Morgensladen" LP1 -nachtladenstates1=$(<"${RAMDISKDIR}/nachtladenstates1") # "Nachtladen" LP2 -nachtladen2states1=$(<"${RAMDISKDIR}/nachtladen2states1") # "Morgensladen" LP2 -if (( nachtladenstate == 0 )) && (( nachtladen2state == 0 )) && (( nachtladenstates1 == 0 )) && (( nachtladen2states1 == 0 )); then +nachtladenstate=$(<"${RAMDISKDIR}/nachtladenstate") # "Nachtladen" LP1 +nachtladen2state=$(<"${RAMDISKDIR}/nachtladen2state") # "Morgensladen" LP1 +nachtladenstates1=$(<"${RAMDISKDIR}/nachtladenstates1") # "Nachtladen" LP2 +nachtladen2states1=$(<"${RAMDISKDIR}/nachtladen2states1") # "Morgensladen" LP2 +if ((nachtladenstate == 0)) && ((nachtladen2state == 0)) && ((nachtladenstates1 == 0)) && ((nachtladen2states1 == 0)); then lmodus=$(<"${RAMDISKDIR}/lademodus") else # "Nachtladen" or "Morgensladen" is configured, set charge mode to "7" @@ -27,12 +27,12 @@ if [ -e "${RAMDISKDIR}/loglademodus" ]; then openwbDebugLog "CHARGESTAT" 2 "\"loglademodus\"=$loglademodus" fi -getTimeDiffString(){ +getTimeDiffString() { minutes=$1 - if (( minutes > 60 )); then - text="$(( minutes / 60 )) H $(( minutes % 60 )) Min" - elif (( minutes >= 0 )); then + if ((minutes > 60)); then + text="$((minutes / 60)) H $((minutes % 60)) Min" + elif ((minutes >= 0)); then text="$minutes Min" else text="--" @@ -41,46 +41,46 @@ getTimeDiffString(){ } # function for charge points 1 to 8 -processChargepoint(){ +processChargepoint() { chargePointNumber=$1 # quirk to handle ugly file naming case $chargePointNumber in - 1) - soc=$(<"${RAMDISKDIR}/soc") - chargePointKey="lp1" - chargePointKey2="" - chargePointKey3=$chargePointKey2 - chargePointActivated=1 # charge point 1 is always activated - ;; - 2) - soc=$(<"${RAMDISKDIR}/soc1") - chargePointKey="lp2" - chargePointKey2="s1" - chargePointKey3=$chargePointKey2 - chargePointActivated=$lastmanagement - ;; - 3) - soc=0 - chargePointKey="lp3" - chargePointKey2="s2" - chargePointKey3=$chargePointKey - chargePointActivated=$lastmanagements2 - ;; - *) - soc=0 - chargePointKey="lp$1" - chargePointKey2=$chargePointKey - chargePointKey3=$chargePointKey - chargePointActivatedVariableName="lastmanagement$chargePointKey" - chargePointActivated=${!chargePointActivatedVariableName} - ;; + 1) + soc=$(<"${RAMDISKDIR}/soc") + chargePointKey="lp1" + chargePointKey2="" + chargePointKey3=$chargePointKey2 + chargePointActivated=1 # charge point 1 is always activated + ;; + 2) + soc=$(<"${RAMDISKDIR}/soc1") + chargePointKey="lp2" + chargePointKey2="s1" + chargePointKey3=$chargePointKey2 + chargePointActivated=$lastmanagement + ;; + 3) + soc=0 + chargePointKey="lp3" + chargePointKey2="s2" + chargePointKey3=$chargePointKey + chargePointActivated=$lastmanagements2 + ;; + *) + soc=0 + chargePointKey="lp$1" + chargePointKey2=$chargePointKey + chargePointKey3=$chargePointKey + chargePointActivatedVariableName="lastmanagement$chargePointKey" + chargePointActivated=${!chargePointActivatedVariableName} + ;; esac chargePointNameVariableName="${chargePointKey}name" - if (( chargePointActivated == 1)); then + if ((chargePointActivated == 1)); then openwbDebugLog "CHARGESTAT" 1 "# processing charge point $chargePointNumber (${!chargePointNameVariableName})" # get soc - if (( soc > 0 )); then + if ((soc > 0)); then openwbDebugLog "CHARGESTAT" 1 "soc detected: $soc%" soctext=", bei $soc %SoC." else @@ -89,7 +89,7 @@ processChargepoint(){ fi # get rfid tag rfid=$(<"${RAMDISKDIR}/rfid${chargePointKey}") - rfid=$(cut -d ',' -f 1 <<< "$rfid") + rfid=$(cut -d ',' -f 1 <<<"$rfid") # get actual charge power ladeleistung=$(<"${RAMDISKDIR}/llaktuell${chargePointKey2}") # get actual meter value @@ -97,60 +97,60 @@ processChargepoint(){ openwbDebugLog "CHARGESTAT" 1 "rfid=$rfid; power=$ladeleistung; meter=$llkwh" # get plug state plugstat=$(<"${RAMDISKDIR}/plugstat${chargePointKey3}") - if (( plugstat == 1 )); then + if ((plugstat == 1)); then # a car is connected openwbDebugLog "CHARGESTAT" 1 "car connected: plugstat=$plugstat" pluggedladungakt=$(<"${RAMDISKDIR}/pluggedladungakt${chargePointKey}") - if (( pluggedladungakt == 0 )); then + if ((pluggedladungakt == 0)); then # new charge detected openwbDebugLog "CHARGESTAT" 1 "new charge detected; meter=$llkwh" # write actual meter value as start value since plugged in - echo "$llkwh" > "${RAMDISKDIR}/pluggedladung${chargePointKey}startkwh" + echo "$llkwh" >"${RAMDISKDIR}/pluggedladung${chargePointKey}startkwh" # note ourself about tracking this charge - echo 1 > "${RAMDISKDIR}/pluggedladungakt${chargePointKey}" + echo 1 >"${RAMDISKDIR}/pluggedladungakt${chargePointKey}" fi - if (( "stopchargeafterdisc$chargePointKey" == 1 )); then + if (("stopchargeafterdisc$chargePointKey" == 1)); then openwbDebugLog "CHARGESTAT" 2 "\"stopchargeafterdisc\" set, charge point will be locked after unplug is detected" boolstopchargeafterdisc=$(<"${RAMDISKDIR}/boolstopchargeafterdisc${chargePointKey}") - if (( boolstopchargeafterdisc == 0 )); then + if ((boolstopchargeafterdisc == 0)); then # note ourself to lock this charge point after disconnect - echo 1 > "${RAMDISKDIR}/boolstopchargeafterdisc${chargePointKey}" + echo 1 >"${RAMDISKDIR}/boolstopchargeafterdisc${chargePointKey}" fi fi # read start meter value since plugged pluggedladungstartkwh=$(<"${RAMDISKDIR}/pluggedladung${chargePointKey}startkwh") # calculate actual meter value difference since plugged - pluggedladungbishergeladen=$(echo "scale=2;($llkwh - $pluggedladungstartkwh)/1" |bc | sed 's/^\./0./') - echo "$pluggedladungbishergeladen" > "${RAMDISKDIR}/pluggedladungbishergeladen${chargePointKey}" + pluggedladungbishergeladen=$(echo "scale=2;($llkwh - $pluggedladungstartkwh)/1" | bc | sed 's/^\./0./') + echo "$pluggedladungbishergeladen" >"${RAMDISKDIR}/pluggedladungbishergeladen${chargePointKey}" openwbDebugLog "CHARGESTAT" 1 "charged since plugged: $pluggedladungstartkwh - $llkwh = $pluggedladungbishergeladen" # reset unplug timer - echo 0 > "${RAMDISKDIR}/pluggedtimer${chargePointKey}" + echo 0 >"${RAMDISKDIR}/pluggedtimer${chargePointKey}" else # no car connected openwbDebugLog "CHARGESTAT" 1 "car not connected: plugstat=$plugstat" pluggedtimer=$(<"${RAMDISKDIR}/pluggedtimer${chargePointKey}") - if (( pluggedtimer < 5 )); then + if ((pluggedtimer < 5)); then # increment unplug timer - pluggedtimer=$(( pluggedtimer + 1 )) - echo "$pluggedtimer" > "${RAMDISKDIR}/pluggedtimer${chargePointKey}" + pluggedtimer=$((pluggedtimer + 1)) + echo "$pluggedtimer" >"${RAMDISKDIR}/pluggedtimer${chargePointKey}" openwbDebugLog "CHARGESTAT" 2 "pluggedtimer=$pluggedtimer" else # unplug timer reached 60s (in normal control loop speed) # stop actual tracked charge - echo 0 > "${RAMDISKDIR}/pluggedladungakt${chargePointKey}" + echo 0 >"${RAMDISKDIR}/pluggedladungakt${chargePointKey}" openwbDebugLog "CHARGESTAT" 2 "unplug detected" # lock this charge point if configured - if (( "stopchargeafterdisc$chargePointKey" == 1 )); then + if (("stopchargeafterdisc$chargePointKey" == 1)); then openwbDebugLog "CHARGESTAT" 2 "locking charge point" boolstopchargeafterdisc=$(<"${RAMDISKDIR}/boolstopchargeafterdisc${chargePointKey}") - if (( boolstopchargeafterdisc == 1 )); then - echo 0 > "${RAMDISKDIR}/boolstopchargeafterdisc${chargePointKey}" + if ((boolstopchargeafterdisc == 1)); then + echo 0 >"${RAMDISKDIR}/boolstopchargeafterdisc${chargePointKey}" mosquitto_pub -r -t "openWB/set/lp/${chargePointNumber}/ChargePointEnabled" -m "0" fi fi fi fi - if (( ladeleistung > 100 )); then + if ((ladeleistung > 100)); then # charge point is charging openwbDebugLog "CHARGESTAT" 1 "car is charging" if [ -e "${RAMDISKDIR}/ladeustart${chargePointKey2}" ]; then @@ -158,35 +158,35 @@ processChargepoint(){ openwbDebugLog "CHARGESTAT" 2 "this charge was already detected" # calculate actual energy charged ladelstart=$(<"${RAMDISKDIR}/ladelstart${chargePointKey2}") - bishergeladen=$(echo "scale=2;($llkwh - $ladelstart)/1" |bc | sed 's/^\./0./') - echo "$bishergeladen" > "${RAMDISKDIR}/aktgeladen${chargePointKey2}" + bishergeladen=$(echo "scale=2;($llkwh - $ladelstart)/1" | bc | sed 's/^\./0./') + echo "$bishergeladen" >"${RAMDISKDIR}/aktgeladen${chargePointKey2}" # calculate range charged averageConsumptionVariableName="durchs$chargePointKey" - gelr=$(echo "scale=0;$bishergeladen * 100 / ${!averageConsumptionVariableName}" |bc) - echo "$gelr" > "${RAMDISKDIR}/gelr${chargePointKey}" + gelr=$(echo "scale=0;$bishergeladen * 100 / ${!averageConsumptionVariableName}" | bc) + echo "$gelr" >"${RAMDISKDIR}/gelr${chargePointKey}" # calculate time remaining if energy limit is set energyChargeLimitVariableName="lademkwh$chargePointKey2" - restzeit=$(echo "scale=0;(${!energyChargeLimitVariableName} - $bishergeladen) * 1000 * 60 / $ladeleistung" |bc) - echo "$restzeit" > "${RAMDISKDIR}/restzeit${chargePointKey}m" + restzeit=$(echo "scale=0;(${!energyChargeLimitVariableName} - $bishergeladen) * 1000 * 60 / $ladeleistung" | bc) + echo "$restzeit" >"${RAMDISKDIR}/restzeit${chargePointKey}m" # format time charged restzeittext=$(getTimeDiffString "$restzeit") - echo "$restzeittext" > "${RAMDISKDIR}/restzeit${chargePointKey}" + echo "$restzeittext" >"${RAMDISKDIR}/restzeit${chargePointKey}" openwbDebugLog "CHARGESTAT" 1 "energyCharged=${bishergeladen}kWh; rangeCharged=${gelr}km; timeRemaining=${restzeit}m ($restzeittext)" else # new charge detected openwbDebugLog "CHARGESTAT" 1 "new charge detected" - echo 1 > "${RAMDISKDIR}/ladungaktiv${chargePointKey}" + echo 1 >"${RAMDISKDIR}/ladungaktiv${chargePointKey}" # save actual timestamp for this charge touch "${RAMDISKDIR}/ladeustart${chargePointKey2}" - echo -e "$(date +%d.%m.%y-%H:%M)" > "${RAMDISKDIR}/ladeustart${chargePointKey2}" - echo -e "$(date +%s)" > "${RAMDISKDIR}/ladeustarts${chargePointKey2}" + echo -e "$(date +%d.%m.%y-%H:%M)" >"${RAMDISKDIR}/ladeustart${chargePointKey2}" + echo -e "$(date +%s)" >"${RAMDISKDIR}/ladeustarts${chargePointKey2}" # save actual charge mode for this charge - echo "$lmodus" > "${RAMDISKDIR}/loglademodus" + echo "$lmodus" >"${RAMDISKDIR}/loglademodus" # save actual meter value es start for this charge - echo "$llkwh" > "${RAMDISKDIR}/ladelstart${chargePointKey2}" + echo "$llkwh" >"${RAMDISKDIR}/ladelstart${chargePointKey2}" # send push message if configured - if (( pushbenachrichtigung == 1 )) ; then - if (( pushbstartl == 1 )) ; then + if ((pushbenachrichtigung == 1)); then + if ((pushbstartl == 1)); then openwbDebugLog "CHARGESTAT" 2 "sending push notification for charge point \"${!chargePointNameVariableName}\"" "${OPENWBBASEDIR}/runs/pushover.sh" "${!chargePointNameVariableName} Ladung gestartet$soctext" fi @@ -194,15 +194,15 @@ processChargepoint(){ openwbDebugLog "CHARGESTAT" 0 "LP${chargePointNumber}, Ladung gestartet" fi # reset our charge stop timer - echo 0 > "${RAMDISKDIR}/llog${chargePointKey2}" + echo 0 >"${RAMDISKDIR}/llog${chargePointKey2}" else # charge point is not charging openwbDebugLog "CHARGESTAT" 1 "car is not charging" llog=$(<"${RAMDISKDIR}/llog${chargePointKey2}") - if (( llog < 5 )); then + if ((llog < 5)); then # increment charge stop timer - llog=$(( llog + 1 )) - echo "$llog" > "${RAMDISKDIR}/llog${chargePointKey2}" + llog=$((llog + 1)) + echo "$llog" >"${RAMDISKDIR}/llog${chargePointKey2}" openwbDebugLog "CHARGESTAT" 2 "llog=$llog" else # charge stop timer reached 60s (in normal control loop speed) @@ -210,39 +210,39 @@ processChargepoint(){ # a charge just finished openwbDebugLog "CHARGESTAT" 1 "end of charge detected" # reset detected charge - echo 0 > "${RAMDISKDIR}/ladungaktiv${chargePointKey}" + echo 0 >"${RAMDISKDIR}/ladungaktiv${chargePointKey}" # clear time remaining - echo "--" > "${RAMDISKDIR}/restzeit${chargePointKey}" + echo "--" >"${RAMDISKDIR}/restzeit${chargePointKey}" # calculate energy charged ladelstart=$(<"${RAMDISKDIR}/ladelstart${chargePointKey2}") - bishergeladen=$(echo "scale=2;($llkwh - $ladelstart)/1" |bc | sed 's/^\./0./') + bishergeladen=$(echo "scale=2;($llkwh - $ladelstart)/1" | bc | sed 's/^\./0./') # calculate range charged averageConsumptionVariableName="durchs$chargePointKey" - gelr=$(echo "scale=0;$bishergeladen * 100 / ${!averageConsumptionVariableName}" |bc) + gelr=$(echo "scale=0;$bishergeladen * 100 / ${!averageConsumptionVariableName}" | bc) # calculate time charged start=$(<"${RAMDISKDIR}/ladeustart${chargePointKey2}") ladeustarts=$(<"${RAMDISKDIR}/ladeustarts${chargePointKey2}") jetzt=$(date +%d.%m.%y-%H:%M) jetzts=$(date +%s) - ladedauer=$(( (jetzts - ladeustarts) / 60 )) - ladedauers=$(( jetzts - ladeustarts )) + ladedauer=$(((jetzts - ladeustarts) / 60)) + ladedauers=$((jetzts - ladeustarts)) # calculate average power - ladegeschw=$(echo "scale=2;$bishergeladen * 60 * 60 / $ladedauers" |bc) + ladegeschw=$(echo "scale=2;$bishergeladen * 60 * 60 / $ladedauers" | bc) # format time charged ladedauertext=$(getTimeDiffString "$ladedauer") # add charge log entry - if (( chargePointNumber < 3 )); then + if ((chargePointNumber < 3)); then lademoduslogvalue=$loglademodus else lademoduslogvalue=$lademodus fi # calculate costs - kosten=$(echo "scale=2;$bishergeladen * $preisjekwh" |bc) + kosten=$(echo "scale=2;$bishergeladen * $preisjekwh" | bc) # save final values sed -i "1i$start,$jetzt,$gelr,$bishergeladen,$ladegeschw,$ladedauertext,$chargePointNumber,$lademoduslogvalue,$rfid,$kosten" "$monthlyfile" # send push message if configured - if (( pushbenachrichtigung == 1 )) ; then - if (( pushbstopl == 1 )) ; then + if ((pushbenachrichtigung == 1)); then + if ((pushbstopl == 1)); then openwbDebugLog "CHARGESTAT" 2 "sending push notification for charge point \"${!chargePointNameVariableName}\"" "${OPENWBBASEDIR}/runs/pushover.sh" "${!chargePointNameVariableName} Ladung gestoppt. $bishergeladen kWh in $ladedauertext mit durchschnittlich $ladegeschw kW geladen$soctext" fi diff --git a/nachtladen.sh b/nachtladen.sh index 13a086982..1876ed708 100755 --- a/nachtladen.sh +++ b/nachtladen.sh @@ -1,5 +1,5 @@ #!/bin/bash -lastmnacht(){ +lastmnacht() { if [[ $schieflastaktiv == "1" ]]; then if [[ $u1p3paktiv == "1" ]]; then u1p3pstat=$( $2 )); then - llnachtreturn=$(($1 - 1 )) + if (($1 > $2)); then + llnachtreturn=$(($1 - 1)) else - if (( maxdiff > 1 )); then - llnachtreturn=$(($1 + 1 )) + if ((maxdiff > 1)); then + llnachtreturn=$(($1 + 1)) else llnachtreturn=$1 fi fi - if (( llnachtreturn > maximalstromstaerke )); then + if ((llnachtreturn > maximalstromstaerke)); then llnachtreturn=$2 fi - if (( llnachtreturn < minimalstromstaerke )); then + if ((llnachtreturn < minimalstromstaerke)); then llnachtreturn=$minimalstromstaerke fi fi fi else - evudiff1=$((evua1 - lastmaxap1 )) - evudiff2=$((evua2 - lastmaxap2 )) - evudiff3=$((evua3 - lastmaxap3 )) - evudiffmax=($evudiff1 $evudiff2 $evudiff3) + evudiff1=$((evua1 - lastmaxap1)) + evudiff2=$((evua2 - lastmaxap2)) + evudiff3=$((evua3 - lastmaxap3)) + evudiffmax=("$evudiff1" "$evudiff2" "$evudiff3") maxdiff=0 for vv in "${evudiffmax[@]}"; do - if (( vv > maxdiff )); then maxdiff=$vv; fi; + if ((vv > maxdiff)); then maxdiff=$vv; fi done - maxdiff=$((maxdiff + 1 )) + maxdiff=$((maxdiff + 1)) llnachtreturn=$(($1 - maxdiff)) - if (( llnachtreturn < minimalstromstaerke )); then + if ((llnachtreturn < minimalstromstaerke)); then llnachtreturn=$minimalstromstaerke openwbDebugLog "MAIN" 1 "Differenz groesser als minimalstromstaerke, setze Nachtladen auf minimal A $minimalstromstaerke" fi - echo "Lastmanagement aktiv, Ladeleistung reduziert" > ramdisk/lastregelungaktiv + echo "Lastmanagement aktiv, Ladeleistung reduziert" >ramdisk/lastregelungaktiv openwbDebugLog "MAIN" 1 "Nachtladen um $maxdiff auf $llnachtreturn reduziert" fi fi } -nachtlademodus(){ +nachtlademodus() { if [[ $nachtladen == "1" ]]; then - if (( nachtladenabuhr <= 10#$H && 10#$H <= 24 )) || (( 0 <= 10#$H && 10#$H < nachtladenbisuhr )); then + if ((nachtladenabuhr <= 10#$H && 10#$H <= 24)) || ((0 <= 10#$H && 10#$H < nachtladenbisuhr)); then nachtladenstate=1 dayoftheweek=$(date +%w) currenthour=$(date +%k) - if [[ $dayoftheweek -eq 0 && $currenthour -ge 14 ]] || [[ $dayoftheweek -ge 1 && $dayoftheweek -le 4 ]] || [[ $dayoftheweek -eq 5 && $currenthour -le 11 ]] ; then - diesersoc=$nachtsoc + if [[ $dayoftheweek -eq 0 && $currenthour -ge 14 ]] || [[ $dayoftheweek -ge 1 && $dayoftheweek -le 4 ]] || [[ $dayoftheweek -eq 5 && $currenthour -le 11 ]]; then + diesersoc=$nachtsoc else diesersoc=$nachtsoc1 fi if [[ $socmodul != "none" ]]; then openwbDebugLog "MAIN" 1 "nachtladen mit socmodul $socmodul" - if (( soc <= diesersoc )); then + if ((soc <= diesersoc)); then if grep -q 0 "/var/www/html/openWB/ramdisk/ladestatus"; then llnachtneu=$nachtll #runs/set-current.sh "$nachtll" m - openwbDebugLog "MAIN" 1 "soc $soc ladeleistung nachtladen bei $nachtll" + openwbDebugLog "MAIN" 1 "soc $soc Ladeleistung Nachtladen bei $nachtll" fi - if ! grep -q $nachtll "/var/www/html/openWB/ramdisk/llsoll"; then + if ! grep -q "$nachtll" "/var/www/html/openWB/ramdisk/llsoll"; then llnachtneu=$nachtll #runs/set-current.sh "$nachtll" m - openwbDebugLog "MAIN" 1 "aendere nacht Ladeleistung auf $nachtll" + openwbDebugLog "MAIN" 1 "aendere Nacht-Ladeleistung auf $nachtll" fi else if grep -q 1 "/var/www/html/openWB/ramdisk/ladestatus"; then @@ -96,12 +96,12 @@ nachtlademodus(){ if grep -q 0 "/var/www/html/openWB/ramdisk/ladestatus"; then llnachtneu=$nachtll #runs/set-current.sh "$nachtll" m - openwbDebugLog "MAIN" 1 "soc $soc ladeleistung nachtladen $nachtll A" + openwbDebugLog "MAIN" 1 "Ladeleistung Nachtladen $nachtll A" else - if ! grep -q $nachtll "/var/www/html/openWB/ramdisk/llsoll"; then + if ! grep -q "$nachtll" "/var/www/html/openWB/ramdisk/llsoll"; then llnachtneu=$nachtll #runs/set-current.sh "$nachtll" m - openwbDebugLog "MAIN" 1 "aendere nacht Ladeleistung auf $nachtll" + openwbDebugLog "MAIN" 1 "aendere Nacht-Ladeleistung auf $nachtll" fi fi fi @@ -115,154 +115,154 @@ nachtlademodus(){ dayoftheweek=$(date +%w) currenttime=$(date +%H:%M) #Sonntag - if (( dayoftheweek == 0 )); then + if ((dayoftheweek == 0)); then if [[ "$currenttime" > "$mollp1soab" ]] && [[ "$currenttime" < "$mollp1sobis" ]]; then nachtladen2state=1 if grep -q 0 "/var/www/html/openWB/ramdisk/ladestatus"; then llnachtneu=$mollp1soll openwbDebugLog "CHARGESTAT" 0 "Sonntag morgens Laden gestartet mit $mollp1soll A" - openwbDebugLog "MAIN" 1 "ladeleistung Sonntag morgens Laden $mollp1soll A" + openwbDebugLog "MAIN" 1 "Ladeleistung Sonntag morgens Laden $mollp1soll A" else - if ! grep -q $mollp1soll "/var/www/html/openWB/ramdisk/llsoll"; then + if ! grep -q "$mollp1soll" "/var/www/html/openWB/ramdisk/llsoll"; then llnachtneu=$mollp1soll - openwbDebugLog "MAIN" 1 "aendere ladeleistung Sonntag morgens Laden $mollp1soll A" + openwbDebugLog "MAIN" 1 "aendere Ladeleistung Sonntag morgens Laden $mollp1soll A" fi fi if [ -z "$llnachtneu" ]; then llnachtneu=$llalt - fi + fi else nachtladen2state=0 fi fi #Montag - if (( dayoftheweek == 1 )); then + if ((dayoftheweek == 1)); then if [[ "$currenttime" > "$mollp1moab" ]] && [[ "$currenttime" < "$mollp1mobis" ]]; then nachtladen2state=1 if grep -q 0 "/var/www/html/openWB/ramdisk/ladestatus"; then llnachtneu=$mollp1moll openwbDebugLog "CHARGESTAT" 0 "Montag morgens Laden gestartet mit $mollp1moll A" - openwbDebugLog "MAIN" 1 "ladeleistung Sonntag morgens Laden $mollp1moll A" + openwbDebugLog "MAIN" 1 "Ladeleistung Sonntag morgens Laden $mollp1moll A" else - if ! grep -q $mollp1moll "/var/www/html/openWB/ramdisk/llsoll"; then + if ! grep -q "$mollp1moll" "/var/www/html/openWB/ramdisk/llsoll"; then llnachtneu=$mollp1moll - openwbDebugLog "MAIN" 1 "aendere ladeleistung Montag morgens Laden $mollp1moll A" + openwbDebugLog "MAIN" 1 "aendere Ladeleistung Montag morgens Laden $mollp1moll A" fi fi if [ -z "$llnachtneu" ]; then llnachtneu=$llalt - fi + fi else nachtladen2state=0 fi fi #Dienstag - if (( dayoftheweek == 2 )); then + if ((dayoftheweek == 2)); then if [[ "$currenttime" > "$mollp1diab" ]] && [[ "$currenttime" < "$mollp1dibis" ]]; then nachtladen2state=1 if grep -q 0 "/var/www/html/openWB/ramdisk/ladestatus"; then llnachtneu=$mollp1dill openwbDebugLog "CHARGESTAT" 0 "Dienstag morgens Laden gestartet mit $mollp1dill A" - openwbDebugLog "MAIN" 1 "ladeleistung Dienstag morgens Laden $mollp1dill A" + openwbDebugLog "MAIN" 1 "Ladeleistung Dienstag morgens Laden $mollp1dill A" else - if ! grep -q $mollp1dill "/var/www/html/openWB/ramdisk/llsoll"; then + if ! grep -q "$mollp1dill" "/var/www/html/openWB/ramdisk/llsoll"; then llnachtneu=$mollp1dill - openwbDebugLog "MAIN" 1 "aendere ladeleistung Dienstag morgens Laden $mollp1dill A" + openwbDebugLog "MAIN" 1 "aendere Ladeleistung Dienstag morgens Laden $mollp1dill A" fi fi if [ -z "$llnachtneu" ]; then llnachtneu=$llalt - fi + fi else nachtladen2state=0 fi fi #Mittwoch - if (( dayoftheweek == 3 )); then + if ((dayoftheweek == 3)); then if [[ "$currenttime" > "$mollp1miab" ]] && [[ "$currenttime" < "$mollp1mibis" ]]; then nachtladen2state=1 if grep -q 0 "/var/www/html/openWB/ramdisk/ladestatus"; then llnachtneu=$mollp1mill openwbDebugLog "CHARGESTAT" 0 "Mittwoch morgens Laden gestartet mit $mollp1mill A" - openwbDebugLog "MAIN" 1 "ladeleistung Mittwoch morgens Laden $mollp1mill A" + openwbDebugLog "MAIN" 1 "Ladeleistung Mittwoch morgens Laden $mollp1mill A" else - if ! grep -q $mollp1mill "/var/www/html/openWB/ramdisk/llsoll"; then + if ! grep -q "$mollp1mill" "/var/www/html/openWB/ramdisk/llsoll"; then llnachtneu=$mollp1mill - openwbDebugLog "MAIN" 1 "aendere ladeleistung Mittwoch morgens Laden $mollp1mill A" + openwbDebugLog "MAIN" 1 "aendere Ladeleistung Mittwoch morgens Laden $mollp1mill A" fi fi if [ -z "$llnachtneu" ]; then llnachtneu=$llalt - fi + fi else nachtladen2state=0 fi fi #Donnerstag - if (( dayoftheweek == 4 )); then + if ((dayoftheweek == 4)); then if [[ "$currenttime" > "$mollp1doab" ]] && [[ "$currenttime" < "$mollp1dobis" ]]; then nachtladen2state=1 if grep -q 0 "/var/www/html/openWB/ramdisk/ladestatus"; then llnachtneu=$mollp1doll openwbDebugLog "CHARGESTAT" 0 "Donnerstag morgens Laden gestartet mit $mollp1doll A" - openwbDebugLog "MAIN" 1 "ladeleistung Donnerstag morgens Laden $mollp1doll A" + openwbDebugLog "MAIN" 1 "Ladeleistung Donnerstag morgens Laden $mollp1doll A" else - if ! grep -q $mollp1doll "/var/www/html/openWB/ramdisk/llsoll"; then + if ! grep -q "$mollp1doll" "/var/www/html/openWB/ramdisk/llsoll"; then llnachtneu=$mollp1doll - openwbDebugLog "MAIN" 1 "aendere ladeleistung Donnerstag morgens Laden $mollp1doll A" + openwbDebugLog "MAIN" 1 "aendere Ladeleistung Donnerstag morgens Laden $mollp1doll A" fi fi if [ -z "$llnachtneu" ]; then llnachtneu=$llalt - fi + fi else nachtladen2state=0 fi fi #Freitag - if (( dayoftheweek == 5 )); then + if ((dayoftheweek == 5)); then if [[ "$currenttime" > "$mollp1frab" ]] && [[ "$currenttime" < "$mollp1frbis" ]]; then nachtladen2state=1 if grep -q 0 "/var/www/html/openWB/ramdisk/ladestatus"; then llnachtneu=$mollp1frll openwbDebugLog "CHARGESTAT" 0 "Freitag morgens Laden gestartet mit $mollp1frll A" - openwbDebugLog "MAIN" 1 "ladeleistung Freitag morgens Laden $mollp1frll A" + openwbDebugLog "MAIN" 1 "Ladeleistung Freitag morgens Laden $mollp1frll A" else - if ! grep -q $mollp1frll "/var/www/html/openWB/ramdisk/llsoll"; then + if ! grep -q "$mollp1frll" "/var/www/html/openWB/ramdisk/llsoll"; then llnachtneu=$mollp1frll - openwbDebugLog "MAIN" 1 "aendere ladeleistung Freitag morgens Laden $mollp1frll A" + openwbDebugLog "MAIN" 1 "aendere Ladeleistung Freitag morgens Laden $mollp1frll A" fi fi if [ -z "$llnachtneu" ]; then llnachtneu=$llalt - fi + fi else nachtladen2state=0 fi fi #Samstag - if (( dayoftheweek == 6 )); then + if ((dayoftheweek == 6)); then if [[ "$currenttime" > "$mollp1saab" ]] && [[ "$currenttime" < "$mollp1sabis" ]]; then nachtladen2state=1 if grep -q 0 "/var/www/html/openWB/ramdisk/ladestatus"; then llnachtneu=$mollp1sall openwbDebugLog "CHARGESTAT" 0 "Samstag morgens Laden gestartet mit $mollp1sall A" - openwbDebugLog "MAIN" 1 "ladeleistung Samstag morgens Laden $mollp1sall A" + openwbDebugLog "MAIN" 1 "Ladeleistung Samstag morgens Laden $mollp1sall A" else - if ! grep -q $mollp1sall "/var/www/html/openWB/ramdisk/llsoll"; then + if ! grep -q "$mollp1sall" "/var/www/html/openWB/ramdisk/llsoll"; then llnachtneu=$mollp1sall - openwbDebugLog "MAIN" 1 "aendere ladeleistung Samstag morgens Laden $mollp1sall A" + openwbDebugLog "MAIN" 1 "aendere Ladeleistung Samstag morgens Laden $mollp1sall A" fi fi if [ -z "$llnachtneu" ]; then llnachtneu=$llalt - fi + fi else nachtladen2state=0 fi @@ -275,45 +275,40 @@ nachtlademodus(){ #Nachtladen S1 if [[ $nachtladens1 == "1" ]]; then - if (( nachtladenabuhrs1 <= 10#$H && 10#$H <= 24 )) || (( 0 <= 10#$H && 10#$H < nachtladenbisuhrs1 )); then + if ((nachtladenabuhrs1 <= 10#$H && 10#$H <= 24)) || ((0 <= 10#$H && 10#$H < nachtladenbisuhrs1)); then nachtladenstates1=1 dayoftheweek=$(date +%w) currenthour=$(date +%k) - if [[ $dayoftheweek -eq 0 && $currenthour -ge 14 ]] || [[ $dayoftheweek -ge 1 && $dayoftheweek -le 4 ]] || [[ $dayoftheweek -eq 5 && $currenthour -le 11 ]] ; then + if [[ $dayoftheweek -eq 0 && $currenthour -ge 14 ]] || [[ $dayoftheweek -ge 1 && $dayoftheweek -le 4 ]] || [[ $dayoftheweek -eq 5 && $currenthour -le 11 ]]; then diesersocs1=$nachtsocs1 else diesersocs1=$nachtsoc1s1 fi if [[ $socmodul1 != "none" ]]; then - openwbDebugLog "MAIN" 1 "nachtladen mit socmodul $socmodul1" - if (( soc1 <= diesersocs1 )); then + openwbDebugLog "MAIN" 1 "Nachtladen mit SoC-Modul $socmodul1" + if ((soc1 <= diesersocs1)); then if grep -q 0 "/var/www/html/openWB/ramdisk/ladestatuss1"; then llnachts1neu=$nachtlls1 - #runs/set-current.sh "$nachtlls1" s1 - openwbDebugLog "MAIN" 1 "soc $soc1 ladeleistung nachtladen bei $nachtlls1" + openwbDebugLog "MAIN" 1 "SoC $soc1 Ladeleistung Nachtladen bei $nachtlls1" fi - if ! grep -q $nachtlls1 "/var/www/html/openWB/ramdisk/llsolls1"; then + if ! grep -q "$nachtlls1" "/var/www/html/openWB/ramdisk/llsolls1"; then llnachts1neu=$nachtlls1 - #runs/set-current.sh "$nachtlls1" s1 - openwbDebugLog "MAIN" 1 "aendere nacht Ladeleistung auf $nachtlls1" + openwbDebugLog "MAIN" 1 "aendere Nacht-Ladeleistung auf $nachtlls1" fi else if grep -q 1 "/var/www/html/openWB/ramdisk/ladestatuss1"; then llnachts1neu=0 - #runs/set-current.sh 0 s1 fi fi else if grep -q 0 "/var/www/html/openWB/ramdisk/ladestatuss1"; then llnachts1neu=$nachtlls1 - #runs/set-current.sh "$nachtlls1" s1 - openwbDebugLog "MAIN" 1 "soc $soc1 ladeleistung nachtladen $nachtlls1 A" + openwbDebugLog "MAIN" 1 "SoC $soc1 Ladeleistung Nachtladen $nachtlls1 A" openwbDebugLog "CHARGESTAT" 0 "start Nachtladung mit $nachtlls1" else - if ! grep -q $nachtlls1 "/var/www/html/openWB/ramdisk/llsolls1"; then + if ! grep -q "$nachtlls1" "/var/www/html/openWB/ramdisk/llsolls1"; then llnachts1neu=$nachtlls1 - #runs/set-current.sh "$nachtlls1" s1 - openwbDebugLog "MAIN" 1 "aendere nacht Ladeleistung auf $nachtlls1" + openwbDebugLog "MAIN" 1 "aendere Nacht-Ladeleistung auf $nachtlls1" fi fi fi @@ -323,19 +318,18 @@ nachtlademodus(){ else nachtladenstates1=0 fi - if (( nachtladen2abuhrs1 <= 10#$H )) && (( 10#$H < nachtladen2bisuhrs1 )); then + if ((nachtladen2abuhrs1 <= 10#$H)) && ((10#$H < nachtladen2bisuhrs1)); then nachtladen2states1=1 - dayoftheweek=$(date +%w) if grep -q 0 "/var/www/html/openWB/ramdisk/ladestatuss1"; then llnachts1neu=$nacht2lls1 #runs/set-current.sh "$nacht2lls1" s1 - openwbDebugLog "MAIN" 1 "soc $soc1 ladeleistung nachtladen $nacht2lls1 A" + openwbDebugLog "MAIN" 1 "SoC $soc1 Ladeleistung Nachtladen $nacht2lls1 A" else - if ! grep -q $nacht2lls1 "/var/www/html/openWB/ramdisk/llsolls1"; then + if ! grep -q "$nacht2lls1" "/var/www/html/openWB/ramdisk/llsolls1"; then llnachts1neu=$nacht2lls1 #runs/set-current.sh "$nacht2lls1" m - openwbDebugLog "MAIN" 1 "aendere nacht Ladeleistung auf $nacht2lls1" + openwbDebugLog "MAIN" 1 "aendere Nacht-Ladeleistung auf $nacht2lls1" fi fi if [ -z "$llnachts1neu" ]; then @@ -348,22 +342,22 @@ nachtlademodus(){ nachtladenstates1=0 nachtladen2states1=0 fi - echo $nachtladenstate > /var/www/html/openWB/ramdisk/nachtladenstate - echo $nachtladenstates1 > /var/www/html/openWB/ramdisk/nachtladenstates1 - echo $nachtladen2state > /var/www/html/openWB/ramdisk/nachtladen2state - echo $nachtladen2states1 > /var/www/html/openWB/ramdisk/nachtladen2states1 - if (( nachtladenstate == 1 )) || (( nachtladenstates1 == 1 )) || (( nachtladen2state == 1 )) || (( nachtladen2states1 == 1 )); then - if (( nachtladenstate == 1 )) || (( nachtladen2state == 1 )); then - lastmnacht $llalt $llnachtneu - if (( llnachtreturn != llalt )); then - runs/set-current.sh $llnachtreturn m + echo $nachtladenstate >/var/www/html/openWB/ramdisk/nachtladenstate + echo $nachtladenstates1 >/var/www/html/openWB/ramdisk/nachtladenstates1 + echo $nachtladen2state >/var/www/html/openWB/ramdisk/nachtladen2state + echo $nachtladen2states1 >/var/www/html/openWB/ramdisk/nachtladen2states1 + if ((nachtladenstate == 1)) || ((nachtladenstates1 == 1)) || ((nachtladen2state == 1)) || ((nachtladen2states1 == 1)); then + if ((nachtladenstate == 1)) || ((nachtladen2state == 1)); then + lastmnacht "$llalt" "$llnachtneu" + if ((llnachtreturn != llalt)); then + runs/set-current.sh "$llnachtreturn" m openwbDebugLog "CHARGESTAT" 0 "LP1, Lademodus Nachtladen. Ladung mit $llnachtreturn Ampere, $diesersoc % SoC" fi fi - if (( nachtladenstates1 == 1 )) || (( nachtladen2states1 == 1 )); then - lastmnacht $llalts1 $llnachts1neu - if (( llnachtreturn != llalts1 )); then - runs/set-current.sh $llnachtreturn s1 + if ((nachtladenstates1 == 1)) || ((nachtladen2states1 == 1)); then + lastmnacht "$llalts1" "$llnachts1neu" + if ((llnachtreturn != llalts1)); then + runs/set-current.sh "$llnachtreturn" s1 openwbDebugLog "CHARGESTAT" 0 "LP2, Lademodus Nachtladen. Ladung mit $llnachtreturn Ampere, $diesersocs1 % SoC" fi fi @@ -371,13 +365,13 @@ nachtlademodus(){ fi } -prenachtlademodus(){ - if { (( lademodus == 0 )) && (( nlakt_sofort == 1 )); } || { (( lademodus == 1 )) && (( nlakt_minpv == 1 )); } || { (( lademodus == 2 )) && (( nlakt_nurpv == 1 )); } || { (( lademodus == 4 )) && (( nlakt_standby == 1 )); } then +prenachtlademodus() { + if { ((lademodus == 0)) && ((nlakt_sofort == 1)); } || { ((lademodus == 1)) && ((nlakt_minpv == 1)); } || { ((lademodus == 2)) && ((nlakt_nurpv == 1)); } || { ((lademodus == 4)) && ((nlakt_standby == 1)); }; then nachtlademodus else - echo 0 > ramdisk/nachtladenstate - echo 0 > ramdisk/nachtladen2state - echo 0 > ramdisk/nachtladenstates1 - echo 0 > ramdisk/nachtladen2states1 + echo 0 >ramdisk/nachtladenstate + echo 0 >ramdisk/nachtladen2state + echo 0 >ramdisk/nachtladenstates1 + echo 0 >ramdisk/nachtladen2states1 fi } diff --git a/u1p3p.sh b/u1p3p.sh index add5e3fe7..fbc79c3f6 100755 --- a/u1p3p.sh +++ b/u1p3p.sh @@ -1,23 +1,23 @@ #!/bin/bash -u1p3pswitch(){ +u1p3pswitch() { - if (( u1p3paktiv == 1 )); then + if ((u1p3paktiv == 1)); then u1p3pstat=$( /var/www/html/openWB/ramdisk/urcounter + echo $urcounter >/var/www/html/openWB/ramdisk/urcounter else runs/u1p3pcheck.sh 1 openwbDebugLog "MAIN" 1 "Min PV Laden derzeit $u1p3pstat Phasen, auf 1 Nur PV konfiguriert, aendere..." - echo 0 > /var/www/html/openWB/ramdisk/urcounter + echo 0 >/var/www/html/openWB/ramdisk/urcounter fi fi else openwbDebugLog "MAIN" 1 "Min PV Laden derzeit $u1p3pstat Phasen, auf $u1p3pminundpv konfiguriert, aendere..." - if (( u1p3pnurpv == 3 )); then + if ((u1p3pnurpv == 3)); then runs/u1p3pcheck.sh 3 else runs/u1p3pcheck.sh 1 @@ -67,29 +67,29 @@ u1p3pswitch(){ fi fi fi - if (( lademodus == 2 )); then - if (( u1p3pstat != u1p3pnurpv )); then - if (( u1p3pnurpv == 4 )); then - if (( u1p3pstat == 0 )); then + if ((lademodus == 2)); then + if ((u1p3pstat != u1p3pnurpv)); then + if ((u1p3pnurpv == 4)); then + if ((u1p3pstat == 0)); then runs/u1p3pcheck.sh 1 fi - if (( u1p3pstat == 3 )); then + if ((u1p3pstat == 3)); then urcounter=$( /var/www/html/openWB/ramdisk/urcounter + echo $urcounter >/var/www/html/openWB/ramdisk/urcounter else runs/u1p3pcheck.sh 1 openwbDebugLog "MAIN" 1 "Nur PV Laden derzeit $u1p3pstat Phasen, auf 1 Nur PV konfiguriert, aendere..." - echo 0 > /var/www/html/openWB/ramdisk/urcounter + echo 0 >/var/www/html/openWB/ramdisk/urcounter fi fi else openwbDebugLog "MAIN" 1 "Nur PV Laden derzeit $u1p3pstat Phasen, auf $u1p3pnurpv konfiguriert, aendere..." - if (( u1p3pnurpv == 3 )); then + if ((u1p3pnurpv == 3)); then runs/u1p3pcheck.sh 3 else runs/u1p3pcheck.sh 1 @@ -98,10 +98,10 @@ u1p3pswitch(){ fi fi fi - if (( lademodus == 4 )); then - if (( u1p3pstat != u1p3pstandby )); then + if ((lademodus == 4)); then + if ((u1p3pstat != u1p3pstandby)); then openwbDebugLog "MAIN" 1 "Standby Laden derzeit $u1p3pstat Phasen, auf $u1p3pstandby konfiguriert, aendere..." - if (( u1p3pstandby == 3 )); then + if ((u1p3pstandby == 3)); then runs/u1p3pcheck.sh 3 else runs/u1p3pcheck.sh 1 @@ -109,10 +109,10 @@ u1p3pswitch(){ openwbDebugLog "MAIN" 1 "auf $u1p3pstandby Phasen geaendert" fi fi - if (( lademodus == 3 )); then - if (( u1p3pstat != u1p3pstandby )); then + if ((lademodus == 3)); then + if ((u1p3pstat != u1p3pstandby)); then openwbDebugLog "MAIN" 1 "Stop Laden derzeit $u1p3pstat Phasen, auf $u1p3pstandby konfiguriert, aendere..." - if (( u1p3pstandby == 3 )); then + if ((u1p3pstandby == 3)); then runs/u1p3pcheck.sh 3 else runs/u1p3pcheck.sh 1 @@ -122,252 +122,252 @@ u1p3pswitch(){ fi fi else - if (( nachtladenstate == 1 )) || (( nachtladen2state == 1 )) || (( nachtladenstates1 == 1 )) || (( nachtladen2states1 == 1 )); then - if (( u1p3pstat != u1p3pnl )); then + if ((nachtladenstate == 1)) || ((nachtladen2state == 1)) || ((nachtladenstates1 == 1)) || ((nachtladen2states1 == 1)); then + if ((u1p3pstat != u1p3pnl)); then openwbDebugLog "MAIN" 1 "Nachtladen derzeit $u1p3pstat Phasen, auf $u1p3pnl konfiguriert, unterbreche Ladung und aendere..." - echo 1 > ramdisk/blockall + echo 1 >ramdisk/blockall runs/u1p3pcheck.sh stop sleep 5 - if (( u1p3pnl == 3 )); then + if ((u1p3pnl == 3)); then runs/u1p3pcheck.sh 3 else runs/u1p3pcheck.sh 1 fi sleep 1 runs/u1p3pcheck.sh start - echo 0 > ramdisk/blockall + echo 0 >ramdisk/blockall openwbDebugLog "MAIN" 1 "auf $u1p3pnl Phasen geaendert" fi else - if (( lademodus == 0 )); then - if (( u1p3pstat != u1p3psofort )); then + if ((lademodus == 0)); then + if ((u1p3pstat != u1p3psofort)); then openwbDebugLog "MAIN" 1 "Sofortladen derzeit $u1p3pstat Phasen, auf $u1p3psofort konfiguriert, unterbreche Ladung und aendere..." - echo 1 > ramdisk/blockall + echo 1 >ramdisk/blockall runs/u1p3pcheck.sh stop sleep 5 - if (( u1p3psofort == 3 )); then + if ((u1p3psofort == 3)); then runs/u1p3pcheck.sh 3 else runs/u1p3pcheck.sh 1 fi sleep 1 runs/u1p3pcheck.sh start - echo 0 > ramdisk/blockall + echo 0 >ramdisk/blockall openwbDebugLog "MAIN" 1 "auf $u1p3psofort Phasen geaendert" fi fi - if (( lademodus == 1 )); then - if (( u1p3pstat != u1p3pminundpv )); then - if (( u1p3pminundpv == 4 )); then + if ((lademodus == 1)); then + if ((u1p3pstat != u1p3pminundpv)); then + if ((u1p3pminundpv == 4)); then oldll=$( ((3 * mindestuberschuss) + 1000) )); then + if ((ladeleistung < 100)); then + if ((uberschuss > ((3 * mindestuberschuss) + 1000))); then openwbDebugLog "MAIN" 1 "Min PV Laden derzeit $u1p3pstat Phasen, auf MinPV Automatik konfiguriert, aendere auf 3 Phasen da viel Überschuss vorhanden..." - echo 1 > ramdisk/blockall + echo 1 >ramdisk/blockall runs/u1p3pcheck.sh stop sleep 8 runs/u1p3pcheck.sh 3 sleep 20 runs/u1p3pcheck.sh startslow - (sleep 25 && echo 0 > ramdisk/blockall)& + (sleep 25 && echo 0 >ramdisk/blockall) & openwbDebugLog "MAIN" 1 "auf 3 Phasen MinPV Automatik geaendert" fi fi - if (( oldll == maximalstromstaerke )); then + if ((oldll == maximalstromstaerke)); then uhcounter=$( 500 )); then + if ((uhcounter < uhwaittime)); then + if ((maximalstromstaerke == 16)); then + if ((uberschuss > 500)); then uhcounter=$((uhcounter + 10)) - echo $uhcounter > /var/www/html/openWB/ramdisk/uhcounter + echo $uhcounter >/var/www/html/openWB/ramdisk/uhcounter openwbDebugLog "MAIN" 1 "Umschaltcounter Erhoehung auf $uhcounter erhoeht fuer Min PV Automatik Phasenumschaltung, genug uberschuss fuer 3 Phasen Ladung" else openwbDebugLog "MAIN" 1 "Umschaltcounter nicht erhöht fuer Min PV Automatik Phasenumschaltung, fehlender uberschuss fuer 3 Phasen Ladung" fi else uhcounter=$((uhcounter + 10)) - echo $uhcounter > /var/www/html/openWB/ramdisk/uhcounter + echo $uhcounter >/var/www/html/openWB/ramdisk/uhcounter openwbDebugLog "MAIN" 1 "Umschaltcounter Erhoehung auf $uhcounter erhoeht fuer Min PV Automatik Phasenumschaltung" fi else openwbDebugLog "MAIN" 1 "Min PV Laden derzeit $u1p3pstat Phasen, auf MinPV Automatik konfiguriert, unterbreche Ladung und aendere auf 3 Phasen..." - echo 1 > ramdisk/blockall + echo 1 >ramdisk/blockall runs/u1p3pcheck.sh stop sleep 8 runs/u1p3pcheck.sh 3 sleep 20 runs/u1p3pcheck.sh startslow - (sleep 25 && echo 0 > ramdisk/blockall)& + (sleep 25 && echo 0 >ramdisk/blockall) & openwbDebugLog "MAIN" 1 "auf 3 Phasen MinPV Automatik geaendert" - echo 0 > /var/www/html/openWB/ramdisk/uhcounter + echo 0 >/var/www/html/openWB/ramdisk/uhcounter fi else - echo 0 > /var/www/html/openWB/ramdisk/uhcounter + echo 0 >/var/www/html/openWB/ramdisk/uhcounter fi else - if (( ladeleistung < 100 )); then - if (( uberschuss < (3 * mindestuberschuss) )); then - echo 0 > /var/www/html/openWB/ramdisk/urcounter - echo 1 > ramdisk/blockall + if ((ladeleistung < 100)); then + if ((uberschuss < (3 * mindestuberschuss))); then + echo 0 >/var/www/html/openWB/ramdisk/urcounter + echo 1 >ramdisk/blockall runs/u1p3pcheck.sh stop sleep 8 runs/u1p3pcheck.sh 1 sleep 20 runs/u1p3pcheck.sh startslow - (sleep 25 && echo 0 > ramdisk/blockall)& + (sleep 25 && echo 0 >ramdisk/blockall) & openwbDebugLog "MAIN" 1 "auf 1 Phasen MinPV Automatik geaendert da geringerer Überschuss" fi fi - if (( oldll == minimalampv )) && (( ladeleistung > 100 )); then + if ((oldll == minimalampv)) && ((ladeleistung > 100)); then urcounter=$( /var/www/html/openWB/ramdisk/urcounter + echo $urcounter >/var/www/html/openWB/ramdisk/urcounter openwbDebugLog "MAIN" 1 "Umschaltcounter Reduzierung auf $urcounter erhoeht fuer Min PV Automatik Phasenumschaltung" else - echo 0 > /var/www/html/openWB/ramdisk/urcounter - echo 1 > ramdisk/blockall + echo 0 >/var/www/html/openWB/ramdisk/urcounter + echo 1 >ramdisk/blockall runs/u1p3pcheck.sh stop sleep 8 runs/u1p3pcheck.sh 1 sleep 20 runs/u1p3pcheck.sh startslow - (sleep 25 && echo 0 > ramdisk/blockall)& + (sleep 25 && echo 0 >ramdisk/blockall) & openwbDebugLog "MAIN" 1 "auf 1 Phasen MinPV Automatik geaendert" fi else - echo 0 > /var/www/html/openWB/ramdisk/urcounter + echo 0 >/var/www/html/openWB/ramdisk/urcounter fi fi else openwbDebugLog "MAIN" 1 "Min PV Laden derzeit $u1p3pstat Phasen, auf $u1p3pminundpv konfiguriert, unterbreche Ladung und aendere..." - echo 1 > ramdisk/blockall + echo 1 >ramdisk/blockall runs/u1p3pcheck.sh stop sleep 5 - if (( u1p3pminundpv == 3 )); then + if ((u1p3pminundpv == 3)); then runs/u1p3pcheck.sh 3 else runs/u1p3pcheck.sh 1 fi sleep 1 runs/u1p3pcheck.sh start - echo 0 > ramdisk/blockall + echo 0 >ramdisk/blockall openwbDebugLog "MAIN" 1 "auf $u1p3pminundpv Phasen geaendert" fi fi fi - if (( lademodus == 2 )); then - if (( u1p3pstat != u1p3pnurpv )); then - if (( u1p3pnurpv == 4 )); then + if ((lademodus == 2)); then + if ((u1p3pstat != u1p3pnurpv)); then + if ((u1p3pnurpv == 4)); then oldll=$( ((3 * mindestuberschuss) + 1000) )); then + if ((ladeleistung < 100)); then + if ((uberschuss > ((3 * mindestuberschuss) + 1000))); then openwbDebugLog "MAIN" 1 "Nur PV Laden derzeit $u1p3pstat Phasen, auf NurPV Automatik konfiguriert, aendere auf 3 Phasen da viel Überschuss vorhanden..." - echo 1 > ramdisk/blockall + echo 1 >ramdisk/blockall runs/u1p3pcheck.sh stop sleep 8 runs/u1p3pcheck.sh 3 sleep 20 runs/u1p3pcheck.sh startslow - (sleep 25 && echo 0 > ramdisk/blockall)& + (sleep 25 && echo 0 >ramdisk/blockall) & openwbDebugLog "MAIN" 1 "auf 3 Phasen NurPV Automatik geaendert" fi fi - if (( oldll == maximalstromstaerke )); then + if ((oldll == maximalstromstaerke)); then uhcounter=$( /var/www/html/openWB/ramdisk/uhcounter + echo $uhcounter >/var/www/html/openWB/ramdisk/uhcounter openwbDebugLog "MAIN" 1 "Umschaltcounter Erhoehung auf $uhcounter erhoeht fuer PV Automatik Phasenumschaltung" else openwbDebugLog "MAIN" 1 "Nur PV Laden derzeit $u1p3pstat Phasen, auf NurPV Automatik konfiguriert, unterbreche Ladung und aendere auf 3 Phasen..." - echo 1 > ramdisk/blockall + echo 1 >ramdisk/blockall runs/u1p3pcheck.sh stop sleep 8 runs/u1p3pcheck.sh 3 sleep 20 runs/u1p3pcheck.sh startslow - (sleep 25 && echo 0 > ramdisk/blockall)& + (sleep 25 && echo 0 >ramdisk/blockall) & openwbDebugLog "MAIN" 1 "auf 3 Phasen NurPV Automatik geaendert" - echo 0 > /var/www/html/openWB/ramdisk/uhcounter + echo 0 >/var/www/html/openWB/ramdisk/uhcounter fi else - echo 0 > /var/www/html/openWB/ramdisk/uhcounter + echo 0 >/var/www/html/openWB/ramdisk/uhcounter fi else - if (( ladeleistung < 100 )); then - if (( uberschuss < (3 * mindestuberschuss) )); then - echo 0 > /var/www/html/openWB/ramdisk/urcounter - echo 1 > ramdisk/blockall + if ((ladeleistung < 100)); then + if ((uberschuss < (3 * mindestuberschuss))); then + echo 0 >/var/www/html/openWB/ramdisk/urcounter + echo 1 >ramdisk/blockall runs/u1p3pcheck.sh stop sleep 8 runs/u1p3pcheck.sh 1 sleep 20 runs/u1p3pcheck.sh startslow - (sleep 25 && echo 0 > ramdisk/blockall)& + (sleep 25 && echo 0 >ramdisk/blockall) & openwbDebugLog "MAIN" 1 "auf 1 Phasen NurPV Automatik geaendert da geringerer Überschuss" fi fi - if (( oldll == minimalapv )) && (( ladeleistung > 100 )); then + if ((oldll == minimalapv)) && ((ladeleistung > 100)); then urcounter=$( /var/www/html/openWB/ramdisk/urcounter + echo $urcounter >/var/www/html/openWB/ramdisk/urcounter openwbDebugLog "MAIN" 1 "Umschaltcounter Reduzierung auf $urcounter erhoeht fuer PV Automatik Phasenumschaltung" else - echo 0 > /var/www/html/openWB/ramdisk/urcounter - echo 1 > ramdisk/blockall + echo 0 >/var/www/html/openWB/ramdisk/urcounter + echo 1 >ramdisk/blockall runs/u1p3pcheck.sh stop sleep 8 runs/u1p3pcheck.sh 1 sleep 20 runs/u1p3pcheck.sh startslow - (sleep 25 && echo 0 > ramdisk/blockall)& + (sleep 25 && echo 0 >ramdisk/blockall) & openwbDebugLog "MAIN" 1 "auf 1 Phasen NurPV Automatik geaendert" fi else - echo 0 > /var/www/html/openWB/ramdisk/urcounter + echo 0 >/var/www/html/openWB/ramdisk/urcounter fi fi else openwbDebugLog "MAIN" 1 "Nur PV Laden derzeit $u1p3pstat Phasen, auf $u1p3pnurpv konfiguriert, unterbreche Ladung und aendere..." - echo 1 > ramdisk/blockall + echo 1 >ramdisk/blockall runs/u1p3pcheck.sh stop sleep 5 - if (( u1p3pnurpv == 3 )); then + if ((u1p3pnurpv == 3)); then runs/u1p3pcheck.sh 3 else runs/u1p3pcheck.sh 1 fi sleep 1 runs/u1p3pcheck.sh start - echo 0 > ramdisk/blockall + echo 0 >ramdisk/blockall openwbDebugLog "MAIN" 1 "auf $u1p3pnurpv Phasen geaendert" fi fi fi - if (( lademodus == 4 )); then - if (( u1p3pstat != u1p3pstandby )); then + if ((lademodus == 4)); then + if ((u1p3pstat != u1p3pstandby)); then openwbDebugLog "MAIN" 1 "Standby Laden derzeit $u1p3pstat Phasen, auf $u1p3pstandby konfiguriert, unterbreche Ladung und aendere..." - echo 1 > ramdisk/blockall + echo 1 >ramdisk/blockall runs/u1p3pcheck.sh stop sleep 5 - if (( u1p3pstandby == 3 )); then + if ((u1p3pstandby == 3)); then runs/u1p3pcheck.sh 3 else runs/u1p3pcheck.sh 1 fi sleep 1 runs/u1p3pcheck.sh start - echo 0 > ramdisk/blockall + echo 0 >ramdisk/blockall openwbDebugLog "MAIN" 1 "auf $u1p3pstandby Phasen geaendert" fi fi