-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnrgkickcheck.sh
54 lines (53 loc) · 3.09 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
54
#!/bin/bash
openwbDebugLog "MAIN" 1 "source nrgkickcheck.sh"
nrgkickcheck(){
openwbDebugLog "MAIN" 1 "nrgkickcheck called"
#######################################
#nrgkick mobility check
if [[ $evsecon == "nrgkick" ]]; then
output=$(curl --connect-timeout 3 -s http://$nrgkickiplp1/api/settings/$nrgkickmaclp1)
read current <ramdisk/llsoll
if [[ $? == "0" ]] ; then
state=$(echo $output | jq -r '.Values.ChargingStatus.Charging')
if grep -q 1 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 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')
read current <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
fi
fi
fi
if [[ $evsecons1 == "nrgkick" ]]; then
output=$(curl --connect-timeout 3 -s http://$nrgkickiplp2/api/settings/$nrgkickmaclp2)
read current <ramdisk/llsolls1
if [[ $? == "0" ]] ; then
state=$(echo $output | jq -r '.Values.ChargingStatus.Charging')
if grep -q 1 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 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')
read current <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
}