forked from snaptec/openWB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
loadvars.sh
executable file
·1908 lines (1826 loc) · 76.5 KB
/
loadvars.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
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
run_soc_module() {
openwbDebugLog "MAIN" 2 "Request to run SoC-Module: $1"
module_dir="modules/$1"
if [ -f "$module_dir/main.sh" ]
then
openwbDebugLog "MAIN" 2 "Calling SoC-Module: $module_dir/main.sh"
"$module_dir/main.sh" &
elif [[ "$module_dir" =~ ^(.*)((s)([1-9])|(lp)([2-9]))$ ]]; then
# Historically if each SoC-Module applied to a single charge point, only. Thus if multiple charge points were
# to be supported the module was copied and got the suffix "s1" or "lp2" for the second charge point.
# With the new structure we call the script for charge point one with the actual charge point number as parameter
if [ "${BASH_REMATCH[3]}" == "s" ]
then
charge_point_num=$((BASH_REMATCH[4] + 1))
else
charge_point_num=${BASH_REMATCH[6]}
fi
module_dir_lp1=${BASH_REMATCH[1]}
if [ -d "$module_dir_lp1" ];
then
openwbDebugLog "MAIN" 2 "Calling SoC-Module: $module_dir_lp1/main.sh for chargepoint $charge_point_num"
"$module_dir_lp1/main.sh" "$charge_point_num" &
else
openwbDebugLog "MAIN" 0 "Neither '$module_dir' nor '$module_dir_lp1' exist!"
fi
else
openwbDebugLog "MAIN" 0 "SoC-Module '$module_dir' does not exist"
fi
}
loadvars(){
#reload mqtt vars
renewmqtt=$(</var/www/html/openWB/ramdisk/renewmqtt)
if ((renewmqtt == 1)); then
echo 0 > /var/www/html/openWB/ramdisk/renewmqtt
echo 01 | tee ramdisk/mqtt*
fi
#get temp vars
sofortll=$(<ramdisk/lp1sofortll)
sofortlls1=$(<ramdisk/lp2sofortll)
sofortlls2=$(<ramdisk/lp3sofortll)
sofortlllp4=$(<ramdisk/lp4sofortll)
sofortlllp5=$(<ramdisk/lp5sofortll)
sofortlllp6=$(<ramdisk/lp6sofortll)
sofortlllp7=$(<ramdisk/lp7sofortll)
sofortlllp8=$(<ramdisk/lp8sofortll)
#get oldvars for mqtt
opvwatt=$(<ramdisk/mqttpvwatt)
owattbezug=$(<ramdisk/mqttwattbezug)
ollaktuell=$(<ramdisk/mqttladeleistunglp1)
ohausverbrauch=$(<ramdisk/mqtthausverbrauch)
ollkombiniert=$(<ramdisk/llkombiniert)
ollaktuells1=$(<ramdisk/mqttladeleistungs1)
ollaktuells2=$(<ramdisk/mqttladeleistungs2)
ospeicherleistung=$(<ramdisk/mqttspeicherleistung)
oladestatus=$(<ramdisk/mqttlastladestatus)
olademodus=$(<ramdisk/mqttlastlademodus)
osoc=$(<ramdisk/mqttsoc)
osoc1=$(<ramdisk/mqttsoc1)
ostopchargeafterdisclp1=$(<ramdisk/mqttstopchargeafterdisclp1)
ostopchargeafterdisclp2=$(<ramdisk/mqttstopchargeafterdisclp2)
ostopchargeafterdisclp3=$(<ramdisk/mqttstopchargeafterdisclp3)
ostopchargeafterdisclp4=$(<ramdisk/mqttstopchargeafterdisclp4)
ostopchargeafterdisclp5=$(<ramdisk/mqttstopchargeafterdisclp5)
ostopchargeafterdisclp6=$(<ramdisk/mqttstopchargeafterdisclp6)
ostopchargeafterdisclp7=$(<ramdisk/mqttstopchargeafterdisclp7)
ostopchargeafterdisclp8=$(<ramdisk/mqttstopchargeafterdisclp8)
ospeichersoc=$(<ramdisk/mqttspeichersoc)
ladestatus=$(</var/www/html/openWB/ramdisk/ladestatus)
odailychargelp1=$(<ramdisk/mqttdailychargelp1)
odailychargelp2=$(<ramdisk/mqttdailychargelp2)
odailychargelp3=$(<ramdisk/mqttdailychargelp3)
oaktgeladens1=$(<ramdisk/mqttaktgeladens1)
oaktgeladens2=$(<ramdisk/mqttaktgeladens2)
oaktgeladen=$(<ramdisk/mqttaktgeladen)
orestzeitlp1=$(<ramdisk/mqttrestzeitlp1)
orestzeitlp2=$(<ramdisk/mqttrestzeitlp2)
orestzeitlp3=$(<ramdisk/mqttrestzeitlp3)
ogelrlp1=$(<ramdisk/mqttgelrlp1)
ogelrlp2=$(<ramdisk/mqttgelrlp2)
ogelrlp3=$(<ramdisk/mqttgelrlp3)
olastregelungaktiv=$(<ramdisk/lastregelungaktiv)
ohook1aktiv=$(<ramdisk/hook1akt)
ohook2aktiv=$(<ramdisk/hook2akt)
ohook3aktiv=$(<ramdisk/hook3akt)
lp1enabled=$(<ramdisk/lp1enabled)
lp2enabled=$(<ramdisk/lp2enabled)
lp3enabled=$(<ramdisk/lp3enabled)
lp4enabled=$(<ramdisk/lp4enabled)
lp5enabled=$(<ramdisk/lp5enabled)
lp6enabled=$(<ramdisk/lp6enabled)
lp7enabled=$(<ramdisk/lp7enabled)
lp8enabled=$(<ramdisk/lp8enabled)
version=$(<web/version)
# EVSE DIN Plug State
declare -r IsNumberRegex='^[0-9]+$'
if [[ $evsecon == "modbusevse" ]]; then
if ((modbusevseid == 0)); then
if [ -f /var/www/html/openWB/ramdisk/evsemodulconfig ]; then
modbusevsesource=$(<ramdisk/evsemodulconfig)
modbusevseid=1
else
if [[ -e "/dev/ttyUSB0" ]]; then
echo "/dev/ttyUSB0" > ramdisk/evsemodulconfig
else
echo "/dev/serial0" > ramdisk/evsemodulconfig
fi
modbusevsesource=$(<ramdisk/evsemodulconfig)
modbusevseid=1
fi
fi
evseplugstate=$(sudo python runs/readmodbus.py "$modbusevsesource" "$modbusevseid" 1002 1)
if [ -z "${evseplugstate}" ] || ! [[ "${evseplugstate}" =~ $IsNumberRegex ]]; then
# EVSE read returned empty or non-numeric value --> use last state for this loop
evseplugstate=$(</var/www/html/openWB/ramdisk/evseplugstate)
openwbDebugLog "MAIN" 0 "Modbus EVSE read CP1 issue - using previous state '${evseplugstate}'"
else
echo "$evseplugstate" > /var/www/html/openWB/ramdisk/evseplugstate
fi
ladestatuslp1=$(</var/www/html/openWB/ramdisk/ladestatus)
if ((evseplugstate >= 0)) && ((evseplugstate <= 10)); then
if ((evseplugstate > 1)); then
plugstat=$(</var/www/html/openWB/ramdisk/plugstat)
if ((plugstat == 0)) ; then
if ((pushbplug == 1)) && ((ladestatuslp1 == 0)) && ((pushbenachrichtigung == 1)) ; then
message="Fahrzeug eingesteckt. Ladung startet bei erfüllter Ladebedingung automatisch."
/var/www/html/openWB/runs/pushover.sh "$message"
fi
if ((displayconfigured == 1)) && ((displayEinBeimAnstecken == 1)) ; then
export DISPLAY=:0 && xset dpms force on && xset dpms "$displaysleep" "$displaysleep" "$displaysleep"
fi
echo 20000 > /var/www/html/openWB/ramdisk/soctimer
fi
echo 1 > /var/www/html/openWB/ramdisk/plugstat
plugstat=1
else
echo 0 > /var/www/html/openWB/ramdisk/plugstat
plugstat=0
fi
if ((evseplugstate > 2)) && ((ladestatuslp1 == 1)) && ((lp1enabled == 1)); then
echo 1 > /var/www/html/openWB/ramdisk/chargestat
chargestat=1
else
echo 0 > /var/www/html/openWB/ramdisk/chargestat
chargestat=0
fi
fi
else
pluggedin=$(</var/www/html/openWB/ramdisk/pluggedin)
if ((pluggedin >= 0)); then
if ((pushbplug == 1)) && ((ladestatuslp1 == 0)) && ((pushbenachrichtigung == 1)) ; then
message="Fahrzeug eingesteckt. Ladung startet bei erfüllter Ladebedingung automatisch."
/var/www/html/openWB/runs/pushover.sh "$message"
fi
if ((displayconfigured == 1)) && ((displayEinBeimAnstecken == 1)) ; then
export DISPLAY=:0 && xset dpms force on && xset dpms "$displaysleep" "$displaysleep" "$displaysleep"
fi
echo 20000 > /var/www/html/openWB/ramdisk/soctimer
echo 0 > /var/www/html/openWB/ramdisk/pluggedin
fi
plugstat=$(<ramdisk/plugstat)
chargestat=$(<ramdisk/chargestat)
fi
if [[ $evsecon == "ipevse" ]]; then
evseplugstatelp1=$(sudo python runs/readipmodbus.py "$evseiplp1" "$evseidlp1" 1002 1)
if [ -z "${evseplugstate}" ] || ! [[ "${evseplugstate}" =~ $IsNumberRegex ]]; then
evseplugstate=$(</var/www/html/openWB/ramdisk/evseplugstate)
openwbDebugLog "MAIN" 0 "IP EVSE read CP1 issue - using previous state '${evseplugstate}'"
else
echo "$evseplugstate" > /var/www/html/openWB/ramdisk/evseplugstate
fi
ladestatuslp1=$(</var/www/html/openWB/ramdisk/ladestatus)
if ((evseplugstatelp1 > 1)); then
echo 1 > /var/www/html/openWB/ramdisk/plugstat
else
echo 0 > /var/www/html/openWB/ramdisk/plugstat
fi
if ((evseplugstatelp1 > 2)) && ((ladestatuslp1 == 1)) && ((lp1enabled == 1)); then
echo 1 > /var/www/html/openWB/ramdisk/chargestat
else
echo 0 > /var/www/html/openWB/ramdisk/chargestat
fi
fi
if ((lastmanagement == 1)); then
ConfiguredChargePoints=2
if [[ $evsecons1 == "modbusevse" ]]; then
evseplugstatelp2=$(sudo python runs/readmodbus.py "$evsesources1" "$evseids1" 1002 1)
if [ -z "${evseplugstatelp2}" ] || ! [[ "${evseplugstatelp2}" =~ $IsNumberRegex ]]; then
evseplugstatelp2=$(</var/www/html/openWB/ramdisk/evseplugstatelp2)
openwbDebugLog "MAIN" 0 "Modbus EVSE read CP2 issue - using previous state '${evseplugstatelp2}'"
else
echo "$evseplugstatelp2" > /var/www/html/openWB/ramdisk/evseplugstatelp2
fi
ladestatuss1=$(</var/www/html/openWB/ramdisk/ladestatuss1)
if ((evseplugstatelp2 > 0)) && ((evseplugstatelp2 < 7)); then
if ((evseplugstatelp2 > 1)); then
plugstat2=$(</var/www/html/openWB/ramdisk/plugstats1)
if ((plugstat2 == 0)) ; then
if ((displayconfigured == 1)) && ((displayEinBeimAnstecken == 1)) ; then
export DISPLAY=:0 && xset dpms force on && xset dpms "$displaysleep" "$displaysleep" "$displaysleep"
fi
echo 20000 > /var/www/html/openWB/ramdisk/soctimer1
fi
echo 1 > /var/www/html/openWB/ramdisk/plugstats1
plugstat2=1
plugstats1=$plugstat2
else
echo 0 > /var/www/html/openWB/ramdisk/plugstats1
plugstat2=0
plugstats1=$plugstat2
fi
if ((evseplugstatelp2 > 2)) && ((ladestatuss1 == 1)); then
echo 1 > /var/www/html/openWB/ramdisk/chargestats1
else
echo 0 > /var/www/html/openWB/ramdisk/chargestats1
fi
fi
fi
if [[ $evsecons1 == "slaveeth" ]]; then
evseplugstatelp2=$(sudo python runs/readslave.py 1002 1)
if [ -z "${evseplugstatelp2}" ] || ! [[ "${evseplugstatelp2}" =~ $IsNumberRegex ]]; then
evseplugstatelp2=$(</var/www/html/openWB/ramdisk/evseplugstatelp2)
openwbDebugLog "MAIN" 0 "Slaveeth EVSE read CP2 issue - using previous state '${evseplugstatelp2}'"
else
echo "$evseplugstatelp2" > /var/www/html/openWB/ramdisk/evseplugstatelp2
fi
ladestatuss1=$(</var/www/html/openWB/ramdisk/ladestatuss1)
if ((evseplugstatelp2 > 1)); then
echo 1 > /var/www/html/openWB/ramdisk/plugstats1
else
echo 0 > /var/www/html/openWB/ramdisk/plugstats1
fi
if ((evseplugstatelp2 > 2)) && ((ladestatuss1 == 1)); then
echo 1 > /var/www/html/openWB/ramdisk/chargestats1
else
echo 0 > /var/www/html/openWB/ramdisk/chargestats1
fi
fi
if [[ $evsecons1 == "ipevse" ]]; then
evseplugstatelp2=$(sudo python runs/readipmodbus.py "$evseiplp2" "$evseidlp2" 1002 1)
if [ -z "${evseplugstatelp2}" ] || ! [[ "${evseplugstatelp2}" =~ $IsNumberRegex ]]; then
evseplugstatelp2=$(</var/www/html/openWB/ramdisk/evseplugstatelp2)
openwbDebugLog "MAIN" 0 "IP EVSE read CP2 issue - using previous state '${evseplugstatelp2}'"
else
echo "$evseplugstatelp2" > /var/www/html/openWB/ramdisk/evseplugstatelp2
fi
ladestatuslp2=$(</var/www/html/openWB/ramdisk/ladestatuss1)
if ((evseplugstatelp2 > 1)); then
echo 1 > /var/www/html/openWB/ramdisk/plugstats1
else
echo 0 > /var/www/html/openWB/ramdisk/plugstats1
fi
if ((evseplugstatelp2 > 2)) && ((ladestatuslp2 == 1)) && ((lp2enabled == 1)); then
echo 1 > /var/www/html/openWB/ramdisk/chargestats1
else
echo 0 > /var/www/html/openWB/ramdisk/chargestats1
fi
fi
plugstatlp2=$(<ramdisk/plugstats1)
chargestatlp2=$(<ramdisk/chargestats1)
else
plugstatlp2=$(<ramdisk/plugstats1)
chargestatlp2=$(<ramdisk/chargestats1)
ConfiguredChargePoints=1
fi
if ((lastmanagements2 == 1)); then
ConfiguredChargePoints=3
if [[ $evsecons2 == "ipevse" ]]; then
evseplugstatelp3=$(sudo python runs/readipmodbus.py "$evseiplp3" "$evseidlp3" 1002 1)
if [ -z "${evseplugstatelp3}" ] || ! [[ "${evseplugstatelp3}" =~ $IsNumberRegex ]]; then
evseplugstatelp3=$(</var/www/html/openWB/ramdisk/evseplugstatelp3)
openwbDebugLog "MAIN" 0 "IP EVSE read CP3 issue - using previous state '${evseplugstatelp3}'"
else
echo "$evseplugstatelp3" > /var/www/html/openWB/ramdisk/evseplugstatelp3
fi
ladestatuslp3=$(</var/www/html/openWB/ramdisk/ladestatuss2)
if ((evseplugstatelp3 > 1)); then
echo 1 > /var/www/html/openWB/ramdisk/plugstatlp3
else
echo 0 > /var/www/html/openWB/ramdisk/plugstatlp3
fi
if ((evseplugstatelp3 > 2)) && ((ladestatuslp3 == 1)) && ((lp3enabled == 1)); then
echo 1 > /var/www/html/openWB/ramdisk/chargestatlp3
else
echo 0 > /var/www/html/openWB/ramdisk/chargestatlp3
fi
fi
if [[ $evsecons2 == "modbusevse" ]]; then
evseplugstatelp3=$(sudo python runs/readmodbus.py "$evsesources2" "$evseids2" 1002 1)
if [ -z "${evseplugstatelp3}" ] || ! [[ "${evseplugstatelp3}" =~ $IsNumberRegex ]]; then
evseplugstatelp3=$(</var/www/html/openWB/ramdisk/evseplugstatelp3)
openwbDebugLog "MAIN" 0 "Modbus EVSE read CP3 issue - using previous state '${evseplugstatelp3}'"
else
echo "$evseplugstatelp3" > /var/www/html/openWB/ramdisk/evseplugstatelp3
fi
ladestatuss2=$(</var/www/html/openWB/ramdisk/ladestatuss2)
if ((evseplugstatelp3 > 1)); then
echo 1 > /var/www/html/openWB/ramdisk/plugstatlp3
else
echo 0 > /var/www/html/openWB/ramdisk/plugstatlp3
fi
if ((evseplugstatelp3 > 2)) && ((ladestatuss2 == 1)) ; then
echo 1 > /var/www/html/openWB/ramdisk/chargestatlp3
else
echo 0 > /var/www/html/openWB/ramdisk/chargestatlp3
fi
fi
plugstatlp3=$(<ramdisk/plugstatlp3)
chargestatlp3=$(<ramdisk/chargestatlp3)
else
plugstatlp3=$(<ramdisk/plugstatlp3)
chargestatlp3=$(<ramdisk/chargestatlp3)
fi
if ((lastmanagementlp4 == 1)); then
ConfiguredChargePoints=4
if [[ $evseconlp4 == "ipevse" ]]; then
evseplugstatelp4=$(sudo python runs/readipmodbus.py "$evseiplp4" "$evseidlp4" 1002 1)
if [ -z "${evseplugstatelp4}" ] || ! [[ "${evseplugstatelp4}" =~ $IsNumberRegex ]]; then
# EVSE read returned empty or non-numeric value --> use last state for this loop
evseplugstatelp4=$(</var/www/html/openWB/ramdisk/evseplugstatelp4)
openwbDebugLog "MAIN" 0 "IP EVSE read CP4 issue - using previous state '${evseplugstatelp4}'"
else
echo "$evseplugstatelp4" > /var/www/html/openWB/ramdisk/evseplugstatelp4
fi
ladestatuslp4=$(</var/www/html/openWB/ramdisk/ladestatuslp4)
if ((evseplugstatelp4 > 1)); then
echo 1 > /var/www/html/openWB/ramdisk/plugstatlp4
else
echo 0 > /var/www/html/openWB/ramdisk/plugstatlp4
fi
if ((evseplugstatelp4 > 2)) && ((ladestatuslp4 == 1)) && ((lp4enabled == 1)); then
echo 1 > /var/www/html/openWB/ramdisk/chargestatlp4
else
echo 0 > /var/www/html/openWB/ramdisk/chargestatlp4
fi
fi
fi
if ((lastmanagementlp5 == 1)); then
ConfiguredChargePoints=5
if [[ $evseconlp5 == "ipevse" ]]; then
evseplugstatelp5=$(sudo python runs/readipmodbus.py "$evseiplp5" "$evseidlp5" 1002 1)
if [ -z "${evseplugstatelp5}" ] || ! [[ "${evseplugstatelp5}" =~ $IsNumberRegex ]]; then
# EVSE read returned empty or non-numeric value --> use last state for this loop
evseplugstatelp5=$(</var/www/html/openWB/ramdisk/evseplugstatelp5)
openwbDebugLog "MAIN" 0 "IP EVSE read CP5 issue - using previous state '${evseplugstatelp5}'"
else
echo "$evseplugstatelp5" > /var/www/html/openWB/ramdisk/evseplugstatelp5
fi
ladestatuslp5=$(</var/www/html/openWB/ramdisk/ladestatuslp5)
if ((evseplugstatelp5 > 1)); then
echo 1 > /var/www/html/openWB/ramdisk/plugstatlp5
else
echo 0 > /var/www/html/openWB/ramdisk/plugstatlp5
fi
if ((evseplugstatelp5 > 2)) && ((ladestatuslp5 == 1)) && ((lp5enabled == 1)) ; then
echo 1 > /var/www/html/openWB/ramdisk/chargestatlp5
else
echo 0 > /var/www/html/openWB/ramdisk/chargestatlp5
fi
fi
fi
if ((lastmanagementlp6 == 1)); then
ConfiguredChargePoints=6
if [[ $evseconlp6 == "ipevse" ]]; then
evseplugstatelp6=$(sudo python runs/readipmodbus.py "$evseiplp6" "$evseidlp6" 1002 1)
if [ -z "${evseplugstatelp6}" ] || ! [[ "${evseplugstatelp6}" =~ $IsNumberRegex ]]; then
# EVSE read returned empty or non-numeric value --> use last state for this loop
evseplugstatelp6=$(</var/www/html/openWB/ramdisk/evseplugstatelp6)
openwbDebugLog "MAIN" 0 "IP EVSE read CP6 issue - using previous state '${evseplugstatelp6}'"
else
echo "$evseplugstatelp6" > /var/www/html/openWB/ramdisk/evseplugstatelp6
fi
ladestatuslp6=$(</var/www/html/openWB/ramdisk/ladestatuslp6)
if ((evseplugstatelp6 > 1)); then
echo 1 > /var/www/html/openWB/ramdisk/plugstatlp6
else
echo 0 > /var/www/html/openWB/ramdisk/plugstatlp6
fi
if ((evseplugstatelp6 > 2)) && ((ladestatuslp6 == 1)) && ((lp6enabled == 1)) ; then
echo 1 > /var/www/html/openWB/ramdisk/chargestatlp6
else
echo 0 > /var/www/html/openWB/ramdisk/chargestatlp6
fi
fi
fi
if ((lastmanagementlp7 == 1)); then
ConfiguredChargePoints=7
if [[ $evseconlp7 == "ipevse" ]]; then
evseplugstatelp7=$(sudo python runs/readipmodbus.py "$evseiplp7" "$evseidlp7" 1002 1)
if [ -z "${evseplugstatelp7}" ] || ! [[ "${evseplugstatelp7}" =~ $IsNumberRegex ]]; then
# EVSE read returned empty or non-numeric value --> use last state for this loop
evseplugstatelp7=$(</var/www/html/openWB/ramdisk/evseplugstatelp7)
openwbDebugLog "MAIN" 0 "IP EVSE read CP7 issue - using previous state '${evseplugstatelp7}'"
else
echo "$evseplugstatelp7" > /var/www/html/openWB/ramdisk/evseplugstatelp7
fi
ladestatuslp7=$(</var/www/html/openWB/ramdisk/ladestatuslp7)
if ((evseplugstatelp7 > 1)); then
echo 1 > /var/www/html/openWB/ramdisk/plugstatlp7
else
echo 0 > /var/www/html/openWB/ramdisk/plugstatlp7
fi
if ((evseplugstatelp7 > 2)) && ((ladestatuslp7 == 1)) && ((lp7enabled == 1)) ; then
echo 1 > /var/www/html/openWB/ramdisk/chargestatlp7
else
echo 0 > /var/www/html/openWB/ramdisk/chargestatlp7
fi
fi
fi
if ((lastmanagementlp8 == 1)); then
ConfiguredChargePoints=8
if [[ $evseconlp8 == "ipevse" ]]; then
evseplugstatelp8=$(sudo python runs/readipmodbus.py "$evseiplp8" "$evseidlp8" 1002 1)
if [ -z "${evseplugstatelp8}" ] || ! [[ "${evseplugstatelp8}" =~ $IsNumberRegex ]]; then
# EVSE read returned empty or non-numeric value --> use last state for this loop
evseplugstatelp4=$(</var/www/html/openWB/ramdisk/evseplugstatelp8)
openwbDebugLog "MAIN" 0 "IP EVSE read CP8 issue - using previous state '${evseplugstatelp8}'"
else
echo "$evseplugstatelp8" > /var/www/html/openWB/ramdisk/evseplugstatelp8
fi
ladestatuslp8=$(</var/www/html/openWB/ramdisk/ladestatuslp8)
if ((evseplugstatelp8 > 1)); then
echo 1 > /var/www/html/openWB/ramdisk/plugstatlp8
else
echo 0 > /var/www/html/openWB/ramdisk/plugstatlp8
fi
if ((evseplugstatelp8 > 2)) && ((ladestatuslp8 == 1)) && ((lp8enabled == 1)) ; then
echo 1 > /var/www/html/openWB/ramdisk/chargestatlp8
else
echo 0 > /var/www/html/openWB/ramdisk/chargestatlp8
fi
fi
fi
echo $ConfiguredChargePoints > ramdisk/ConfiguredChargePoints
# Lastmanagement var check age
if test $(find "ramdisk/lastregelungaktiv" -mmin +2); then
echo " " > ramdisk/lastregelungaktiv
fi
# Werte für die Berechnung ermitteln
lademodus=$(</var/www/html/openWB/ramdisk/lademodus)
if [ -z "$lademodus" ] ; then
mosquitto_pub -r -t "openWB/set/ChargeMode" -m "$bootmodus"
lademodus=$bootmodus
fi
llalt=$(cat /var/www/html/openWB/ramdisk/llsoll)
llaltlp1=$llalt
#PV Leistung ermitteln
# pv1watt Leistung WR1
# pv2watt Leistung WR2
# pvwatt gesamtleistung WR1 und WR2
# pvallwatt gleich zu pvwatt
# pv Counter
# pvkwh zaehler wr1
# pv2kwh zaehler wr2
# pvallwh summe von pvkwh und pv2kwh (wird in cron5 und cronnighly verwendet)
if [[ $pvwattmodul != "none" ]]; then
pv1vorhanden="1"
echo 1 > /var/www/html/openWB/ramdisk/pv1vorhanden
pvwatt=$("modules/$pvwattmodul/main.sh" || true)
if ! [[ $pvwatt =~ $re ]] ; then
openwbDebugLog "MAIN" 0 "ungültiger Wert für pvwatt: $pvwatt"
pvwatt="0"
fi
pv1watt=$pvwatt
echo "$pv1watt" > ramdisk/pv1watt
else
pv1vorhanden="0"
echo 0 > /var/www/html/openWB/ramdisk/pv1vorhanden
pvwatt=$(</var/www/html/openWB/ramdisk/pvwatt)
fi
if [[ $pv2wattmodul != "none" ]]; then
pv2vorhanden="1"
echo 1 > /var/www/html/openWB/ramdisk/pv2vorhanden
pv2watt=$("modules/$pv2wattmodul/main.sh" || true)
if ! [[ $pv2watt =~ $re ]] ; then
openwbDebugLog "MAIN" 0 "ungültiger Wert für pv2watt: $pv2watt"
pv2watt="0"
fi
echo $pv2watt > ramdisk/pv2watt
pvwatt=$((pvwatt + pv2watt))
if ! [[ $pvwatt =~ $re ]] ; then
openwbDebugLog "MAIN" 0 "ungültiger Wert für PV Gesamtleistung: $pvwatt"
pvwatt="0"
fi
echo "$pvwatt" > /var/www/html/openWB/ramdisk/pvallwatt
pvkwh=$(</var/www/html/openWB/ramdisk/pvkwh)
pv2kwh=$(</var/www/html/openWB/ramdisk/pv2kwh)
pvallwh=$(echo "$pvkwh + $pv2kwh" |bc)
echo "$pvallwh" > /var/www/html/openWB/ramdisk/pvallwh
else
pvkwh=$(</var/www/html/openWB/ramdisk/pvkwh)
pv2vorhanden="0"
echo 0 > /var/www/html/openWB/ramdisk/pv2vorhanden
echo "$pvkwh" > /var/www/html/openWB/ramdisk/pvallwh
echo "$pvwatt" > /var/www/html/openWB/ramdisk/pvallwatt
fi
#Speicher werte
if [[ $speichermodul != "none" ]] ; then
timeout 5 "modules/$speichermodul/main.sh"
if [[ $? -eq 124 ]] ; then
openwbModulePublishState "BAT" 2 "Die Werte konnten nicht innerhalb des Timeouts abgefragt werden. Bitte Konfiguration und Gerätestatus prüfen."
else
openwbModulePublishState "BAT" 0 ""
fi
speicherleistung=$(</var/www/html/openWB/ramdisk/speicherleistung)
speicherleistung=${speicherleistung//.*/}
speichersoc=$(</var/www/html/openWB/ramdisk/speichersoc)
speichersoc=${speichersoc//.*/}
speichervorhanden="1"
echo 1 > /var/www/html/openWB/ramdisk/speichervorhanden
if [[ $speichermodul == "speicher_e3dc" ]] ; then
pvwatt=$(</var/www/html/openWB/ramdisk/pvwatt)
echo 1 > /var/www/html/openWB/ramdisk/pv1vorhanden
pv1vorhanden="1"
echo "$pvwatt" > ramdisk/pv1watt
fi
else
speichervorhanden="0"
echo 0 > /var/www/html/openWB/ramdisk/speichervorhanden
fi
#addition pv nach Speicherauslesung
if ((pv2vorhanden == 1)); then
pv1watt=$(</var/www/html/openWB/ramdisk/pv1watt)
pv2watt=$(</var/www/html/openWB/ramdisk/pv2watt)
pvwatt=$((pv1watt + pv2watt))
echo "$pvwatt" > /var/www/html/openWB/ramdisk/pvallwatt
echo "$pvwatt" > /var/www/html/openWB/ramdisk/pvwatt
else
if ((pv1vorhanden == 1)); then
pv1watt=$(</var/www/html/openWB/ramdisk/pv1watt)
pvwatt=$pv1watt
echo "$pvwatt" > /var/www/html/openWB/ramdisk/pvallwatt
echo "$pvwatt" > /var/www/html/openWB/ramdisk/pvwatt
fi
fi
llphaset=3
#Ladeleistung ermitteln
if [[ $ladeleistungmodul != "none" ]]; then
timeout 10 "modules/$ladeleistungmodul/main.sh" || true
llkwh=$(</var/www/html/openWB/ramdisk/llkwh)
llkwhges=$llkwh
lla1=$(cat /var/www/html/openWB/ramdisk/lla1)
lla2=$(cat /var/www/html/openWB/ramdisk/lla2)
lla3=$(cat /var/www/html/openWB/ramdisk/lla3)
lla1=${lla1//.*/}
lla2=${lla2//.*/}
lla3=${lla3//.*/}
llv1=$(cat /var/www/html/openWB/ramdisk/llv1)
llv2=$(cat /var/www/html/openWB/ramdisk/llv2)
llv3=$(cat /var/www/html/openWB/ramdisk/llv3)
ladeleistung=$(cat /var/www/html/openWB/ramdisk/llaktuell)
ladeleistunglp1=$ladeleistung
if ! [[ $lla1 =~ $re ]] ; then
openwbDebugLog "MAIN" 0 "ungültiger Wert für lla1: $lla1"
lla1="0"
fi
if ! [[ $lla2 =~ $re ]] ; then
openwbDebugLog "MAIN" 0 "ungültiger Wert für lla2: $lla2"
lla2="0"
fi
if ! [[ $lla3 =~ $re ]] ; then
openwbDebugLog "MAIN" 0 "ungültiger Wert für lla3: $lla3"
lla3="0"
fi
lp1phasen=0
if ((lla1 >= llphaset)); then
((lp1phasen++))
fi
if ((lla2 >= llphaset)); then
((lp1phasen++))
fi
if ((lla3 >= llphaset)); then
((lp1phasen++))
fi
echo "$lp1phasen" > /var/www/html/openWB/ramdisk/lp1phasen
if ! [[ $ladeleistung =~ $re ]] ; then
openwbDebugLog "MAIN" 0 "ungültiger Wert für ladeleistung: $ladeleistung"
ladeleistung="0"
fi
ladestatus=$(</var/www/html/openWB/ramdisk/ladestatus)
else
lla1=0
lla2=0
lla3=0
ladeleistung=0
llkwh=0
llkwhges=$llkwh
fi
#zweiter ladepunkt
if ((lastmanagement == 1)); then
if [[ $socmodul1 != "none" ]]; then
run_soc_module "$socmodul1"
soc1=$(</var/www/html/openWB/ramdisk/soc1)
tmpsoc1=$(</var/www/html/openWB/ramdisk/tmpsoc1)
if ! [[ $soc1 =~ $re ]] ; then
openwbDebugLog "MAIN" 0 "ungültiger Wert für soc1: $soc1"
soc1=$tmpsoc1
else
echo "$soc1" > /var/www/html/openWB/ramdisk/tmpsoc1
fi
soc1vorhanden=1
echo 1 > /var/www/html/openWB/ramdisk/soc1vorhanden
else
echo 0 > /var/www/html/openWB/ramdisk/soc1vorhanden
soc1=0
soc1vorhanden=0
fi
timeout 10 "modules/$ladeleistungs1modul/main.sh" || true
llkwhs1=$(</var/www/html/openWB/ramdisk/llkwhs1)
llkwhges=$(echo "$llkwhges + $llkwhs1" |bc)
llalts1=$(cat /var/www/html/openWB/ramdisk/llsolls1)
ladeleistungs1=$(cat /var/www/html/openWB/ramdisk/llaktuells1)
ladeleistunglp2=$ladeleistungs1
llas11=$(cat /var/www/html/openWB/ramdisk/llas11)
llas12=$(cat /var/www/html/openWB/ramdisk/llas12)
llas13=$(cat /var/www/html/openWB/ramdisk/llas13)
llas11=${llas11//.*/}
llas12=${llas12//.*/}
llas13=${llas13//.*/}
ladestatuss1=$(</var/www/html/openWB/ramdisk/ladestatuss1)
if ! [[ $ladeleistungs1 =~ $re ]] ; then
ladeleistungs1="0"
fi
ladeleistung=$((ladeleistung + ladeleistungs1))
echo "$ladeleistung" > /var/www/html/openWB/ramdisk/llkombiniert
lp2phasen=0
if ((llas11 >= llphaset)); then
((lp2phasen++))
fi
if ((llas12 >= llphaset)); then
((lp2phasen++))
fi
if ((llas13 >= llphaset)); then
((lp2phasen++))
fi
echo "$lp2phasen" > /var/www/html/openWB/ramdisk/lp2phasen
else
echo "$ladeleistung" > /var/www/html/openWB/ramdisk/llkombiniert
ladeleistunglp2=0
soc1vorhanden=0
fi
#dritter ladepunkt
if ((lastmanagements2 == 1)); then
timeout 10 "modules/$ladeleistungs2modul/main.sh" || true
llkwhs2=$(</var/www/html/openWB/ramdisk/llkwhs2)
llkwhges=$(echo "$llkwhges + $llkwhs2" |bc)
llalts2=$(cat /var/www/html/openWB/ramdisk/llsolls2)
ladeleistungs2=$(cat /var/www/html/openWB/ramdisk/llaktuells2)
ladeleistunglp3=$ladeleistungs2
llas21=$(cat /var/www/html/openWB/ramdisk/llas21)
llas22=$(cat /var/www/html/openWB/ramdisk/llas22)
llas23=$(cat /var/www/html/openWB/ramdisk/llas23)
llas21=${llas21//.*/}
llas22=${llas22//.*/}
llas23=${llas23//.*/}
lp3phasen=0
if ((llas21 >= llphaset)); then
((lp3phasen++))
fi
if ((llas22 >= llphaset)); then
((lp3phasen++))
fi
if ((llas23 >= llphaset)); then
((lp3phasen++))
fi
echo "$lp3phasen" > /var/www/html/openWB/ramdisk/lp3phasen
ladestatuss2=$(</var/www/html/openWB/ramdisk/ladestatuss2)
if ! [[ $ladeleistungs2 =~ $re ]] ; then
openwbDebugLog "MAIN" 0 "ungültiger Wert für ladeleistungs2: $ladeleistungs2"
ladeleistungs2="0"
fi
ladeleistung=$((ladeleistung + ladeleistungs2))
echo "$ladeleistung" > /var/www/html/openWB/ramdisk/llkombiniert
else
echo "$ladeleistung" > /var/www/html/openWB/ramdisk/llkombiniert
ladeleistungs2="0"
ladeleistunglp3=0
fi
#vierter ladepunkt
if ((lastmanagementlp4 == 1)); then
if [[ "$evseconlp4" == "extopenwb" ]]; then
timeout 3 modules/extopenwb/main.sh 4 "$chargep4ip" "$chargep4cp" || true
else
timeout 3 modules/mpm3pmlllp4/main.sh || true
fi
llkwhlp4=$(</var/www/html/openWB/ramdisk/llkwhlp4)
llkwhges=$(echo "$llkwhges + $llkwhlp4" |bc)
llaltlp4=$(cat /var/www/html/openWB/ramdisk/llsolllp4)
ladeleistunglp4=$(cat /var/www/html/openWB/ramdisk/llaktuelllp4)
lla1lp4=$(cat /var/www/html/openWB/ramdisk/lla1lp4)
lla2lp4=$(cat /var/www/html/openWB/ramdisk/lla2lp4)
lla3lp4=$(cat /var/www/html/openWB/ramdisk/lla3lp4)
lla1lp4=${lla1lp4//.*/}
lla2lp4=${lla2lp4//.*/}
lla3lp4=${lla3lp4//.*/}
lp4phasen=0
if ((lla1lp4 >= llphaset)); then
((lp4phasen++))
fi
if ((lla2lp4 >= llphaset)); then
((lp4phasen++))
fi
if ((lla3lp4 >= llphaset)); then
((lp4phasen++))
fi
echo "$lp4phasen" > /var/www/html/openWB/ramdisk/lp4phasen
ladestatuslp4=$(</var/www/html/openWB/ramdisk/ladestatuslp4)
if ! [[ $ladeleistunglp4 =~ $re ]] ; then
openwbDebugLog "MAIN" 0 "ungültiger Wert für ladeleistunglp4: $ladeleistunglp4"
ladeleistunglp4="0"
fi
ladeleistung=$((ladeleistung + ladeleistunglp4))
else
ladeleistunglp4=0
fi
#fünfter ladepunkt
if ((lastmanagementlp5 == 1)); then
if [[ "$evseconlp5" == "extopenwb" ]]; then
timeout 3 modules/extopenwb/main.sh 5 "$chargep5ip" "$chargep5cp" || true
else
timeout 3 modules/mpm3pmlllp5/main.sh || true
fi
llkwhlp5=$(</var/www/html/openWB/ramdisk/llkwhlp5)
llkwhges=$(echo "$llkwhges + $llkwhlp5" |bc)
llaltlp5=$(cat /var/www/html/openWB/ramdisk/llsolllp5)
ladeleistunglp5=$(cat /var/www/html/openWB/ramdisk/llaktuelllp5)
lla1lp5=$(cat /var/www/html/openWB/ramdisk/lla1lp5)
lla2lp5=$(cat /var/www/html/openWB/ramdisk/lla2lp5)
lla3lp5=$(cat /var/www/html/openWB/ramdisk/lla3lp5)
lla1lp5=${lla1lp5//.*/}
lla2lp5=${lla2lp5//.*/}
lla3lp5=${lla3lp5//.*/}
lp5phasen=0
if ((lla1lp5 >= llphaset)); then
((lp5phasen++))
fi
if ((lla2lp5 >= llphaset)); then
((lp5phasen++))
fi
if ((lla3lp5 >= llphaset)); then
((lp5phasen++))
fi
echo "$lp5phasen" > /var/www/html/openWB/ramdisk/lp5phasen
ladestatuslp5=$(</var/www/html/openWB/ramdisk/ladestatuslp5)
if ! [[ $ladeleistunglp5 =~ $re ]] ; then
openwbDebugLog "MAIN" 0 "ungültiger Wert für ladeleistunglp5: $ladeleistunglp5"
ladeleistunglp5="0"
fi
ladeleistung=$((ladeleistung + ladeleistunglp5))
else
ladeleistunglp5=0
fi
#sechster ladepunkt
if ((lastmanagementlp6 == 1)); then
if [[ "$evseconlp6" == "extopenwb" ]]; then
timeout 3 modules/extopenwb/main.sh 6 "$chargep6ip" "$chargep6cp" || true
else
timeout 3 modules/mpm3pmlllp6/main.sh || true
fi
llkwhlp6=$(</var/www/html/openWB/ramdisk/llkwhlp6)
llkwhges=$(echo "$llkwhges + $llkwhlp6" |bc)
llaltlp6=$(cat /var/www/html/openWB/ramdisk/llsolllp6)
ladeleistunglp6=$(cat /var/www/html/openWB/ramdisk/llaktuelllp6)
lla1lp6=$(cat /var/www/html/openWB/ramdisk/lla1lp6)
lla2lp6=$(cat /var/www/html/openWB/ramdisk/lla2lp6)
lla3lp6=$(cat /var/www/html/openWB/ramdisk/lla3lp6)
lla1lp6=${lla1lp6//.*/}
lla2lp6=${lla2lp6//.*/}
lla3lp6=${lla3lp6//.*/}
lp6phasen=0
if ((lla1lp6 >= llphaset)); then
((lp6phasen++))
fi
if ((lla2lp6 >= llphaset)); then
((lp6phasen++))
fi
if ((lla3lp6 >= llphaset)); then
((lp6phasen++))
fi
echo "$lp6phasen" > /var/www/html/openWB/ramdisk/lp6phasen
ladestatuslp6=$(</var/www/html/openWB/ramdisk/ladestatuslp6)
if ! [[ $ladeleistunglp6 =~ $re ]] ; then
openwbDebugLog "MAIN" 0 "ungültiger Wert für ladeleistunglp6: $ladeleistunglp6"
ladeleistunglp6="0"
fi
ladeleistung=$((ladeleistung + ladeleistunglp6))
else
ladeleistunglp6=0
fi
#siebter ladepunkt
if ((lastmanagementlp7 == 1)); then
if [[ "$evseconlp7" == "extopenwb" ]]; then
timeout 3 modules/extopenwb/main.sh 7 "$chargep7ip" "$chargep7cp" || true
else
timeout 3 modules/mpm3pmlllp7/main.sh || true
fi
llkwhlp7=$(</var/www/html/openWB/ramdisk/llkwhlp7)
llkwhges=$(echo "$llkwhges + $llkwhlp7" |bc)
llaltlp7=$(cat /var/www/html/openWB/ramdisk/llsolllp7)
ladeleistunglp7=$(cat /var/www/html/openWB/ramdisk/llaktuelllp7)
lla1lp7=$(cat /var/www/html/openWB/ramdisk/lla1lp7)
lla2lp7=$(cat /var/www/html/openWB/ramdisk/lla2lp7)
lla3lp7=$(cat /var/www/html/openWB/ramdisk/lla3lp7)
lla1lp7=${lla1lp7//.*/}
lla2lp7=${lla2lp7//.*/}
lla3lp7=${lla3lp7//.*/}
ladestatuslp7=$(</var/www/html/openWB/ramdisk/ladestatuslp7)
if ! [[ $ladeleistunglp7 =~ $re ]] ; then
openwbDebugLog "MAIN" 0 "ungültiger Wert für ladeleistunglp7: $ladeleistunglp7"
ladeleistunglp7="0"
fi
ladeleistung=$((ladeleistung + ladeleistunglp7))
lp7phasen=0
if ((lla1lp7 >= llphaset)); then
((lp7phasen++))
fi
if ((lla2lp7 >= llphaset)); then
((lp7phasen++))
fi
if ((lla3lp7 >= llphaset)); then
((lp7phasen++))
fi
echo "$lp7phasen" > /var/www/html/openWB/ramdisk/lp7phasen
else
ladeleistunglp7=0
fi
#achter ladepunkt
if ((lastmanagementlp8 == 1)); then
if [[ "$evseconlp8" == "extopenwb" ]]; then
timeout 3 modules/extopenwb/main.sh 8 "$chargep8ip" "$chargep8cp" || true
else
timeout 3 modules/mpm3pmlllp8/main.sh || true
fi
llkwhlp8=$(</var/www/html/openWB/ramdisk/llkwhlp8)
llkwhges=$(echo "$llkwhges + $llkwhlp8" |bc)
llaltlp8=$(cat /var/www/html/openWB/ramdisk/llsolllp8)
ladeleistunglp8=$(cat /var/www/html/openWB/ramdisk/llaktuelllp8)
lla1lp8=$(cat /var/www/html/openWB/ramdisk/lla1lp8)
lla2lp8=$(cat /var/www/html/openWB/ramdisk/lla2lp8)
lla3lp8=$(cat /var/www/html/openWB/ramdisk/lla3lp8)
lla1lp8=${lla1lp8//.*/}
lla2lp8=${lla2lp8//.*/}
lla3lp8=${lla3lp8//.*/}
lp8phasen=0
if ((lla1lp8 >= llphaset)); then
((lp8phasen++))
fi
if ((lla2lp8 >= llphaset)); then
((lp8phasen++))
fi
if ((lla3lp8 >= llphaset)); then
((lp8phasen++))
fi
echo "$lp8phasen" > /var/www/html/openWB/ramdisk/lp8phasen
ladestatuslp8=$(</var/www/html/openWB/ramdisk/ladestatuslp8)
if ! [[ $ladeleistunglp8 =~ $re ]] ; then
openwbDebugLog "MAIN" 0 "ungültiger Wert für ladeleistunglp8: $ladeleistunglp8"
ladeleistunglp8="0"
fi
ladeleistung=$((ladeleistung + ladeleistunglp8))
else
ladeleistunglp8=0
fi
echo "$ladeleistung" > /var/www/html/openWB/ramdisk/llkombiniert
echo "$llkwhges" > ramdisk/llkwhges
#Schuko-Steckdose an openWB
if ((standardSocketInstalled == 1)); then
timeout 10 modules/sdm120modbusSocket/main.sh || true
socketkwh=$(</var/www/html/openWB/ramdisk/socketkwh)
socketp=$(cat /var/www/html/openWB/ramdisk/socketp)
socketa=$(cat /var/www/html/openWB/ramdisk/socketa)
socketa=${socketa//.*/}
socketv=$(cat /var/www/html/openWB/ramdisk/socketv)
if ! [[ $socketa =~ $re ]] ; then
openwbDebugLog "MAIN" 0 "ungültiger Wert für socketa: $socketa"
socketa="0"
fi
fi
#Wattbezug
if [[ $wattbezugmodul != "none" ]]; then
wattbezug=$("modules/$wattbezugmodul/main.sh" || true)
if ! [[ $wattbezug =~ $re ]] ; then
openwbDebugLog "MAIN" 0 "ungültiger Wert für wattbezug: $wattbezug"
wattbezug="0"
fi
wattbezugint=$(printf "%.0f\n" $wattbezug)
#evu glaettung
if ((evuglaettungakt == 1)); then
if ((evuglaettung > 20)); then
ganzahl=$((evuglaettung / 10))
for ((i=ganzahl;i>=1;i--)); do
i2=$((i + 1))
cp "ramdisk/glaettung$i" "ramdisk/glaettung$i2"
done
echo "$wattbezug" > ramdisk/glaettung1
for ((i=1;i<=ganzahl;i++)); do
glaettung=$(<"ramdisk/glaettung$i")
glaettungw=$((glaettung + glaettungw))
done
glaettungfinal=$((glaettungw / ganzahl))
echo "$glaettungfinal" > ramdisk/glattwattbezug
wattbezug=$glaettungfinal
fi
fi
#uberschuss zur berechnung
uberschuss=$(printf "%.0f\n" $((-wattbezug)))
if ((speichervorhanden == 1)); then
if ((speicherpveinbeziehen == 1)); then
if ((speicherleistung > 0)); then
if ((speichersoc > speichersocnurpv)); then
speicherww=$((speicherleistung + speicherwattnurpv))
uberschuss=$((uberschuss + speicherww))
else
speicherww=$((speicherleistung - speichermaxwatt))
uberschuss=$((uberschuss + speicherww))
fi
fi
fi
fi
evua1=$(cat /var/www/html/openWB/ramdisk/bezuga1)
evua2=$(cat /var/www/html/openWB/ramdisk/bezuga2)
evua3=$(cat /var/www/html/openWB/ramdisk/bezuga3)
evua1=${evua1//.*/}
evua2=${evua2//.*/}
evua3=${evua3//.*/}
if ! [[ $evua1 =~ $re ]]; then
openwbDebugLog "MAIN" 0 "ungültiger Wert für evua1: $evua1"
evua1="0"
fi
if ! [[ $evua2 =~ $re ]]; then
openwbDebugLog "MAIN" 0 "ungültiger Wert für evua2: $evua2"
evua2="0"
fi
if ! [[ $evua3 =~ $re ]]; then
openwbDebugLog "MAIN" 0 "ungültiger Wert für evua3: $evua3"
evua3="0"
fi
evuas=("$evua1" "$evua2" "$evua3")
maxevu=${evuas[0]}
lowevu=${evuas[0]}
for v in "${evuas[@]}"; do
if ((v < lowevu)); then lowevu=$v; fi;
if ((v > maxevu)); then maxevu=$v; fi;
done
schieflast=$((maxevu - lowevu))
echo $schieflast > /var/www/html/openWB/ramdisk/schieflast
else
uberschuss=$((-pvwatt - hausbezugnone - ladeleistung))
echo $((-uberschuss)) > /var/www/html/openWB/ramdisk/wattbezug
wattbezugint=$((-uberschuss))
wattbezug=$wattbezugint
fi
# Abschaltbare Smartdevices zum Ueberschuss rechnen