forked from snaptec/openWB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
loadvars.sh
executable file
·1771 lines (1693 loc) · 72.7 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
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)
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" -ge "0" ] && [ "$evseplugstate" -le "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" -gt "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
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
if [[ $pvwattmodul != "none" ]]; then
pv1vorhanden="1"
echo 1 > /var/www/html/openWB/ramdisk/pv1vorhanden
pvwatt=$(modules/$pvwattmodul/main.sh || true)
if ! [[ $pvwatt =~ $re ]] ; then
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)
echo $pv2watt > ramdisk/pv2watt
pvwatt=$(( pvwatt + pv2watt ))
pvkwh=$(</var/www/html/openWB/ramdisk/pvkwh)
pv2kwh=$(</var/www/html/openWB/ramdisk/pv2kwh)
pvallwh=$(echo "$pvkwh + $pv2kwh" |bc)
#echo $pvallkwh > /var/www/html/openWB/ramdisk/pvkwh
echo $pvallwh > /var/www/html/openWB/ramdisk/pvallwh
echo $pvwatt > /var/www/html/openWB/ramdisk/pvallwatt
if ! [[ $pvwatt =~ $re ]] ; then
pvwatt="0"
fi
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 || true
speicherleistung=$(</var/www/html/openWB/ramdisk/speicherleistung)
speicherleistung=$(echo $speicherleistung | sed 's/\..*$//')
speichersoc=$(</var/www/html/openWB/ramdisk/speichersoc)
speichersoc=$(echo $speichersoc | sed 's/\..*$//')
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"
fi
if [[ $speichermodul == "speicher_sonneneco" ]] ; then
pvwatt=$(</var/www/html/openWB/ramdisk/pvwatt)
echo 1 > /var/www/html/openWB/ramdisk/pv1vorhanden
pv1vorhanden="1"
fi
else
speichervorhanden="0"
echo 0 > /var/www/html/openWB/ramdisk/speichervorhanden
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=$(echo $lla1 | sed 's/\..*$//')
lla2=$(echo $lla2 | sed 's/\..*$//')
lla3=$(echo $lla3 | sed 's/\..*$//')
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
lla1="0"
fi
if ! [[ $lla2 =~ $re ]] ; then
lla2="0"
fi
if ! [[ $lla3 =~ $re ]] ; then
lla3="0"
fi
lp1phasen=0
if [ $lla1 -ge $llphaset ]; then
lp1phasen=$((lp1phasen + 1 ))
fi
if [ $lla2 -ge $llphaset ]; then
lp1phasen=$((lp1phasen + 1 ))
fi
if [ $lla3 -ge $llphaset ]; then
lp1phasen=$((lp1phasen + 1 ))
fi
echo $lp1phasen > /var/www/html/openWB/ramdisk/lp1phasen
if ! [[ $ladeleistung =~ $re ]] ; then
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
modules/$socmodul1/main.sh &
soc1=$(</var/www/html/openWB/ramdisk/soc1)
tmpsoc1=$(</var/www/html/openWB/ramdisk/tmpsoc1)
if ! [[ $soc1 =~ $re ]] ; then
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=$(echo $llas11 | sed 's/\..*$//')
llas12=$(echo $llas12 | sed 's/\..*$//')
llas13=$(echo $llas13 | sed 's/\..*$//')
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 -ge $llphaset ]; then
lp2phasen=$((lp2phasen + 1 ))
fi
if [ $llas12 -ge $llphaset ]; then
lp2phasen=$((lp2phasen + 1 ))
fi
if [ $llas13 -ge $llphaset ]; then
lp2phasen=$((lp2phasen + 1 ))
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=$(echo $llas21 | sed 's/\..*$//')
llas22=$(echo $llas22 | sed 's/\..*$//')
llas23=$(echo $llas23 | sed 's/\..*$//')
lp3phasen=0
if [ $llas21 -ge $llphaset ]; then
lp3phasen=$((lp3phasen + 1 ))
fi
if [ $llas22 -ge $llphaset ]; then
lp3phasen=$((lp3phasen + 1 ))
fi
if [ $llas23 -ge $llphaset ]; then
lp3phasen=$((lp3phasen + 1 ))
fi
echo $lp3phasen > /var/www/html/openWB/ramdisk/lp3phasen
ladestatuss2=$(</var/www/html/openWB/ramdisk/ladestatuss2)
if ! [[ $ladeleistungs2 =~ $re ]] ; then
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=$(echo $lla1lp4 | sed 's/\..*$//')
lla2lp4=$(echo $lla2lp4 | sed 's/\..*$//')
lla3lp4=$(echo $lla3lp4 | sed 's/\..*$//')
lp4phasen=0
if [ $lla1lp4 -ge $llphaset ]; then
lp4phasen=$((lp4phasen + 1 ))
fi
if [ $lla2lp4 -ge $llphaset ]; then
lp4phasen=$((lp4phasen + 1 ))
fi
if [ $lla3lp4 -ge $llphaset ]; then
lp4phasen=$((lp4phasen + 1 ))
fi
echo $lp4phasen > /var/www/html/openWB/ramdisk/lp4phasen
ladestatuslp4=$(</var/www/html/openWB/ramdisk/ladestatuslp4)
if ! [[ $ladeleistunglp4 =~ $re ]] ; then
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=$(echo $lla1lp5 | sed 's/\..*$//')
lla2lp5=$(echo $lla2lp5 | sed 's/\..*$//')
lla3lp5=$(echo $lla3lp5 | sed 's/\..*$//')
lp5phasen=0
if [ $lla1lp5 -ge $llphaset ]; then
lp5phasen=$((lp5phasen + 1 ))
fi
if [ $lla2lp5 -ge $llphaset ]; then
lp5phasen=$((lp5phasen + 1 ))
fi
if [ $lla3lp5 -ge $llphaset ]; then
lp5phasen=$((lp5phasen + 1 ))
fi
echo $lp5phasen > /var/www/html/openWB/ramdisk/lp5phasen
ladestatuslp5=$(</var/www/html/openWB/ramdisk/ladestatuslp5)
if ! [[ $ladeleistunglp5 =~ $re ]] ; then
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=$(echo $lla1lp6 | sed 's/\..*$//')
lla2lp6=$(echo $lla2lp6 | sed 's/\..*$//')
lla3lp6=$(echo $lla3lp6 | sed 's/\..*$//')
lp6phasen=0
if [ $lla1lp6 -ge $llphaset ]; then
lp6phasen=$((lp6phasen + 1 ))
fi
if [ $lla2lp6 -ge $llphaset ]; then
lp6phasen=$((lp6phasen + 1 ))
fi
if [ $lla3lp6 -ge $llphaset ]; then
lp6phasen=$((lp6phasen + 1 ))
fi
echo $lp6phasen > /var/www/html/openWB/ramdisk/lp6phasen
ladestatuslp6=$(</var/www/html/openWB/ramdisk/ladestatuslp6)
if ! [[ $ladeleistunglp6 =~ $re ]] ; then
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=$(echo $lla1lp7 | sed 's/\..*$//')
lla2lp7=$(echo $lla2lp7 | sed 's/\..*$//')
lla3lp7=$(echo $lla3lp7 | sed 's/\..*$//')
ladestatuslp7=$(</var/www/html/openWB/ramdisk/ladestatuslp7)
if ! [[ $ladeleistunglp7 =~ $re ]] ; then
ladeleistunglp7="0"
fi
ladeleistung=$(( ladeleistung + ladeleistunglp7 ))
lp7phasen=0
if [ $lla1lp7 -ge $llphaset ]; then
lp7phasen=$((lp7phasen + 1 ))
fi
if [ $lla2lp7 -ge $llphaset ]; then
lp7phasen=$((lp7phasen + 1 ))
fi
if [ $lla3lp7 -ge $llphaset ]; then
lp7phasen=$((lp7phasen + 1 ))
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=$(echo $lla1lp8 | sed 's/\..*$//')
lla2lp8=$(echo $lla2lp8 | sed 's/\..*$//')
lla3lp8=$(echo $lla3lp8 | sed 's/\..*$//')
lp8phasen=0
if [ $lla1lp8 -ge $llphaset ]; then
lp8phasen=$((lp8phasen + 1 ))
fi
if [ $lla2lp8 -ge $llphaset ]; then
lp8phasen=$((lp8phasen + 1 ))
fi
if [ $lla3lp8 -ge $llphaset ]; then
lp8phasen=$((lp8phasen + 1 ))
fi
echo $lp8phasen > /var/www/html/openWB/ramdisk/lp8phasen
ladestatuslp8=$(</var/www/html/openWB/ramdisk/ladestatuslp8)
if ! [[ $ladeleistunglp8 =~ $re ]] ; then
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=$(echo $socketa | sed 's/\..*$//')
socketv=$(cat /var/www/html/openWB/ramdisk/socketv)
if ! [[ $socketa =~ $re ]] ; then
socketa="0"
fi
fi
#Wattbezug
if [[ $wattbezugmodul != "none" ]]; then
wattbezug=$(modules/$wattbezugmodul/main.sh || true)
if ! [[ $wattbezug =~ $re ]] ; then
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=$(echo $evua1 | sed 's/\..*$//')
evua2=$(echo $evua2 | sed 's/\..*$//')
evua3=$(echo $evua3 | sed 's/\..*$//')
[[ $evua1 =~ $re ]] || evua1="0"
[[ $evua2 =~ $re ]] || evua2="0"
[[ $evua3 =~ $re ]] || evua3="0"
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
echo $uberschuss > /var/www/html/openWB/ramdisk/ueberschuss_org
wattabs=$(cat /var/www/html/openWB/ramdisk/devicetotal_watt)
uberschuss=$((uberschuss + wattabs))
echo $uberschuss > /var/www/html/openWB/ramdisk/ueberschuss_mitsmart
#Soc ermitteln
if [[ $socmodul != "none" ]]; then
socvorhanden=1
echo 1 > /var/www/html/openWB/ramdisk/socvorhanden
if (( stopsocnotpluggedlp1 == 1 )); then
soctimer=$(</var/www/html/openWB/ramdisk/soctimer)
# if (( plugstat == 1 )); then
if [ $plugstat -eq 1 -o $soctimer -eq 20005 ]; then # force soc update button sends 20005
modules/$socmodul/main.sh &
soc=$(</var/www/html/openWB/ramdisk/soc)
tmpsoc=$(</var/www/html/openWB/ramdisk/tmpsoc)
if ! [[ $soc =~ $re ]] ; then
soc=$tmpsoc
else
echo $soc > /var/www/html/openWB/ramdisk/tmpsoc
fi
else
echo 600 > /var/www/html/openWB/ramdisk/soctimer
soc=$(</var/www/html/openWB/ramdisk/soc)
fi
else
modules/$socmodul/main.sh &
soc=$(</var/www/html/openWB/ramdisk/soc)
tmpsoc=$(</var/www/html/openWB/ramdisk/tmpsoc)
if ! [[ $soc =~ $re ]] ; then
soc=$tmpsoc
else
echo $soc > /var/www/html/openWB/ramdisk/tmpsoc
fi
fi
else
socvorhanden=0
echo 0 > /var/www/html/openWB/ramdisk/socvorhanden
soc=0
fi
if [ -s "ramdisk/device1_watt" ]; then shd1_w=$(<ramdisk/device1_watt); else shd1_w=0; fi
if [ -s "ramdisk/device2_watt" ]; then shd2_w=$(<ramdisk/device2_watt); else shd2_w=0; fi
if [ -s "ramdisk/device3_watt" ]; then shd3_w=$(<ramdisk/device3_watt); else shd3_w=0; fi
if [ -s "ramdisk/device4_watt" ]; then shd4_w=$(<ramdisk/device4_watt); else shd4_w=0; fi
if [ -s "ramdisk/device5_watt" ]; then shd5_w=$(<ramdisk/device5_watt); else shd5_w=0; fi
if [ -s "ramdisk/device6_watt" ]; then shd6_w=$(<ramdisk/device6_watt); else shd6_w=0; fi
if [ -s "ramdisk/device7_watt" ]; then shd7_w=$(<ramdisk/device7_watt); else shd7_w=0; fi
if [ -s "ramdisk/device8_watt" ]; then shd8_w=$(<ramdisk/device8_watt); else shd8_w=0; fi
if [ -s "ramdisk/device9_watt" ]; then shd9_w=$(<ramdisk/device9_watt); else shd9_w=0; fi
if [ -s "ramdisk/devicetotal_watt_hausmin" ]; then shdall_w=$(<ramdisk/devicetotal_watt_hausmin); else shdall_w=0; fi
if [ -s "ramdisk/device1_temp0" ]; then shd1_t0=$(<ramdisk/device1_temp0); else shd1_t0=0; fi
if [ -s "ramdisk/device1_temp1" ]; then shd1_t1=$(<ramdisk/device1_temp1); else shd1_t1=0; fi
if [ -s "ramdisk/device1_temp2" ]; then shd1_t2=$(<ramdisk/device1_temp2); else shd1_t2=0; fi
if [ -s "ramdisk/verbraucher1_watt" ]; then verb1_w=$(<ramdisk/verbraucher1_watt); else verb1_w=0; fi
verb1_w=$(printf "%.0f\n" $verb1_w)
if [ -s "ramdisk/verbraucher2_watt" ]; then verb2_w=$(<ramdisk/verbraucher2_watt); else verb2_w=0; fi
verb2_w=$(printf "%.0f\n" $verb2_w)
if [ -s "ramdisk/verbraucher3_watt" ]; then verb3_w=$(<ramdisk/verbraucher3_watt); else verb3_w=0; fi
verb3_w=$(printf "%.0f\n" $verb3_w)
#hausverbrauch=$((wattbezugint - pvwatt - ladeleistung - speicherleistung - shd1_w - shd2_w - shd3_w - shd4_w - shd5_w - shd6_w - shd7_w - shd8_w - shd9_w - verb1_w - verb2_w - verb3_w))
hausverbrauch=$((wattbezugint - pvwatt - ladeleistung - speicherleistung - shdall_w - verb1_w - verb2_w - verb3_w))
if (( hausverbrauch < 0 )); then
if [ -f /var/www/html/openWB/ramdisk/hausverbrauch.invalid ]; then
hausverbrauchinvalid=$(</var/www/html/openWB/ramdisk/hausverbrauch.invalid)
let hausverbrauchinvalid+=1
else
hausverbrauchinvalid=1
fi
echo "$hausverbrauchinvalid" > /var/www/html/openWB/ramdisk/hausverbrauch.invalid
if (( hausverbrauchinvalid < 3 )); then
hausverbrauch=$(</var/www/html/openWB/ramdisk/hausverbrauch)
else
hausverbrauch=0
fi
else
echo "0" > /var/www/html/openWB/ramdisk/hausverbrauch.invalid
fi
echo $hausverbrauch > /var/www/html/openWB/ramdisk/hausverbrauch
fronius_sm_bezug_meterlocation=$(</var/www/html/openWB/ramdisk/fronius_sm_bezug_meterlocation)
usesimbezug=0
if [[ $wattbezugmodul == "bezug_e3dc" ]] || [[ $wattbezugmodul == "bezug_carlogavazzilan" ]]|| [[ $wattbezugmodul == "bezug_siemens" ]] || [[ $wattbezugmodul == "bezug_solarwatt" ]]|| [[ $wattbezugmodul == "bezug_rct" ]]|| [[ $wattbezugmodul == "bezug_sungrow" ]] || [[ $wattbezugmodul == "bezug_powerdog" ]] || [[ $wattbezugmodul == "bezug_varta" ]] || [[ $wattbezugmodul == "bezug_lgessv1" ]] || [[ $wattbezugmodul == "bezug_kostalpiko" ]] || [[ $wattbezugmodul == "bezug_kostalplenticoreem300haus" ]] || [[ $wattbezugmodul == "bezug_sbs25" ]] || [[ $wattbezugmodul == "bezug_solarlog" ]] || [[ $wattbezugmodul == "bezug_sonneneco" ]] || [[ $fronius_sm_bezug_meterlocation == "1" ]]; then
usesimbezug=1
fi
if [[ $wattbezugmodul == "bezug_ethmpm3pm" ]] && [[ $evukitversion == "1" ]]; then
usesimbezug=1
fi
if [[ $wattbezugmodul == "bezug_ethmpm3pm" ]] && [[ $evukitversion == "2" ]]; then
usesimbezug=1
fi