Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use Go-e API V2 instead of API V1 (in case of HWv3 which supports it) #2460

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
151 changes: 111 additions & 40 deletions goecheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,54 @@
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=$(</var/www/html/openWB/ramdisk/lp1enabled)
if ((state == "0")) && (( lp1enabled == "1" )) ; then
curl --silent --connect-timeout $goetimeoutlp1 -s http://$goeiplp1/mqtt?payload=alw=1 > /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=$(</var/www/html/openWB/ramdisk/lp1enabled)
if ((state == "0")) && (( lp1enabled == "1" )) ; then
curl --silent --connect-timeout $goetimeoutlp1 -s http://$goeiplp1/mqtt?payload=alw=1 > /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
fwv=$(echo $output | jq -r '.fwv' | grep -Po "[1-9]\d{1,2}")
oldcurrent=$(echo $output | jq -r '.amp')
current=$(</var/www/html/openWB/ramdisk/llsoll)
if (( oldcurrent != $current )) && (( $current != 0 )); then
if (($fwv >= 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
fwv=$(echo $output | jq -r '.fwv' | grep -Po "[1-9]\d{1,2}")
oldcurrent=$(echo $output | jq -r '.amp')
current=$(</var/www/html/openWB/ramdisk/llsoll)
if (( oldcurrent != $current )) && (( $current != 0 )) ; then
if (($fwv >= 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=$(</var/www/html/openWB/ramdisk/lp1enabled)
if ((state == "1")) && (( lp1enabled == "1" )) ; then
curl --silent --connect-timeout $goetimeoutlp1 -s http://$goeiplp1/api/set?frc=0 > /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=$(</var/www/html/openWB/ramdisk/llsoll)
if (( oldcurrent != $current )) && (( $current != 0 )) ; then
curl --silent --connect-timeout $goetimeoutlp1 -s http://$goeiplp1/api/set?amp=$current > /dev/null
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ist bei der neuen API keine Unterscheidung zwischen amp und amx erforderlich?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nein, hier gibt es nur noch den Wert amp.
Die Unterscheidung zwischen amx und amp war ja, das amp persistent ist, also der Wert ins Flash geschrieben wird. Um zu verhindern, das man damit auf Dauer durch "ständiges" Neusetzen (was bei PV Regelung ja der Fall ist) das Flash "kaputt" schreibt wurde der Wert amx eingeführt.
Mit der neuen HW Generation (sowie neuer SW) ist go-e dieses Problem aber von einer neuen Seite angegangen mit einem intelligenten bzw. intelligenteren Ansatz zur Persistierung, hier das Statement von go-e (habe extra nochmals angefragt):
"Da du allerdings wohl ohnehin bereits eine neuere Hardware-Version hast, musst du dir hier generell keine Sorgen machen.
Hier wird ein Log geschrieben und immer hinten der geänderte Einstellungwert angehängt. Da ein sehr großer Bereich im Flash dafür vorgesehen ist, setzt sich das einfach auf dem nächsten Block fort wenn noch mehr Daten geschrieben werden. Erst wenn alle Blöcke vollgeschrieben wurden, wird das komprimiert, alle Blöcke wieder mit 0 initialisiert und das Log von vorne geschrieben. Daher muss man sich hier keine Sorgen um Langzeit Zuverlässigkeit machen."

Überschlagsmäßig würde ich das unterstreichen (mehrere 1000 Male den Wert schreiben, bis der Sektor gelöscht werden muss und der verkraftet mind. 1000 Zyklen - eher 10000 => da sollte länger funktionieren, als die eigentliche alterungsbedingte Flashlebensdauer).

Da es die neue API ausschließlich bei der neuen HW-Generation gibt, sollte es somit kein Problem geben.

fi
fi
fi
Expand All @@ -33,38 +58,64 @@ 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=$(</var/www/html/openWB/ramdisk/lp2enabled)
if ((state == "0")) && (( lp2enabled == "1" )) ; then
curl --silent --connect-timeout $goetimeoutlp2 -s http://$goeiplp2/mqtt?payload=alw=1 > /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=$(</var/www/html/openWB/ramdisk/lp2enabled)
if ((state == "0")) && (( lp2enabled == "1" )) ; then
curl --silent --connect-timeout $goetimeoutlp2 -s http://$goeiplp2/mqtt?payload=alw=1 > /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
fwv=$(echo $output | jq -r '.fwv' | grep -Po "[1-9]\d{1,2}")
oldcurrent=$(echo $output | jq -r '.amp')
current=$(</var/www/html/openWB/ramdisk/llsolls1)
if (( oldcurrent != $current )) && (( $current != 0 )); then
if (($fwv >= 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
fwv=$(echo $output | jq -r '.fwv' | grep -Po "[1-9]\d{1,2}")
oldcurrent=$(echo $output | jq -r '.amp')
current=$(</var/www/html/openWB/ramdisk/llsolls1)
if (( oldcurrent != $current )) && (( $current != 0 )) ; then
if (($fwv >= 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=$(</var/www/html/openWB/ramdisk/lp2enabled)
if ((state == "1")) && (( lp2enabled == "1" )) ; then
curl --silent --connect-timeout $goetimeoutlp2 -s http://$goeiplp2/api/set?frc=0 > /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=$(</var/www/html/openWB/ramdisk/llsolls1)
if (( oldcurrent != $current )) && (( $current != 0 )) ; then
curl --silent --connect-timeout $goetimeoutlp2 -s http://$goeiplp2/api/set?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=$(</var/www/html/openWB/ramdisk/lp3enabled)
if ((state == "0")) && (( lp3enabled == "1" )) ; then
if ((state == "0")) && (( lp3enabled == "1" )) ; then
curl --silent --connect-timeout $goetimeoutlp3 -s http://$goeiplp3/mqtt?payload=alw=1 > /dev/null
fi
fi
Expand All @@ -76,15 +127,35 @@ goecheck(){
fwv=$(echo $output | jq -r '.fwv' | grep -Po "[1-9]\d{1,2}")
oldcurrent=$(echo $output | jq -r '.amp')
current=$(</var/www/html/openWB/ramdisk/llsolls2)
if (( oldcurrent != $current )) ; then
if (( oldcurrent != $current && $current != 0 )) ; then
if (($fwv >= 40)) ; then
curl --silent --connect-timeout $goetimeoutlp3 -s http://$goeiplp3/mqtt?payload=amx=$current > /dev/null
else
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=$(</var/www/html/openWB/ramdisk/lp3enabled)
if (( state == "1" )) && (( lp3enabled == "1" )) ; then
curl --silent --connect-timeout $goetimeoutlp3 -s http://$goeiplp3/api/set?frc=0 > /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=$(</var/www/html/openWB/ramdisk/llsolls2)
if (( oldcurrent != $current && $current != 0 )) ; then
curl --silent --connect-timeout $goetimeoutlp3 -s http://$goeiplp3/api/set?amp=$current > /dev/null
fi
fi
fi
fi
fi
fi
}
185 changes: 127 additions & 58 deletions modules/goelp1/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/tmpgoelp1rfid)
if [[ $rfid != $oldrfid ]] ; then
echo $rfid > /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/tmpgoelp1rfid)
if [[ $rfid != $oldrfid ]] ; then
echo $rfid > /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/tmpgoelprfid)
if [[ $rfid != $oldrfid ]] ; then
echo $rfid > /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
Loading