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
171 changes: 120 additions & 51 deletions goecheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=$(</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

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=$(</var/www/html/openWB/ramdisk/llsoll)
if (( oldcurrent != $current )) && (( $current != 0 )); 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
oldcurrent=$(echo $output | jq -r '.amp')
current=$(</var/www/html/openWB/ramdisk/llsoll)
if (( oldcurrent != $current )) && (( $current != 0 )); 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
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 @@ -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=$(</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

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=$(</var/www/html/openWB/ramdisk/llsolls1)
if (( oldcurrent != $current )) && (( $current != 0 )); then
if (($majorVersion >= 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=$(</var/www/html/openWB/ramdisk/llsolls1)
if (( oldcurrent != $current )) && (( $current != 0 )); then
if (($majorVersion >= 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 @@ -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=$(</var/www/html/openWB/ramdisk/llsolls2)
Expand All @@ -99,8 +148,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=$(</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
}
Loading