diff --git a/goecheck.sh b/goecheck.sh index 701174a60..1d2818f1e 100755 --- a/goecheck.sh +++ b/goecheck.sh @@ -2,53 +2,24 @@ 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 - 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 - 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" - - - 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 - fi - fi - if [[ $lastmanagement == "1" ]]; then - if [[ $evsecons1 == "goe" ]]; then - output=$(curl --connect-timeout 1 -s http://$goeiplp2/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/ladestatuss1"; then - lp2enabled=$( /dev/null + 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/ladestatuss1"; then + if grep -q 0 "/var/www/html/openWB/ramdisk/ladestatus"; then if ((state == "1")) ; then - curl --silent --connect-timeout $goetimeoutlp2 -s http://$goeiplp2/mqtt?payload=alw=0 > /dev/null + curl --silent --connect-timeout $goetimeoutlp1 -s http://$goeiplp1/mqtt?payload=alw=0 > /dev/null fi fi @@ -57,25 +28,104 @@ goecheck(){ 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 + curl --silent --connect-timeout $goetimeoutlp1 -s http://$goeiplp1/mqtt?payload=amx=$current > /dev/null else - curl --silent --connect-timeout $goetimeoutlp2 -s http://$goeiplp2/mqtt?payload=amp=$current > /dev/null + 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 + fi + if [[ $lastmanagement == "1" ]]; then + if [[ $evsecons1 == "goe" ]]; then + output=$(curl --connect-timeout 1 -s http://$goeiplp2/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/ladestatuss1"; then + lp2enabled=$( /dev/null + 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 + 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" + + 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 @@ -92,6 +142,7 @@ goecheck(){ oldcurrent=$(echo $output | jq -r '.amp') current=$(= 40)) ; then curl --silent --connect-timeout $goetimeoutlp3 -s http://$goeiplp3/mqtt?payload=amx=$current > /dev/null @@ -99,8 +150,28 @@ goecheck(){ curl --silent --connect-timeout $goetimeoutlp3 -s http://$goeiplp3/mqtt?payload=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..b8459976c 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 - else - echo 0 > /var/www/html/openWB/ramdisk/chargestat - fi + #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 + 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 diff --git a/modules/goelp2/main.sh b/modules/goelp2/main.sh index e830d6e97..592a0c0f7 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 - else - echo 0 > /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 + 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 diff --git a/modules/goelp3/main.sh b/modules/goelp3/main.sh index c468058dd..a557dfff3 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 - else - echo 0 > /var/www/html/openWB/ramdisk/chargestatlp3 - fi + #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 + 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 diff --git a/runs/set-current.sh b/runs/set-current.sh index 7d27f6e8b..36fecb657 100755 --- a/runs/set-current.sh +++ b/runs/set-current.sh @@ -201,11 +201,34 @@ 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 + 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 + 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 + 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 else output=$(curl --connect-timeout "$goetimeoutlp1" -s "http://$goeiplp1/status") diff --git a/runs/u1p3pcheck.sh b/runs/u1p3pcheck.sh index fa74edca8..7c9fe69b4 100755 --- a/runs/u1p3pcheck.sh +++ b/runs/u1p3pcheck.sh @@ -13,6 +13,9 @@ if [[ "$1" == "1" ]]; then if [[ $evsecon == "extopenwb" ]]; then mosquitto_pub -r -t openWB/set/isss/U1p3p -h "$chargep1ip" -m "1" fi + if [[ $evsecon == "goe" ]]; then + sudo python runs/u1p3pgoe.py -v -a "$goeiplp1" -p 1 + fi if [[ $evsecon == "owbpro" ]]; then curl -s -X POST --data "phasetarget=1" "$owbpro1ip/connect.php" fi @@ -28,6 +31,9 @@ if [[ "$1" == "1" ]]; then if [[ $lastmanagement == 1 && $evsecons1 == "extopenwb" ]]; then mosquitto_pub -r -t openWB/set/isss/U1p3p -h "$chargep2ip" -m "1" fi + if [[ $lastmanagement == 1 && $evsecons1 == "goe" ]]; then + sudo python runs/u1p3pgoe.py -v -a "$goeiplp2" -p 1 + fi if [[ $lastmanagement == 1 && $evsecons1 == "owbpro" ]]; then curl -s -X POST --data "phasetarget=1" "$owbpro2ip/connect.php" fi @@ -42,6 +48,9 @@ if [[ "$1" == "1" ]]; then if [[ $lastmanagements2 == 1 && $evsecons2 == "ipevse" && $u1p3plp3aktiv == "1" ]]; then sudo python runs/u1p3premote.py -a "$evseiplp3" -i "$u1p3plp3id" -p 1 -d "$u1p3ppause" fi + if [[ $lastmanagements2 == 1 && $evsecons2 == "goe" ]]; then + sudo python runs/u1p3pgoe.py -v -a "$goeiplp3" -p 1 + fi # chargepoint 4 if [[ $lastmanagementlp4 == 1 && $evseconlp4 == "extopenwb" ]]; then @@ -191,6 +200,15 @@ if [[ "$1" == "3" ]]; then if [[ $lastmanagementlp8 == 1 && $evseconlp8 == "ipevse" && $u1p3plp8aktiv == "1" ]]; then sudo python runs/u1p3premote.py -a "$evseiplp8" -i "$u1p3plp8id" -p 3 -d "$u1p3ppause" fi + if [[ $evsecon == "goe" ]]; then + sudo python runs/u1p3pgoe.py -v -a "$goeiplp1" -p 3 -m "$minimalapv" + fi + if [[ $lastmanagement == 1 && $evsecons1 == "goe" ]]; then + sudo python runs/u1p3pgoe.py -v -a "$goeiplp2" -p 3 -m "$minimalapv" + fi + if [[ $lastmanagements2 == 1 && $evsecons2 == "goe" ]]; then + sudo python runs/u1p3pgoe.py -v -a "$goeiplp3" -p 3 -m "$minimalapv" + fi echo 3 > ramdisk/u1p3pstat fi @@ -210,6 +228,11 @@ if [[ "$1" == "stop" ]]; then oldll=$( ramdisk/tmpllsoll fi + #if [[ $evsecon == "goe" ]]; then + # oldll=$( ramdisk/tmpllsoll + # runs/set-current.sh 0 m + #fi if [[ $lastmanagement == 1 && $evsecons1 == "daemon" ]]; then oldlls1=$( ramdisk/tmpllsolls1 @@ -220,11 +243,21 @@ if [[ "$1" == "stop" ]]; then echo "$oldlls1" > ramdisk/tmpllsolls1 mosquitto_pub -r -t openWB/set/isss/Current -h "$chargep2ip" -m "0" fi + #if [[ $lastmanagement == 1 && $evsecons1 == "goe" ]]; then + # oldlls1=$( ramdisk/tmpllsolls1 + # runs/set-current.sh 0 s1 + #fi if [[ $lastmanagements2 == 1 && $evsecons2 == "extopenwb" ]]; then oldlls2=$( ramdisk/tmpllsolls2 mosquitto_pub -r -t openWB/set/isss/Current -h "$chargep3ip" -m "0" fi + #if [[ $lastmanagements2 == 1 && $evsecons2 == "goe" ]]; then + # oldlls2=$( ramdisk/tmpllsolls2 + # runs/set-current.sh 0 s2 + #fi if [[ $lastmanagementlp4 == 1 && $evseconlp4 == "extopenwb" ]]; then oldlllp4=$( ramdisk/tmpllsolllp4 @@ -316,6 +349,9 @@ if [[ "$1" == "start" ]]; then oldll=$( go-e charger has HW V3 and therefore 1to3 phase switch capability +if ("fsp" in status_goe): + try: + if(args.verbose): + print("Phaseneinstellung fsp vorher: %d" % (int(status_goe['fsp']))) + if (args.phases == 1 and int(status_goe['fsp']) != 1): + set_psm_goe = requests.get('http://'+args.address+'/api/set?psm=1', timeout=5).json() + if (set_psm_goe['psm'] is True and args.verbose): + print("Umschaltung auf 1 Phase erfolgreich!") + if (args.phases == 3 and int(status_goe['fsp']) != 0): + if (args.minampere and args.minampere >= 5 and args.minampere <= 32): + set_amp_goe = requests.get('http://'+args.address+'/api/set?amp='+str(args.minampere), timeout=5).json() + if (set_amp_goe['amp'] is True and args.verbose): + print("Setzen von MinAmpere erfolgreich!") + set_psm_goe = requests.get('http://'+args.address+'/api/set?psm=2', timeout=5).json() + if (set_psm_goe['psm'] is True and args.verbose): + print("Umschaltung auf 3 Phasen erfolgreich!") + except: + traceback.print_exc() + exit(1) +else: + if(args.verbose): + print("Phasenumschaltung von go-e Charger nicht unterstuetzt (V2 HW ?!)") diff --git a/runs/update.sh b/runs/update.sh index d3e7114bf..23c159fd7 100755 --- a/runs/update.sh +++ b/runs/update.sh @@ -69,8 +69,8 @@ cp modules/soc_eq/soc_eq_acc_lp2 /tmp/soc_eq_acc_lp2 cp openwb.conf /tmp/openwb.conf # fetch new release from GitHub -git fetch origin -git reset --hard origin/$train +sudo git fetch matzempc +sudo git reset --hard matzempc/$train # set permissions cd /var/www/html/