forked from snaptec/openWB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nrgkickcheck.sh
executable file
·53 lines (53 loc) · 3.2 KB
/
nrgkickcheck.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
nrgkickcheck(){
#######################################
#nrgkick mobility check
if [[ $evsecon == "nrgkick" ]]; then
output=$(curl --connect-timeout 3 -s http://$nrgkickiplp1/api/settings/$nrgkickmaclp1)
current=$(</var/www/html/openWB/ramdisk/llsoll)
if [[ $? == "0" ]] ; then
state=$(echo $output | jq -r '.Values.ChargingStatus.Charging')
if grep -q 1 "/var/www/html/openWB/ramdisk/ladestatus"; then
if [[ $state == "false" ]] ; then
curl --connect-timeout 2 -s -X PUT -H "Content-Type: application/json" --data "{ "Values": {"ChargingStatus": { "Charging": true }, "ChargingCurrent": { "Value": $current }, "DeviceMetadata":{"Password": $nrgkickpwlp1}}}" $nrgkickiplp1/api/settings/$nrgkickmaclp1 > /dev/null
fi
fi
if grep -q 0 "/var/www/html/openWB/ramdisk/ladestatus"; then
if [[ $state == "true" ]] ; then
curl --connect-timeout 2 -s -X PUT -H "Content-Type: application/json" --data "{ "Values": {"ChargingStatus": { "Charging": false }, "ChargingCurrent": { "Value": "6"}, "DeviceMetadata":{"Password": $nrgkickpwlp1}}}" $nrgkickiplp1/api/settings/$nrgkickmaclp1 > /dev/null
fi
fi
oldcurrent=$(echo $output | jq -r '.Values.ChargingCurrent.Value')
current=$(</var/www/html/openWB/ramdisk/llsoll)
if (( oldcurrent != $current )) ; then
curl --silent --connect-timeout $nrgkicktimeoutlp1 -s -X PUT -H "Content-Type: application/json" --data "{ "Values": {"ChargingStatus": { "Charging": true }, "ChargingCurrent": { "Value": $current}, "DeviceMetadata":{"Password": $nrgkickpwlp1}}}" $nrgkickiplp1/api/settings/$nrgkickmaclp1 > /dev/null
> /dev/null
# BUG? remove line above?
fi
fi
fi
if [[ $evsecons1 == "nrgkick" ]]; then
output=$(curl --connect-timeout 3 -s http://$nrgkickiplp2/api/settings/$nrgkickmaclp2)
current=$(</var/www/html/openWB/ramdisk/llsolls1)
if [[ $? == "0" ]] ; then
state=$(echo $output | jq -r '.Values.ChargingStatus.Charging')
if grep -q 1 "/var/www/html/openWB/ramdisk/ladestatuss1"; then
if [[ $state == "false" ]] ; then
curl --connect-timeout 2 -s -X PUT -H "Content-Type: application/json" --data "{ "Values": {"ChargingStatus": { "Charging": true }, "ChargingCurrent": { "Value": $current }, "DeviceMetadata":{"Password": $nrgkickpwlp2}}}" $nrgkickiplp2/api/settings/$nrgkickmaclp2 > /dev/null
fi
fi
if grep -q 0 "/var/www/html/openWB/ramdisk/ladestatus"; then
if [[ $state == "true" ]] ; then
curl --connect-timeout 2 -s -X PUT -H "Content-Type: application/json" --data "{ "Values": {"ChargingStatus": { "Charging": false }, "ChargingCurrent": { "Value": "6"}, "DeviceMetadata":{"Password": $nrgkickpwlp2}}}" $nrgkickiplp2/api/settings/$nrgkickmaclp2 > /dev/null
fi
fi
oldcurrent=$(echo $output | jq -r '.Values.ChargingCurrent.Value')
current=$(</var/www/html/openWB/ramdisk/llsolls1)
if (( oldcurrent != $current )) ; then
curl --silent --connect-timeout $nrgkicktimeoutlp2 -s -X PUT -H "Content-Type: application/json" --data "{ "Values": {"ChargingStatus": { "Charging": true }, "ChargingCurrent": { "Value": $current}, "DeviceMetadata":{"Password": $nrgkickpwlp2}}}" $nrgkickiplp2/api/settings/$nrgkickmaclp2 > /dev/null
> /dev/null
# BUG? remove line above?
fi
fi
fi
}