This repository has been archived by the owner on Mar 31, 2023. It is now read-only.
forked from snaptec/openWB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nrgkickcheck.sh
executable file
·28 lines (28 loc) · 1.59 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
#!/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
fi
fi
fi
}