-
Notifications
You must be signed in to change notification settings - Fork 0
/
geraete.sh
146 lines (140 loc) · 5.33 KB
/
geraete.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
function geraete()
{
# Gerät 1..3
if (( hook1_aktiv == "1" )); then # is configured?
if (( hook1akt == 0 )); then
read hook1einschaltverzcounter <ramdisk/hook1einschaltverzcounter
if (( uberschuss > hook1ein_watt )); then
if (( hook1einschaltverzcounter > hook1einschaltverz)); then
echo 0 > /var/www/html/openWB/ramdisk/hook1einschaltverzcounter
echo 0 > /var/www/html/openWB/ramdisk/hook1counter
if [ ! -e ramdisk/hook1aktivstamp ]; then
touch ramdisk/hook1aktivstamp
echo 1 > ramdisk/hook1akt
curl -s --connect-timeout 5 $hook1ein_url > ramdisk/hookmsg
openwbDebugLog "CHARGESTAT" 0 "WebHook 1 aktiviert"
openwbDebugLog "CHARGESTAT" 0 "$(cat ramdisk/hookmsg)"
rm ramdisk/hookmsg
openwbDebugLog "MAIN" 1 "Gerät 1 aktiviert"
if ((pushbsmarthome == "1")) && ((pushbenachrichtigung == "1")); then
./runs/pushover.sh "Gerät 1 eingeschaltet bei $uberschuss"
fi
fi
else
hook1einschaltverzcounter=$((hook1einschaltverzcounter +10))
echo $hook1einschaltverzcounter > /var/www/html/openWB/ramdisk/hook1einschaltverzcounter
fi
else
hook1einschaltverzcounter=0
fi
fi
if [ -e ramdisk/hook1aktivstamp ]; then
if test $(find "ramdisk/hook1aktivstamp" -mmin +$hook1_dauer); then
if (( uberschuss < hook1aus_watt )); then
read hook1counter <ramdisk/hook1counter
if (( hook1counter < hook1_ausverz )); then
hook1counter=$((hook1counter + 10))
echo $hook1counter > /var/www/html/openWB/ramdisk/hook1counter
else
rm ramdisk/hook1aktivstamp
echo 0 > ramdisk/hook1akt
curl -s --connect-timeout 5 $hook1aus_url > ramdisk/hookmsg
openwbDebugLog "CHARGESTAT" 0 "WebHook 1 deaktiviert"
openwbDebugLog "CHARGESTAT" 0 "$(cat ramdisk/hookmsg)"
rm ramdisk/hookmsg
openwbDebugLog "MAIN" 1 "Gerät 1 deaktiviert"
if ((pushbsmarthome == "1")) && ((pushbenachrichtigung == "1")); then
./runs/pushover.sh "Gerät 1 ausgeschaltet bei $uberschuss"
fi
fi
fi
fi
fi
fi
if (( hook2_aktiv == "1" )); then # is configured?
if (( hook2akt == 0 )); then
read hook2einschaltverzcounter <ramdisk/hook2einschaltverzcounter
if (( uberschuss > hook2ein_watt )); then
if (( hook2einschaltverzcounter > hook2einschaltverz)); then
echo 0 > /var/www/html/openWB/ramdisk/hook2einschaltverzcounter
echo 0 > /var/www/html/openWB/ramdisk/hook2counter
if [ ! -e ramdisk/hook2aktiv ]; then
touch ramdisk/hook2aktiv
echo 1 > ramdisk/hook2akt
curl -s --connect-timeout 5 $hook2ein_url > ramdisk/hook2msg
openwbDebugLog "CHARGESTAT" 0 "WebHook 2 aktiviert"
openwbDebugLog "CHARGESTAT" 0 "$(cat ramdisk/hook2msg)"
rm ramdisk/hook2msg
openwbDebugLog "MAIN" 1 "Gerät 2 aktiviert"
if ((pushbsmarthome == "1")) && ((pushbenachrichtigung == "1")); then
./runs/pushover.sh "Gerät 2 eingeschaltet bei $uberschuss"
fi
fi
else
hook2einschaltverzcounter=$((hook2einschaltverzcounter +10))
echo $hook2einschaltverzcounter > /var/www/html/openWB/ramdisk/hook2einschaltverzcounter
fi
else
hook2einschaltverzcounter=0
fi
fi
if [ -e ramdisk/hook2aktiv ]; then
if test $(find "ramdisk/hook2aktiv" -mmin +$hook2_dauer); then
if (( uberschuss < hook2aus_watt )); then
read hook2counter <ramdisk/hook2counter
if (( hook2counter < hook2_ausverz )); then
hook2counter=$((hook2counter + 10))
echo $hook2counter > /var/www/html/openWB/ramdisk/hook2counter
else
rm ramdisk/hook2aktiv
echo 0 > ramdisk/hook2akt
curl -s --connect-timeout 5 $hook2aus_url > ramdisk/hook2msg
openwbDebugLog "CHARGESTAT" 0 "WebHook 2 deaktiviert"
openwbDebugLog "CHARGESTAT" 0 "$(cat ramdisk/hook2msg)"
rm ramdisk/hook2msg
openwbDebugLog "MAIN" 1 "Gerät 2 deaktiviert"
if ((pushbsmarthome == "1")) && ((pushbenachrichtigung == "1")); then
./runs/pushover.sh "Gerät 2 ausgeschaltet bei $uberschuss"
fi
fi
fi
fi
fi
fi
if (( hook3_aktiv == "1" )); then # is configured?
if (( uberschuss > hook3ein_watt )); then
echo 0 > /var/www/html/openWB/ramdisk/hook3counter
if [ ! -e ramdisk/hook3aktiv ]; then
touch ramdisk/hook3aktiv
echo 1 > ramdisk/hook3akt
curl -s --connect-timeout 5 $hook3ein_url > /dev/null
openwbDebugLog "CHARGESTAT" 0 "WebHook 3 aktiviert"
openwbDebugLog "MAIN" 1 "Gerät 3 aktiviert"
if ((pushbsmarthome == "1")) && ((pushbenachrichtigung == "1")); then
./runs/pushover.sh "Gerät 3 eingeschaltet bei $uberschuss"
fi
fi
fi
if [ -e ramdisk/hook3aktiv ]; then
if test $(find "ramdisk/hook3aktiv" -mmin +$hook3_dauer); then
if (( uberschuss < hook3aus_watt )); then
read hook3counter <ramdisk/hook3counter
if (( hook3counter < hook3_ausverz )); then
hook3counter=$((hook3counter + 10))
echo $hook3counter > /var/www/html/openWB/ramdisk/hook3counter
else
rm ramdisk/hook3aktiv
echo 0 > ramdisk/hook3akt
curl -s --connect-timeout 5 $hook3aus_url > /dev/null
openwbDebugLog "CHARGESTAT" 0 "WebHook 3 deaktiviert"
openwbDebugLog "MAIN" 1 "Gerät 3 deaktiviert"
if ((pushbsmarthome == "1")) && ((pushbenachrichtigung == "1")); then
./runs/pushover.sh "Gerät 3 ausgeschaltet bei $uberschuss"
fi
fi
fi
fi
fi
fi
}