forked from snaptec/openWB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
u1p3p.sh
368 lines (365 loc) · 13.4 KB
/
u1p3p.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
#!/bin/bash
u1p3pswitch(){
if (( u1p3paktiv == 1 )); then
u1p3pstat=$(<ramdisk/u1p3pstat)
nachtladenstate=$(<ramdisk/nachtladenstate)
nachtladen2state=$(<ramdisk/nachtladen2state)
if [ -z "$u1p3schaltparam" ]; then
u1p3schaltparam = 8
fi
uhwaittime=$(( $u1p3schaltparam * 60 ))
urwaittime=$(( (16 - $u1p3schaltparam) * 60 ))
openwbDebugLog "MAIN" 1 "automatische Umschaltung aktiv"
openwbDebugLog "MAIN" 1 "Timing Umschaltung: $uhwaittime / $urwaittime"
if (( ladestatus == 0)); then
if (( nachtladenstate == 1 )) || (( nachtladen2state == 1 )); then
if (( u1p3pstat != u1p3pnl )); then
openwbDebugLog "MAIN" 1 "Nachtladen derzeit $u1p3pstat Phasen, auf $u1p3pnl konfiguriert, aendere..."
if (( u1p3pnl == 3 )); then
runs/u1p3pcheck.sh 3
else
runs/u1p3pcheck.sh 1
fi
openwbDebugLog "MAIN" 1 "auf $u1p3pnl Phasen geaendert"
fi
else
if (( lademodus == 0 )); then
if (( u1p3pstat != u1p3psofort )); then
openwbDebugLog "MAIN" 1 "Sofortladen derzeit $u1p3pstat Phasen, auf $u1p3psofort konfiguriert, aendere..."
if (( u1p3psofort == 3 )); then
runs/u1p3pcheck.sh 3
else
runs/u1p3pcheck.sh 1
fi
openwbDebugLog "MAIN" 1 "auf $u1p3psofort Phasen geaendert"
fi
fi
if (( lademodus == 1 )); then
if (( u1p3pstat != u1p3pminundpv )); then
if (( u1p3pminundpv == 4 )); then
if (( u1p3pstat == 0 )); then
runs/u1p3pcheck.sh 1
fi
if (( u1p3pstat == 3 )); then
urcounter=$(</var/www/html/openWB/ramdisk/urcounter)
if (( urcounter < urwaittime )); then
if (( urcounter < urwaittime - 60 )); then
urcounter=$((urwaittime - 60))
fi
urcounter=$((urcounter + 10))
echo $urcounter > /var/www/html/openWB/ramdisk/urcounter
else
runs/u1p3pcheck.sh 1
openwbDebugLog "MAIN" 1 "Min PV Laden derzeit $u1p3pstat Phasen, auf 1 Nur PV konfiguriert, aendere..."
echo 0 > /var/www/html/openWB/ramdisk/urcounter
fi
fi
else
openwbDebugLog "MAIN" 1 "Min PV Laden derzeit $u1p3pstat Phasen, auf $u1p3pminundpv konfiguriert, aendere..."
if (( u1p3pnurpv == 3 )); then
runs/u1p3pcheck.sh 3
else
runs/u1p3pcheck.sh 1
fi
openwbDebugLog "MAIN" 1 "auf $u1p3pminundpv Phasen geaendert"
fi
fi
fi
if (( lademodus == 2 )); then
if (( u1p3pstat != u1p3pnurpv )); then
if (( u1p3pnurpv == 4 )); then
if (( u1p3pstat == 0 )); then
runs/u1p3pcheck.sh 1
fi
if (( u1p3pstat == 3 )); then
urcounter=$(</var/www/html/openWB/ramdisk/urcounter)
if (( urcounter < urwaittime )); then
if (( urcounter < urwaittime - 60 )); then
urcounter=$((urwaittime - 60))
fi
urcounter=$((urcounter + 10))
echo $urcounter > /var/www/html/openWB/ramdisk/urcounter
else
runs/u1p3pcheck.sh 1
openwbDebugLog "MAIN" 1 "Nur PV Laden derzeit $u1p3pstat Phasen, auf 1 Nur PV konfiguriert, aendere..."
echo 0 > /var/www/html/openWB/ramdisk/urcounter
fi
fi
else
openwbDebugLog "MAIN" 1 "Nur PV Laden derzeit $u1p3pstat Phasen, auf $u1p3pnurpv konfiguriert, aendere..."
if (( u1p3pnurpv == 3 )); then
runs/u1p3pcheck.sh 3
else
runs/u1p3pcheck.sh 1
fi
openwbDebugLog "MAIN" 1 "auf $u1p3pnurpv Phasen geaendert"
fi
fi
fi
if (( lademodus == 4 )); then
if (( u1p3pstat != u1p3pstandby )); then
openwbDebugLog "MAIN" 1 "Standby Laden derzeit $u1p3pstat Phasen, auf $u1p3pstandby konfiguriert, aendere..."
if (( u1p3pstandby == 3 )); then
runs/u1p3pcheck.sh 3
else
runs/u1p3pcheck.sh 1
fi
openwbDebugLog "MAIN" 1 "auf $u1p3pstandby Phasen geaendert"
fi
fi
if (( lademodus == 3 )); then
if (( u1p3pstat != u1p3pstandby )); then
openwbDebugLog "MAIN" 1 "Stop Laden derzeit $u1p3pstat Phasen, auf $u1p3pstandby konfiguriert, aendere..."
if (( u1p3pstandby == 3 )); then
runs/u1p3pcheck.sh 3
else
runs/u1p3pcheck.sh 1
fi
openwbDebugLog "MAIN" 1 "auf $u1p3pstandby Phasen geaendert"
fi
fi
fi
else
if (( nachtladenstate == 1 )) || (( nachtladen2state == 1 )); then
if (( u1p3pstat != u1p3pnl )); then
openwbDebugLog "MAIN" 1 "Nachtladen derzeit $u1p3pstat Phasen, auf $u1p3pnl konfiguriert, unterbreche Ladung und aendere..."
echo 1 > ramdisk/blockall
runs/u1p3pcheck.sh stop
sleep 5
if (( u1p3pnl == 3 )); then
runs/u1p3pcheck.sh 3
else
runs/u1p3pcheck.sh 1
fi
sleep 1
runs/u1p3pcheck.sh start
echo 0 > ramdisk/blockall
openwbDebugLog "MAIN" 1 "auf $u1p3pnl Phasen geaendert"
fi
else
if (( lademodus == 0 )); then
if (( u1p3pstat != u1p3psofort )); then
openwbDebugLog "MAIN" 1 "Sofortladen derzeit $u1p3pstat Phasen, auf $u1p3psofort konfiguriert, unterbreche Ladung und aendere..."
echo 1 > ramdisk/blockall
runs/u1p3pcheck.sh stop
sleep 5
if (( u1p3psofort == 3 )); then
runs/u1p3pcheck.sh 3
else
runs/u1p3pcheck.sh 1
fi
sleep 1
runs/u1p3pcheck.sh start
echo 0 > ramdisk/blockall
openwbDebugLog "MAIN" 1 "auf $u1p3psofort Phasen geaendert"
fi
fi
if (( lademodus == 1 )); then
if (( u1p3pstat != u1p3pminundpv )); then
if (( u1p3pminundpv == 4 )); then
oldll=$(<ramdisk/llsoll)
if (( u1p3pstat == 1 )); then
if [[ $schieflastaktiv == "1" ]]; then
maximalstromstaerke=$schieflastmaxa
fi
if (( ladeleistung < 100 )); then
if (( uberschuss > ((3 * mindestuberschuss) + 1000) )); then
openwbDebugLog "MAIN" 1 "Min PV Laden derzeit $u1p3pstat Phasen, auf MinPV Automatik konfiguriert, aendere auf 3 Phasen da viel Überschuss vorhanden..."
echo 1 > ramdisk/blockall
runs/u1p3pcheck.sh stop
sleep 8
runs/u1p3pcheck.sh 3
sleep 20
runs/u1p3pcheck.sh startslow
(sleep 25 && echo 0 > ramdisk/blockall)&
openwbDebugLog "MAIN" 1 "auf 3 Phasen MinPV Automatik geaendert"
fi
fi
if (( oldll == maximalstromstaerke )); then
uhcounter=$(</var/www/html/openWB/ramdisk/uhcounter)
if (( uhcounter < uhwaittime )); then
uhcounter=$((uhcounter + 10))
echo $uhcounter > /var/www/html/openWB/ramdisk/uhcounter
openwbDebugLog "MAIN" 1 "Umschaltcounter Erhoehung auf $uhcounter erhoeht fuer Min PV Automatik Phasenumschaltung"
else
openwbDebugLog "MAIN" 1 "Min PV Laden derzeit $u1p3pstat Phasen, auf MinPV Automatik konfiguriert, unterbreche Ladung und aendere auf 3 Phasen..."
echo 1 > ramdisk/blockall
runs/u1p3pcheck.sh stop
sleep 8
runs/u1p3pcheck.sh 3
sleep 20
runs/u1p3pcheck.sh startslow
(sleep 25 && echo 0 > ramdisk/blockall)&
openwbDebugLog "MAIN" 1 "auf 3 Phasen MinPV Automatik geaendert"
echo 0 > /var/www/html/openWB/ramdisk/uhcounter
fi
else
echo 0 > /var/www/html/openWB/ramdisk/uhcounter
fi
else
if (( ladeleistung < 100 )); then
if (( uberschuss < (3 * mindestuberschuss) )); then
echo 0 > /var/www/html/openWB/ramdisk/urcounter
echo 1 > ramdisk/blockall
runs/u1p3pcheck.sh stop
sleep 8
runs/u1p3pcheck.sh 1
sleep 20
runs/u1p3pcheck.sh startslow
(sleep 25 && echo 0 > ramdisk/blockall)&
openwbDebugLog "MAIN" 1 "auf 1 Phasen MinPV Automatik geaendert da geringerer Überschuss"
fi
fi
if (( oldll == minimalampv )); then
urcounter=$(</var/www/html/openWB/ramdisk/urcounter)
if (( urcounter < urwaittime )); then
urcounter=$((urcounter + 10))
echo $urcounter > /var/www/html/openWB/ramdisk/urcounter
openwbDebugLog "MAIN" 1 "Umschaltcounter Reduzierung auf $urcounter erhoeht fuer Min PV Automatik Phasenumschaltung"
else
echo 0 > /var/www/html/openWB/ramdisk/urcounter
echo 1 > ramdisk/blockall
runs/u1p3pcheck.sh stop
sleep 8
runs/u1p3pcheck.sh 1
sleep 20
runs/u1p3pcheck.sh startslow
(sleep 25 && echo 0 > ramdisk/blockall)&
openwbDebugLog "MAIN" 1 "auf 1 Phasen MinPV Automatik geaendert"
fi
else
echo 0 > /var/www/html/openWB/ramdisk/urcounter
fi
fi
else
openwbDebugLog "MAIN" 1 "Min PV Laden derzeit $u1p3pstat Phasen, auf $u1p3pminundpv konfiguriert, unterbreche Ladung und aendere..."
echo 1 > ramdisk/blockall
runs/u1p3pcheck.sh stop
sleep 5
if (( u1p3pminundpv == 3 )); then
runs/u1p3pcheck.sh 3
else
runs/u1p3pcheck.sh 1
fi
sleep 1
runs/u1p3pcheck.sh start
echo 0 > ramdisk/blockall
openwbDebugLog "MAIN" 1 "auf $u1p3pminundpv Phasen geaendert"
fi
fi
fi
if (( lademodus == 2 )); then
if (( u1p3pstat != u1p3pnurpv )); then
if (( u1p3pnurpv == 4 )); then
oldll=$(<ramdisk/llsoll)
if (( u1p3pstat == 1 )); then
if [[ $schieflastaktiv == "1" ]]; then
maximalstromstaerke=$schieflastmaxa
fi
if (( ladeleistung < 100 )); then
if (( uberschuss > ((3 * mindestuberschuss) + 1000) )); then
openwbDebugLog "MAIN" 1 "Nur PV Laden derzeit $u1p3pstat Phasen, auf NurPV Automatik konfiguriert, aendere auf 3 Phasen da viel Überschuss vorhanden..."
echo 1 > ramdisk/blockall
runs/u1p3pcheck.sh stop
sleep 8
runs/u1p3pcheck.sh 3
sleep 20
runs/u1p3pcheck.sh startslow
(sleep 25 && echo 0 > ramdisk/blockall)&
openwbDebugLog "MAIN" 1 "auf 3 Phasen NurPV Automatik geaendert"
fi
fi
if (( oldll == maximalstromstaerke )); then
uhcounter=$(</var/www/html/openWB/ramdisk/uhcounter)
if (( uhcounter < uhwaittime )); then
uhcounter=$((uhcounter + 10))
echo $uhcounter > /var/www/html/openWB/ramdisk/uhcounter
openwbDebugLog "MAIN" 1 "Umschaltcounter Erhoehung auf $uhcounter erhoeht fuer PV Automatik Phasenumschaltung"
else
openwbDebugLog "MAIN" 1 "Nur PV Laden derzeit $u1p3pstat Phasen, auf NurPV Automatik konfiguriert, unterbreche Ladung und aendere auf 3 Phasen..."
echo 1 > ramdisk/blockall
runs/u1p3pcheck.sh stop
sleep 8
runs/u1p3pcheck.sh 3
sleep 20
runs/u1p3pcheck.sh startslow
(sleep 25 && echo 0 > ramdisk/blockall)&
openwbDebugLog "MAIN" 1 "auf 3 Phasen NurPV Automatik geaendert"
echo 0 > /var/www/html/openWB/ramdisk/uhcounter
fi
else
echo 0 > /var/www/html/openWB/ramdisk/uhcounter
fi
else
if (( ladeleistung < 100 )); then
if (( uberschuss < (3 * mindestuberschuss) )); then
echo 0 > /var/www/html/openWB/ramdisk/urcounter
echo 1 > ramdisk/blockall
runs/u1p3pcheck.sh stop
sleep 8
runs/u1p3pcheck.sh 1
sleep 20
runs/u1p3pcheck.sh startslow
(sleep 25 && echo 0 > ramdisk/blockall)&
openwbDebugLog "MAIN" 1 "auf 1 Phasen NurPV Automatik geaendert da geringerer Überschuss"
fi
fi
if (( oldll == minimalapv )); then
urcounter=$(</var/www/html/openWB/ramdisk/urcounter)
if (( urcounter < urwaittime )); then
urcounter=$((urcounter + 10))
echo $urcounter > /var/www/html/openWB/ramdisk/urcounter
openwbDebugLog "MAIN" 1 "Umschaltcounter Reduzierung auf $urcounter erhoeht fuer PV Automatik Phasenumschaltung"
else
echo 0 > /var/www/html/openWB/ramdisk/urcounter
echo 1 > ramdisk/blockall
runs/u1p3pcheck.sh stop
sleep 8
runs/u1p3pcheck.sh 1
sleep 20
runs/u1p3pcheck.sh startslow
(sleep 25 && echo 0 > ramdisk/blockall)&
openwbDebugLog "MAIN" 1 "auf 1 Phasen NurPV Automatik geaendert"
fi
else
echo 0 > /var/www/html/openWB/ramdisk/urcounter
fi
fi
else
openwbDebugLog "MAIN" 1 "Nur PV Laden derzeit $u1p3pstat Phasen, auf $u1p3pnurpv konfiguriert, unterbreche Ladung und aendere..."
echo 1 > ramdisk/blockall
runs/u1p3pcheck.sh stop
sleep 5
if (( u1p3pnurpv == 3 )); then
runs/u1p3pcheck.sh 3
else
runs/u1p3pcheck.sh 1
fi
sleep 1
runs/u1p3pcheck.sh start
echo 0 > ramdisk/blockall
openwbDebugLog "MAIN" 1 "auf $u1p3pnurpv Phasen geaendert"
fi
fi
fi
if (( lademodus == 4 )); then
if (( u1p3pstat != u1p3pstandby )); then
openwbDebugLog "MAIN" 1 "Standby Laden derzeit $u1p3pstat Phasen, auf $u1p3pstandby konfiguriert, unterbreche Ladung und aendere..."
echo 1 > ramdisk/blockall
runs/u1p3pcheck.sh stop
sleep 5
if (( u1p3pstandby == 3 )); then
runs/u1p3pcheck.sh 3
else
runs/u1p3pcheck.sh 1
fi
sleep 1
runs/u1p3pcheck.sh start
echo 0 > ramdisk/blockall
openwbDebugLog "MAIN" 1 "auf $u1p3pstandby Phasen geaendert"
fi
fi
fi
fi
fi
}