diff --git a/goecheck.sh b/goecheck.sh index 701174a60..3cb1e9f7f 100755 --- a/goecheck.sh +++ b/goecheck.sh @@ -2,35 +2,59 @@ goecheck(){ ####################################### #goe mobility check + digit='^[0-9]$' + if [[ $evsecon == "goe" ]]; then output=$(curl --connect-timeout 1 -s http://$goeiplp1/status) if [[ $? == "0" ]] ; then - state=$(echo $output | jq -r '.alw') - if grep -q 1 "/var/www/html/openWB/ramdisk/ladestatus"; then - lp1enabled=$( /dev/null + #check whether goe has 1to3phase switch capability => new HWV3 and new API V2 + fsp=$(echo $output | jq -r '.fsp') + if [[ ! $fsp =~ $digit ]] ; then + state=$(echo $output | jq -r '.alw') + if grep -q 1 "/var/www/html/openWB/ramdisk/ladestatus"; then + lp1enabled=$( /dev/null + fi fi - fi - if grep -q 0 "/var/www/html/openWB/ramdisk/ladestatus"; then - if ((state == "1")) ; then - curl --silent --connect-timeout $goetimeoutlp1 -s http://$goeiplp1/mqtt?payload=alw=0 > /dev/null + if grep -q 0 "/var/www/html/openWB/ramdisk/ladestatus"; then + if ((state == "1")) ; then + curl --silent --connect-timeout $goetimeoutlp1 -s http://$goeiplp1/mqtt?payload=alw=0 > /dev/null + fi fi - fi - - version=$(echo $output | jq -r '.fwv') # get firmware version - majorVersion=${version%.*} # remove everything after a "." - majorVersion=${majorVersion%-*} # remove everything after a "-" - majorVersion=${majorVersion#0} # remove leading "0" + version=$(echo $output | jq -r '.fwv') # get firmware version + majorVersion=${version%.*} # remove everything after a "." + majorVersion=${majorVersion%-*} # remove everything after a "-" + majorVersion=${majorVersion#0} # remove leading "0" - oldcurrent=$(echo $output | jq -r '.amp') - current=$(= 40)) ; then - curl --silent --connect-timeout $goetimeoutlp1 -s http://$goeiplp1/mqtt?payload=amx=$current > /dev/null - else - curl --silent --connect-timeout $goetimeoutlp1 -s http://$goeiplp1/mqtt?payload=amp=$current > /dev/null + oldcurrent=$(echo $output | jq -r '.amp') + current=$(= 40)) ; then + curl --silent --connect-timeout $goetimeoutlp1 -s http://$goeiplp1/mqtt?payload=amx=$current > /dev/null + else + curl --silent --connect-timeout $goetimeoutlp1 -s http://$goeiplp1/mqtt?payload=amp=$current > /dev/null + fi + fi + else + output=$(curl --connect-timeout 1 -s http://$goeiplp1/api/status) + state=$(echo $output | jq -r '.frc') + if grep -q 1 "/var/www/html/openWB/ramdisk/ladestatus"; then + lp1enabled=$( /dev/null + fi + fi + if grep -q 0 "/var/www/html/openWB/ramdisk/ladestatus"; then + if (( state == "0" )) || (( state == "2" )) ; then + curl --silent --connect-timeout $goetimeoutlp1 -s http://$goeiplp1/api/set?frc=1 > /dev/null + fi + fi + oldcurrent=$(echo $output | jq -r '.amp') + current=$( /dev/null fi fi fi @@ -39,43 +63,68 @@ goecheck(){ if [[ $evsecons1 == "goe" ]]; then output=$(curl --connect-timeout 1 -s http://$goeiplp2/status) if [[ $? == "0" ]] ; then - state=$(echo $output | jq -r '.alw') - if grep -q 1 "/var/www/html/openWB/ramdisk/ladestatuss1"; then - lp2enabled=$( /dev/null + #check whether goe has 1to3phase switch capability => new HWV3 and new API V2 + fsp=$(echo $output | jq -r '.fsp') + if [[ ! $fsp =~ $digit ]] ; then + state=$(echo $output | jq -r '.alw') + if grep -q 1 "/var/www/html/openWB/ramdisk/ladestatuss1"; then + lp2enabled=$( /dev/null + fi fi - fi - if grep -q 0 "/var/www/html/openWB/ramdisk/ladestatuss1"; then - if ((state == "1")) ; then - curl --silent --connect-timeout $goetimeoutlp2 -s http://$goeiplp2/mqtt?payload=alw=0 > /dev/null + if grep -q 0 "/var/www/html/openWB/ramdisk/ladestatuss1"; then + if ((state == "1")) ; then + curl --silent --connect-timeout $goetimeoutlp2 -s http://$goeiplp2/mqtt?payload=alw=0 > /dev/null + fi fi - fi - - version=$(echo $output | jq -r '.fwv') # get firmware version - majorVersion=${version%.*} # remove everything after a "." - majorVersion=${majorVersion%-*} # remove everything after a "-" - majorVersion=${majorVersion#0} # remove leading "0" + version=$(echo $output | jq -r '.fwv') # get firmware version + majorVersion=${version%.*} # remove everything after a "." + majorVersion=${majorVersion%-*} # remove everything after a "-" + majorVersion=${majorVersion#0} # remove leading "0" - oldcurrent=$(echo $output | jq -r '.amp') - current=$(= 40)) ; then - curl --silent --connect-timeout $goetimeoutlp2 -s http://$goeiplp2/mqtt?payload=amx=$current > /dev/null - else - curl --silent --connect-timeout $goetimeoutlp2 -s http://$goeiplp2/mqtt?payload=amp=$current > /dev/null + oldcurrent=$(echo $output | jq -r '.amp') + current=$(= 40)) ; then + curl --silent --connect-timeout $goetimeoutlp2 -s http://$goeiplp2/mqtt?payload=amx=$current > /dev/null + else + curl --silent --connect-timeout $goetimeoutlp2 -s http://$goeiplp2/mqtt?payload=amp=$current > /dev/null + fi + fi + else + output=$(curl --connect-timeout 1 -s http://$goeiplp2/api/status) + state=$(echo $output | jq -r '.frc') + if grep -q 1 "/var/www/html/openWB/ramdisk/ladestatuss1"; then + lp2enabled=$( /dev/null + fi + fi + if grep -q 0 "/var/www/html/openWB/ramdisk/ladestatuss1"; then + if (( state == "0" )) || (( state == "2" )) ; then + curl --silent --connect-timeout $goetimeoutlp2 -s http://$goeiplp2/api/set?frc=1 > /dev/null + fi + fi + oldcurrent=$(echo $output | jq -r '.amp') + current=$( /dev/null fi fi fi fi if [[ $lastmanagements2 == "1" ]]; then if [[ $evsecons2 == "goe" ]]; then - output=$(curl --connect-timeout 1 -s http://$goeiplp3/status) - if [[ $? == "0" ]] ; then + output=$(curl --connect-timeout 1 -s http://$goeiplp3/status) + if [[ $? == "0" ]] ; then + #check whether goe has 1to3phase switch capability => new HWV3 and new API V2 + fsp=$(echo $output | jq -r '.fsp') + if [[ ! $fsp =~ $digit ]] ; then state=$(echo $output | jq -r '.alw') if grep -q 1 "/var/www/html/openWB/ramdisk/ladestatuss2"; then lp3enabled=$( /dev/null fi fi @@ -85,10 +134,10 @@ goecheck(){ fi fi - version=$(echo $output | jq -r '.fwv') # get firmware version - majorVersion=${version%.*} # remove everything after a "." - majorVersion=${majorVersion%-*} # remove everything after a "-" - majorVersion=${majorVersion#0} # remove leading "0" + version=$(echo $output | jq -r '.fwv') # get firmware version + majorVersion=${version%.*} # remove everything after a "." + majorVersion=${majorVersion%-*} # remove everything after a "-" + majorVersion=${majorVersion#0} # remove leading "0" oldcurrent=$(echo $output | jq -r '.amp') current=$( /dev/null fi fi + else + output=$(curl --connect-timeout 1 -s http://$goeiplp3/api/status) + state=$(echo $output | jq -r '.frc') + if grep -q 1 "/var/www/html/openWB/ramdisk/ladestatuss2"; then + lp3enabled=$( /dev/null + fi + fi + if grep -q 0 "/var/www/html/openWB/ramdisk/ladestatuss2"; then + if (( state == "0" )) || (( state == "2" )) ; then + curl --silent --connect-timeout $goetimeoutlp3 -s http://$goeiplp3/api/set?frc=1 > /dev/null + fi + fi + oldcurrent=$(echo $output | jq -r '.amp') + current=$( /dev/null + fi fi fi + fi fi fi } diff --git a/modules/goelp1/main.sh b/modules/goelp1/main.sh index 80b9455ad..6bc752488 100755 --- a/modules/goelp1/main.sh +++ b/modules/goelp1/main.sh @@ -4,62 +4,131 @@ rekwh='^[-+]?[0-9]+\.?[0-9]*$' output=$(curl --connect-timeout $goetimeoutlp1 -s http://$goeiplp1/status) if [[ $? == "0" ]] ; then - watt=$(echo $output | jq -r '.nrg[11]') - watt=$(echo "scale=0;$watt * 10 /1" |bc) - if [[ $watt =~ $re ]] ; then - echo $watt > /var/www/html/openWB/ramdisk/llaktuell - fi - lla1=$(echo $output | jq -r '.nrg[4]') - lla1=$(echo "scale=0;$lla1 / 10" |bc) - if [[ $lla1 =~ $re ]] ; then - echo $lla1 > /var/www/html/openWB/ramdisk/lla1 - fi - lla2=$(echo $output | jq -r '.nrg[5]') - lla2=$(echo "scale=0;$lla2 / 10" |bc) - if [[ $lla2 =~ $re ]] ; then - echo $lla2 > /var/www/html/openWB/ramdisk/lla2 - fi - lla3=$(echo $output | jq -r '.nrg[6]') - lla3=$(echo "scale=0;$lla3 / 10" |bc) - if [[ $lla3 =~ $re ]] ; then - echo $lla3 > /var/www/html/openWB/ramdisk/lla3 - fi - llv1=$(echo $output | jq -r '.nrg[0]') - if [[ $llv1 =~ $re ]] ; then - echo $llv1 > /var/www/html/openWB/ramdisk/llv1 - fi - llv2=$(echo $output | jq -r '.nrg[1]') - if [[ $llv2 =~ $re ]] ; then - echo $llv2 > /var/www/html/openWB/ramdisk/llv2 - fi - llv3=$(echo $output | jq -r '.nrg[2]') - if [[ $llv3 =~ $re ]] ; then - echo $llv3 > /var/www/html/openWB/ramdisk/llv3 - fi - llkwh=$(echo $output | jq -r '.eto') - llkwh=$(echo "scale=3;$llkwh / 10" |bc) - if [[ $llkwh =~ $rekwh ]] ; then - echo $llkwh > /var/www/html/openWB/ramdisk/llkwh - fi - rfid=$(echo $output | jq -r '.uby') - oldrfid=$( /var/www/html/openWB/ramdisk/readtag - echo $rfid > /var/www/html/openWB/ramdisk/tmpgoelp1rfid - fi - #car status 1 Ladestation bereit, kein Auto - #car status 2 Auto lädt - #car status 3 Warte auf Fahrzeug - #car status 4 Ladung beendet, Fahrzeug verbunden - car=$(echo $output | jq -r '.car') - if [[ $car == "1" ]] ; then - echo 0 > /var/www/html/openWB/ramdisk/plugstat - else - echo 1 > /var/www/html/openWB/ramdisk/plugstat - fi - if [[ $car == "2" ]] ; then - echo 1 > /var/www/html/openWB/ramdisk/chargestat + #check whether goe has 1to3phase switch capability => new HWV3 and new API V2 + fsp=$(echo $output | jq -r '.fsp') + if [[ ! $fsp =~ $re ]] ; then + watt=$(echo $output | jq -r '.nrg[11]') + watt=$(echo "scale=0;$watt * 10 /1" |bc) + if [[ $watt =~ $re ]] ; then + echo $watt > /var/www/html/openWB/ramdisk/llaktuell + fi + lla1=$(echo $output | jq -r '.nrg[4]') + lla1=$(echo "scale=0;$lla1 / 10" |bc) + if [[ $lla1 =~ $re ]] ; then + echo $lla1 > /var/www/html/openWB/ramdisk/lla1 + fi + lla2=$(echo $output | jq -r '.nrg[5]') + lla2=$(echo "scale=0;$lla2 / 10" |bc) + if [[ $lla2 =~ $re ]] ; then + echo $lla2 > /var/www/html/openWB/ramdisk/lla2 + fi + lla3=$(echo $output | jq -r '.nrg[6]') + lla3=$(echo "scale=0;$lla3 / 10" |bc) + if [[ $lla3 =~ $re ]] ; then + echo $lla3 > /var/www/html/openWB/ramdisk/lla3 + fi + llv1=$(echo $output | jq -r '.nrg[0]') + if [[ $llv1 =~ $re ]] ; then + echo $llv1 > /var/www/html/openWB/ramdisk/llv1 + fi + llv2=$(echo $output | jq -r '.nrg[1]') + if [[ $llv2 =~ $re ]] ; then + echo $llv2 > /var/www/html/openWB/ramdisk/llv2 + fi + llv3=$(echo $output | jq -r '.nrg[2]') + if [[ $llv3 =~ $re ]] ; then + echo $llv3 > /var/www/html/openWB/ramdisk/llv3 + fi + llkwh=$(echo $output | jq -r '.eto') + llkwh=$(echo "scale=3;$llkwh / 10" |bc) + if [[ $llkwh =~ $rekwh ]] ; then + echo $llkwh > /var/www/html/openWB/ramdisk/llkwh + fi + rfid=$(echo $output | jq -r '.uby') + oldrfid=$( /var/www/html/openWB/ramdisk/readtag + echo $rfid > /var/www/html/openWB/ramdisk/tmpgoelp1rfid + fi + #car status 1 Ladestation bereit, kein Auto + #car status 2 Auto lädt + #car status 3 Warte auf Fahrzeug + #car status 4 Ladung beendet, Fahrzeug verbunden + car=$(echo $output | jq -r '.car') + if [[ $car == "1" ]] ; then + echo 0 > /var/www/html/openWB/ramdisk/plugstat + else + echo 1 > /var/www/html/openWB/ramdisk/plugstat + fi + if [[ $car == "2" ]] ; then + echo 1 > /var/www/html/openWB/ramdisk/chargestat + else + echo 0 > /var/www/html/openWB/ramdisk/chargestat + fi else - echo 0 > /var/www/html/openWB/ramdisk/chargestat + output=$(curl --connect-timeout $goetimeoutlp1 -s http://$goeiplp1/api/status) + if [[ $? == "0" ]] ; then + watt=$(echo $output | jq -r '.nrg[11]') + watt=$(echo "scale=0;$watt /1" |bc) + if [[ $watt =~ $re ]] ; then + echo $watt > /var/www/html/openWB/ramdisk/llaktuell + fi + lla1=$(echo $output | jq -r '.nrg[4]') + lla1=$(echo "scale=0;$lla1" |bc) + if [[ $lla1 =~ $rekwh ]] ; then + echo $lla1 > /var/www/html/openWB/ramdisk/lla1 + fi + lla2=$(echo $output | jq -r '.nrg[5]') + lla2=$(echo "scale=0;$lla2" |bc) + if [[ $lla2 =~ $rekwh ]] ; then + echo $lla2 > /var/www/html/openWB/ramdisk/lla2 + fi + lla3=$(echo $output | jq -r '.nrg[6]') + lla3=$(echo "scale=0;$lla3" |bc) + if [[ $lla3 =~ $rekwh ]] ; then + echo $lla3 > /var/www/html/openWB/ramdisk/lla3 + fi + llv1=$(echo $output | jq -r '.nrg[0]') + if [[ $llv1 =~ $re ]] ; then + echo $llv1 > /var/www/html/openWB/ramdisk/llv1 + fi + llv2=$(echo $output | jq -r '.nrg[1]') + if [[ $llv2 =~ $re ]] ; then + echo $llv2 > /var/www/html/openWB/ramdisk/llv2 + fi + llv3=$(echo $output | jq -r '.nrg[2]') + if [[ $llv3 =~ $re ]] ; then + echo $llv3 > /var/www/html/openWB/ramdisk/llv3 + fi + llkwh=$(echo $output | jq -r '.eto') + llkwh=$(echo "scale=3;$llkwh / 1000" |bc) + if [[ $llkwh =~ $rekwh ]] ; then + echo $llkwh > /var/www/html/openWB/ramdisk/llkwh + fi + rfid=$(echo $output | jq -r '.trx') + if [[ $rfid == "null" ]] ; then + rfid="0" + fi + oldrfid=$( /var/www/html/openWB/ramdisk/readtag + echo $rfid > /var/www/html/openWB/ramdisk/tmpgoelprfid + fi + #car status 1 Ladestation bereit, kein Auto + #car status 2 Auto lädt + #car status 3 Warte auf Fahrzeug + #car status 4 Ladung beendet, Fahrzeug verbunden + car=$(echo $output | jq -r '.car') + if [[ $car == "2" ]] || [[ $car == "3" ]] || [[ $car == "4" ]] ; then + echo 1 > /var/www/html/openWB/ramdisk/plugstat + else + echo 0 > /var/www/html/openWB/ramdisk/plugstat + fi + if [[ $car == "2" ]] ; then + echo 1 > /var/www/html/openWB/ramdisk/chargestat + else + echo 0 > /var/www/html/openWB/ramdisk/chargestat + fi + fi fi -fi \ No newline at end of file +fi diff --git a/modules/goelp2/main.sh b/modules/goelp2/main.sh index e830d6e97..4900364cf 100755 --- a/modules/goelp2/main.sh +++ b/modules/goelp2/main.sh @@ -4,62 +4,131 @@ rekwh='^[-+]?[0-9]+\.?[0-9]*$' output=$(curl --connect-timeout $goetimeoutlp2 -s http://$goeiplp2/status) if [[ $? == "0" ]] ; then - watt=$(echo $output | jq -r '.nrg[11]') - watt=$(echo "scale=0;$watt * 10 /1" |bc) - if [[ $watt =~ $re ]] ; then - echo $watt > /var/www/html/openWB/ramdisk/llaktuells1 - fi - lla1=$(echo $output | jq -r '.nrg[4]') - lla1=$(echo "scale=0;$lla1 / 10" |bc) - if [[ $lla1 =~ $re ]] ; then - echo $lla1 > /var/www/html/openWB/ramdisk/llas11 - fi - lla2=$(echo $output | jq -r '.nrg[5]') - lla2=$(echo "scale=0;$lla2 / 10" |bc) - if [[ $lla2 =~ $re ]] ; then - echo $lla2 > /var/www/html/openWB/ramdisk/llas12 - fi - lla3=$(echo $output | jq -r '.nrg[6]') - lla3=$(echo "scale=0;$lla3 / 10" |bc) - if [[ $lla3 =~ $re ]] ; then - echo $lla3 > /var/www/html/openWB/ramdisk/llas13 - fi - llv1=$(echo $output | jq -r '.nrg[0]') - if [[ $llv1 =~ $re ]] ; then - echo $llv1 > /var/www/html/openWB/ramdisk/llvs11 - fi - llv2=$(echo $output | jq -r '.nrg[1]') - if [[ $llv2 =~ $re ]] ; then - echo $llv2 > /var/www/html/openWB/ramdisk/llvs12 - fi - llv3=$(echo $output | jq -r '.nrg[2]') - if [[ $llv3 =~ $re ]] ; then - echo $llv3 > /var/www/html/openWB/ramdisk/llvs13 - fi - llkwh=$(echo $output | jq -r '.eto') - llkwh=$(echo "scale=3;$llkwh / 10" |bc) - if [[ $llkwh =~ $rekwh ]] ; then - echo $llkwh > /var/www/html/openWB/ramdisk/llkwhs1 - fi - rfid=$(echo $output | jq -r '.uby') - oldrfid=$( /var/www/html/openWB/ramdisk/readtag - echo $rfid > /var/www/html/openWB/ramdisk/tmpgoelp2rfid - fi - #car status 1 Ladestation bereit, kein Auto - #car status 2 Auto lädt - #car status 3 Warte auf Fahrzeug - #car status 4 Ladung beendet, Fahrzeug verbunden - car=$(echo $output | jq -r '.car') - if [[ $car == "1" ]] ; then - echo 0 > /var/www/html/openWB/ramdisk/plugstats1 - else - echo 1 > /var/www/html/openWB/ramdisk/plugstats1 - fi - if [[ $car == "2" ]] ; then - echo 1 > /var/www/html/openWB/ramdisk/chargestats1 + #check whether goe has 1to3phase switch capability => new HWV3 and new API V2 + fsp=$(echo $output | jq -r '.fsp') + if [[ ! $fsp =~ $re ]] ; then + watt=$(echo $output | jq -r '.nrg[11]') + watt=$(echo "scale=0;$watt * 10 /1" |bc) + if [[ $watt =~ $re ]] ; then + echo $watt > /var/www/html/openWB/ramdisk/llaktuells1 + fi + lla1=$(echo $output | jq -r '.nrg[4]') + lla1=$(echo "scale=0;$lla1 / 10" |bc) + if [[ $lla1 =~ $re ]] ; then + echo $lla1 > /var/www/html/openWB/ramdisk/llas11 + fi + lla2=$(echo $output | jq -r '.nrg[5]') + lla2=$(echo "scale=0;$lla2 / 10" |bc) + if [[ $lla2 =~ $re ]] ; then + echo $lla2 > /var/www/html/openWB/ramdisk/llas12 + fi + lla3=$(echo $output | jq -r '.nrg[6]') + lla3=$(echo "scale=0;$lla3 / 10" |bc) + if [[ $lla3 =~ $re ]] ; then + echo $lla3 > /var/www/html/openWB/ramdisk/llas13 + fi + llv1=$(echo $output | jq -r '.nrg[0]') + if [[ $llv1 =~ $re ]] ; then + echo $llv1 > /var/www/html/openWB/ramdisk/llvs11 + fi + llv2=$(echo $output | jq -r '.nrg[1]') + if [[ $llv2 =~ $re ]] ; then + echo $llv2 > /var/www/html/openWB/ramdisk/llvs12 + fi + llv3=$(echo $output | jq -r '.nrg[2]') + if [[ $llv3 =~ $re ]] ; then + echo $llv3 > /var/www/html/openWB/ramdisk/llvs13 + fi + llkwh=$(echo $output | jq -r '.eto') + llkwh=$(echo "scale=3;$llkwh / 10" |bc) + if [[ $llkwh =~ $rekwh ]] ; then + echo $llkwh > /var/www/html/openWB/ramdisk/llkwhs1 + fi + rfid=$(echo $output | jq -r '.uby') + oldrfid=$( /var/www/html/openWB/ramdisk/readtag + echo $rfid > /var/www/html/openWB/ramdisk/tmpgoelp2rfid + fi + #car status 1 Ladestation bereit, kein Auto + #car status 2 Auto lädt + #car status 3 Warte auf Fahrzeug + #car status 4 Ladung beendet, Fahrzeug verbunden + car=$(echo $output | jq -r '.car') + if [[ $car == "1" ]] ; then + echo 0 > /var/www/html/openWB/ramdisk/plugstats1 + else + echo 1 > /var/www/html/openWB/ramdisk/plugstats1 + fi + if [[ $car == "2" ]] ; then + echo 1 > /var/www/html/openWB/ramdisk/chargestats1 + else + echo 0 > /var/www/html/openWB/ramdisk/chargestats1 + fi else - echo 0 > /var/www/html/openWB/ramdisk/chargestats1 + output=$(curl --connect-timeout $goetimeoutlp2 -s http://$goeiplp2/api/status) + if [[ $? == "0" ]] ; then + watt=$(echo $output | jq -r '.nrg[11]') + watt=$(echo "scale=0;$watt /1" |bc) + if [[ $watt =~ $re ]] ; then + echo $watt > /var/www/html/openWB/ramdisk/llaktuells1 + fi + lla1=$(echo $output | jq -r '.nrg[4]') + lla1=$(echo "scale=0;$lla1" |bc) + if [[ $lla1 =~ $rekwh ]] ; then + echo $lla1 > /var/www/html/openWB/ramdisk/llas11 + fi + lla2=$(echo $output | jq -r '.nrg[5]') + lla2=$(echo "scale=0;$lla2" |bc) + if [[ $lla2 =~ $rekwh ]] ; then + echo $lla2 > /var/www/html/openWB/ramdisk/llas12 + fi + lla3=$(echo $output | jq -r '.nrg[6]') + lla3=$(echo "scale=0;$lla3" |bc) + if [[ $lla3 =~ $rekwh ]] ; then + echo $lla3 > /var/www/html/openWB/ramdisk/llas13 + fi + llv1=$(echo $output | jq -r '.nrg[0]') + if [[ $llv1 =~ $re ]] ; then + echo $llv1 > /var/www/html/openWB/ramdisk/llvs11 + fi + llv2=$(echo $output | jq -r '.nrg[1]') + if [[ $llv2 =~ $re ]] ; then + echo $llv2 > /var/www/html/openWB/ramdisk/llvs12 + fi + llv3=$(echo $output | jq -r '.nrg[2]') + if [[ $llv3 =~ $re ]] ; then + echo $llv3 > /var/www/html/openWB/ramdisk/llvs13 + fi + llkwh=$(echo $output | jq -r '.eto') + llkwh=$(echo "scale=3;$llkwh / 1000" |bc) + if [[ $llkwh =~ $rekwh ]] ; then + echo $llkwh > /var/www/html/openWB/ramdisk/llkwhs1 + fi + rfid=$(echo $output | jq -r '.trx') + if [[ $rfid == "null" ]] ; then + rfid="0" + fi + oldrfid=$( /var/www/html/openWB/ramdisk/readtag + echo $rfid > /var/www/html/openWB/ramdisk/tmpgoelp2rfid + fi + #car status 1 Ladestation bereit, kein Auto + #car status 2 Auto lädt + #car status 3 Warte auf Fahrzeug + #car status 4 Ladung beendet, Fahrzeug verbunden + car=$(echo $output | jq -r '.car') + if [[ $car == "2" ]] || [[ $car == "3" ]] || [[ $car == "4" ]] ; then + echo 1 > /var/www/html/openWB/ramdisk/plugstats1 + else + echo 0 > /var/www/html/openWB/ramdisk/plugstats1 + fi + if [[ $car == "2" ]] ; then + echo 1 > /var/www/html/openWB/ramdisk/chargestats1 + else + echo 0 > /var/www/html/openWB/ramdisk/chargestats1 + fi + fi fi -fi \ No newline at end of file +fi diff --git a/modules/goelp3/main.sh b/modules/goelp3/main.sh index c468058dd..0f11a60cc 100755 --- a/modules/goelp3/main.sh +++ b/modules/goelp3/main.sh @@ -4,62 +4,131 @@ rekwh='^[-+]?[0-9]+\.?[0-9]*$' output=$(curl --connect-timeout $goetimeoutlp3 -s http://$goeiplp3/status) if [[ $? == "0" ]] ; then - watt=$(echo $output | jq -r '.nrg[11]') - watt=$(echo "scale=0;$watt * 10 /1" |bc) - if [[ $watt =~ $re ]] ; then - echo $watt > /var/www/html/openWB/ramdisk/llaktuells2 - fi - lla1=$(echo $output | jq -r '.nrg[4]') - lla1=$(echo "scale=0;$lla1 / 10" |bc) - if [[ $lla1 =~ $re ]] ; then - echo $lla1 > /var/www/html/openWB/ramdisk/llas21 - fi - lla2=$(echo $output | jq -r '.nrg[5]') - lla2=$(echo "scale=0;$lla2 / 10" |bc) - if [[ $lla2 =~ $re ]] ; then - echo $lla2 > /var/www/html/openWB/ramdisk/llas22 - fi - lla3=$(echo $output | jq -r '.nrg[6]') - lla3=$(echo "scale=0;$lla3 / 10" |bc) - if [[ $lla3 =~ $re ]] ; then - echo $lla3 > /var/www/html/openWB/ramdisk/llas23 - fi - llv1=$(echo $output | jq -r '.nrg[0]') - if [[ $llv1 =~ $re ]] ; then - echo $llv1 > /var/www/html/openWB/ramdisk/llvs21 - fi - llv2=$(echo $output | jq -r '.nrg[1]') - if [[ $llv2 =~ $re ]] ; then - echo $llv2 > /var/www/html/openWB/ramdisk/llvs22 - fi - llv3=$(echo $output | jq -r '.nrg[2]') - if [[ $llv3 =~ $re ]] ; then - echo $llv3 > /var/www/html/openWB/ramdisk/llvs23 - fi - llkwh=$(echo $output | jq -r '.eto') - llkwh=$(echo "scale=3;$llkwh / 10" |bc) - if [[ $llkwh =~ $rekwh ]] ; then - echo $llkwh > /var/www/html/openWB/ramdisk/llkwhs2 - fi - rfid=$(echo $output | jq -r '.uby') - oldrfid=$( /var/www/html/openWB/ramdisk/readtag - echo $rfid > /var/www/html/openWB/ramdisk/tmpgoelp3rfid - fi - #car status 1 Ladestation bereit, kein Auto - #car status 2 Auto lädt - #car status 3 Warte auf Fahrzeug - #car status 4 Ladung beendet, Fahrzeug verbunden - car=$(echo $output | jq -r '.car') - if [[ $car == "1" ]] ; then - echo 0 > /var/www/html/openWB/ramdisk/plugstatlp3 - else - echo 1 > /var/www/html/openWB/ramdisk/plugstatlp3 - fi - if [[ $car == "2" ]] ; then - echo 1 > /var/www/html/openWB/ramdisk/chargestatlp3 + #check whether goe has 1to3phase switch capability => new HWV3 and new API V2 + fsp=$(echo $output | jq -r '.fsp') + if [[ ! $fsp =~ $re ]] ; then + watt=$(echo $output | jq -r '.nrg[11]') + watt=$(echo "scale=0;$watt * 10 /1" |bc) + if [[ $watt =~ $re ]] ; then + echo $watt > /var/www/html/openWB/ramdisk/llaktuells2 + fi + lla1=$(echo $output | jq -r '.nrg[4]') + lla1=$(echo "scale=0;$lla1 / 10" |bc) + if [[ $lla1 =~ $re ]] ; then + echo $lla1 > /var/www/html/openWB/ramdisk/llas21 + fi + lla2=$(echo $output | jq -r '.nrg[5]') + lla2=$(echo "scale=0;$lla2 / 10" |bc) + if [[ $lla2 =~ $re ]] ; then + echo $lla2 > /var/www/html/openWB/ramdisk/llas22 + fi + lla3=$(echo $output | jq -r '.nrg[6]') + lla3=$(echo "scale=0;$lla3 / 10" |bc) + if [[ $lla3 =~ $re ]] ; then + echo $lla3 > /var/www/html/openWB/ramdisk/llas23 + fi + llv1=$(echo $output | jq -r '.nrg[0]') + if [[ $llv1 =~ $re ]] ; then + echo $llv1 > /var/www/html/openWB/ramdisk/llvs21 + fi + llv2=$(echo $output | jq -r '.nrg[1]') + if [[ $llv2 =~ $re ]] ; then + echo $llv2 > /var/www/html/openWB/ramdisk/llvs22 + fi + llv3=$(echo $output | jq -r '.nrg[2]') + if [[ $llv3 =~ $re ]] ; then + echo $llv3 > /var/www/html/openWB/ramdisk/llvs23 + fi + llkwh=$(echo $output | jq -r '.eto') + llkwh=$(echo "scale=3;$llkwh / 10" |bc) + if [[ $llkwh =~ $rekwh ]] ; then + echo $llkwh > /var/www/html/openWB/ramdisk/llkwhs2 + fi + rfid=$(echo $output | jq -r '.uby') + oldrfid=$( /var/www/html/openWB/ramdisk/readtag + echo $rfid > /var/www/html/openWB/ramdisk/tmpgoelp3rfid + fi + #car status 1 Ladestation bereit, kein Auto + #car status 2 Auto lädt + #car status 3 Warte auf Fahrzeug + #car status 4 Ladung beendet, Fahrzeug verbunden + car=$(echo $output | jq -r '.car') + if [[ $car == "1" ]] ; then + echo 0 > /var/www/html/openWB/ramdisk/plugstatlp3 + else + echo 1 > /var/www/html/openWB/ramdisk/plugstatlp3 + fi + if [[ $car == "2" ]] ; then + echo 1 > /var/www/html/openWB/ramdisk/chargestatlp3 + else + echo 0 > /var/www/html/openWB/ramdisk/chargestatlp3 + fi else - echo 0 > /var/www/html/openWB/ramdisk/chargestatlp3 + output=$(curl --connect-timeout $goetimeoutlp3 -s http://$goeiplp3/api/status) + if [[ $? == "0" ]] ; then + watt=$(echo $output | jq -r '.nrg[11]') + watt=$(echo "scale=0;$watt /1" |bc) + if [[ $watt =~ $re ]] ; then + echo $watt > /var/www/html/openWB/ramdisk/llaktuells2 + fi + lla1=$(echo $output | jq -r '.nrg[4]') + lla1=$(echo "scale=0;$lla1" |bc) + if [[ $lla1 =~ $rekwh ]] ; then + echo $lla1 > /var/www/html/openWB/ramdisk/llas21 + fi + lla2=$(echo $output | jq -r '.nrg[5]') + lla2=$(echo "scale=0;$lla2" |bc) + if [[ $lla2 =~ $rekwh ]] ; then + echo $lla2 > /var/www/html/openWB/ramdisk/llas22 + fi + lla3=$(echo $output | jq -r '.nrg[6]') + lla3=$(echo "scale=0;$lla3" |bc) + if [[ $lla3 =~ $rekwh ]] ; then + echo $lla3 > /var/www/html/openWB/ramdisk/llas23 + fi + llv1=$(echo $output | jq -r '.nrg[0]') + if [[ $llv1 =~ $re ]] ; then + echo $llv1 > /var/www/html/openWB/ramdisk/llvs21 + fi + llv2=$(echo $output | jq -r '.nrg[1]') + if [[ $llv2 =~ $re ]] ; then + echo $llv2 > /var/www/html/openWB/ramdisk/llvs22 + fi + llv3=$(echo $output | jq -r '.nrg[2]') + if [[ $llv3 =~ $re ]] ; then + echo $llv3 > /var/www/html/openWB/ramdisk/llvs23 + fi + llkwh=$(echo $output | jq -r '.eto') + llkwh=$(echo "scale=3;$llkwh / 1000" |bc) + if [[ $llkwh =~ $rekwh ]] ; then + echo $llkwh > /var/www/html/openWB/ramdisk/llkwhs2 + fi + rfid=$(echo $output | jq -r '.trx') + if [[ $rfid == "null" ]] ; then + rfid="0" + fi + oldrfid=$( /var/www/html/openWB/ramdisk/readtag + echo $rfid > /var/www/html/openWB/ramdisk/tmpgoelp3rfid + fi + #car status 1 Ladestation bereit, kein Auto + #car status 2 Auto lädt + #car status 3 Warte auf Fahrzeug + #car status 4 Ladung beendet, Fahrzeug verbunden + car=$(echo $output | jq -r '.car') + if [[ $car == "2" ]] || [[ $car == "3" ]] || [[ $car == "4" ]] ; then + echo 1 > /var/www/html/openWB/ramdisk/plugstatlp3 + else + echo 0 > /var/www/html/openWB/ramdisk/plugstatlp3 + fi + if [[ $car == "2" ]] ; then + echo 1 > /var/www/html/openWB/ramdisk/chargestatlp3 + else + echo 0 > /var/www/html/openWB/ramdisk/chargestatlp3 + fi + fi fi -fi \ No newline at end of file +fi diff --git a/runs/set-current.sh b/runs/set-current.sh index 5f8c26701..038f838a8 100755 --- a/runs/set-current.sh +++ b/runs/set-current.sh @@ -7,18 +7,18 @@ # # This file is part of openWB. # -# openWB is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# openWB is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -# openWB is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# openWB is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with openWB. If not, see . +# You should have received a copy of the GNU General Public License +# along with openWB. If not, see . # ##### @@ -201,30 +201,51 @@ function setChargingCurrenthttp () { # 3: goeiplp1 function setChargingCurrentgoe () { if [[ $evsecon == "goe" ]]; then - if [[ $current -eq 0 ]]; then - output=$(curl --connect-timeout "$goetimeoutlp1" -s "http://$goeiplp1/status") - state=$(echo "$output" | jq -r '.alw') - if ((state == "1")) ; then - curl --silent --connect-timeout "$goetimeoutlp1" -s "http://$goeiplp1/mqtt?payload=alw=0" > /dev/null - fi - else - output=$(curl --connect-timeout "$goetimeoutlp1" -s "http://$goeiplp1/status") + output=$(curl --connect-timeout "$goetimeoutlp1" -s "http://$goeiplp1/status") + #check whether goe has 1to3phase switch capability => new HWV3 and new API V2 + digit='^[0-9]$' + fsp=$(echo "$output" | jq -r '.fsp') + if [[ ! $fsp =~ $digit ]] ; then + if [[ $current -eq 0 ]]; then + state=$(echo "$output" | jq -r '.alw') + if ((state == "1")) ; then + curl --silent --connect-timeout "$goetimeoutlp1" -s "http://$goeiplp1/mqtt?payload=alw=0" > /dev/null + fi + else + output=$(curl --connect-timeout "$goetimeoutlp1" -s "http://$goeiplp1/status") - version=$(echo $output | jq -r '.fwv') # get firmware version - majorVersion=${version%.*} # remove everything after a "." - majorVersion=${majorVersion%-*} # remove everything after a "-" - majorVersion=${majorVersion#0} # remove leading "0" + version=$(echo $output | jq -r '.fwv') # get firmware version + majorVersion=${version%.*} # remove everything after a "." + majorVersion=${majorVersion%-*} # remove everything after a "-" + majorVersion=${majorVersion#0} # remove leading "0" - state=$(echo "$output" | jq -r '.alw') - if ((state == "0")) ; then - curl --silent --connect-timeout "$goetimeoutlp1" -s "http://$goeiplp1/mqtt?payload=alw=1" > /dev/null + state=$(echo "$output" | jq -r '.alw') + if ((state == "0")) ; then + curl --silent --connect-timeout "$goetimeoutlp1" -s "http://$goeiplp1/mqtt?payload=alw=1" > /dev/null + fi + oldgoecurrent=$(echo "$output" | jq -r '.amp') + if (( oldgoecurrent != current )) ; then + if ((majorVersion >= 40)) ; then + curl --silent --connect-timeout "$goetimeoutlp1" -s "http://$goeiplp1/mqtt?payload=amx=$current" > /dev/null + else + curl --silent --connect-timeout "$goetimeoutlp1" -s "http://$goeiplp1/mqtt?payload=amp=$current" > /dev/null + fi + fi fi - oldgoecurrent=$(echo "$output" | jq -r '.amp') - if (( oldgoecurrent != current )) ; then - if ((majorVersion >= 40)) ; then - curl --silent --connect-timeout "$goetimeoutlp1" -s "http://$goeiplp1/mqtt?payload=amx=$current" > /dev/null - else - curl --silent --connect-timeout "$goetimeoutlp1" -s "http://$goeiplp1/mqtt?payload=amp=$current" > /dev/null + else + output=$(curl --connect-timeout "$goetimeoutlp1" -s "http://$goeiplp1/api/status") + state=$(echo "$output" | jq -r '.frc') + if [[ $current -eq 0 ]]; then + if ((state == "0")) ; then + curl --silent --connect-timeout "$goetimeoutlp1" -s "http://$goeiplp1/api/set?frc=1" > /dev/null + fi + else + if ((state == "1")) ; then + curl --silent --connect-timeout "$goetimeoutlp1" -s "http://$goeiplp1/api/set?frc=0" > /dev/null + fi + oldgoecurrent=$(echo "$output" | jq -r '.amp') + if (( oldgoecurrent != current )) ; then + curl --silent --connect-timeout "$goetimeoutlp1" -s "http://$goeiplp1/api/set?amp=$current" > /dev/null fi fi fi @@ -250,7 +271,7 @@ function setChargingCurrentkeba () { echo -n "display 1 10 10 0 S$current" | socat - UDP-DATAGRAM:"$kebaiplp1":7090 fi else - #modbus 1 means modbus interface + #modbus 1 means modbus interface sudo python3 /var/www/html/openWB/modules/keballlp1/setcurrkeba.py "$kebaiplp1" "$current" >> /var/www/html/openWB/ramdisk/port.log 2>&1 fi fi