File size: 26,702 Bytes
6d776bd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1a02e7a
6d776bd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import sqlite3
import pandas as pd
import base64
import plotly.graph_objects as go
from datetime import datetime
import base64
import io
import dash
from dash import dcc, html
from dash.dependencies import Input, Output, State
from dash import dash_table
# import sqlite3
# import pandas as pd
import re
import dash_bootstrap_components as dbc
#import dash_html_components as html
import plotly.graph_objects as go

## taken from LG240416
full_r1="v7.6;XT-Ubat- (MIN) [Vdc];;XT-Uin [Vac];;XT-Iin [Aac];;XT-Pout [kVA];;XT-Pout+ [kVA];;XT-Fout [Hz];;XT-Fin [Hz];;XT-Phase [];;XT-Mode [];;XT-Transfert [];;XT-E CMD [];;XT-Aux 1 [];;XT-Aux 2 [];;XT-Ubat [Vdc];;XT-Ibat [Adc];;XT-Pin a [kW];;XT-Pout a [kW];;XT-Tp1+ (MAX) [°C];;VT-PsoM [kW];;VT-Mode [];VT-Tp1M [°C];VT-UpvM [Vdc];VT-IbaM [Adc];VT-UbaM [Vdc];VT-Phase [];VT-E CMD [];VT-Aux 1 [];VT-Aux 2 [];BSP-Ubat [Vdc];BSP-Ibat [Adc];BSP-SOC [%];BSP-Tbat [°C];Solar power (ALL) [kW];DEV XT-DBG1 [];DEV VT-locEr [];DEV SYS MSG;DEV SYS SCOM ERR;"
full_r2=";I3090;I3090;I3113;I3113;I3116;I3116;I3098;I3098;I3097;I3097;I3110;I3110;I3122;I3122;I3010;I3010;I3028;I3028;I3020;I3020;I3086;I3086;I3054;I3054;I3055;I3055;I3092;I3092;I3095;I3095;I3119;I3119;I3101;I3101;I3103;I3103;I11043;I11043;I11016;I11045;I11041;I11040;I11039;I11038;I11082;I11061;I11062;I7030;I7031;I7032;I7033;I17999;I3140;I11076;I17997;I17998;"
full_r3=";L1;L2;L1;L2;L1;L2;L1;L2;L1;L2;L1;L2;L1;L2;L1;L2;L1;L2;L1;L2;L1;L2;L1;L2;L1;L2;L1-1;L2-2;L1-1;L2-2;L1-1;L2-2;L1-1;L2-2;L1-1;L2-2;1;ALL;1;1;1;1;1;1;1;1;1;1;1;1;1;ALL;1;1;1;1;"


FONT_AWESOME = "https://use.fontawesome.com/releases/v5.10.2/css/all.css"

card_icon = {
    "color": "white",
    "textAlign": "center",
    "fontSize": 30,
    "margin": "auto",
}

nHeaderSkip = 3
csvSep = ";"

db_file = 'data/akonolinga_database_v3_demo.db'
dbTime_name = "time_data"
dbDayP_name = "dayP_data"
dbDayI_name = "dayI_data"

db_timecol = "time"
db_daycol = "day"

enc = "latin_1"
#nColsTime = 46
nRowsDayP = 10
nColsDayP = 4
nRowsDayI = 13
nColsDayI = 3

# tab-2
maxTimePlotVar = 4
timePlotLineCols=['blue', 'red', 'green', 'orange']  # 'purple']

popupmsg_maxvar = "Vous ne pouvez pas sélectionner plus de " + str(maxTimePlotVar) +" variables."

# Les 2 sources peuvent être disciminée par leurs valeur: Le réseau à une fréquence très stable
# <49,5Hz-50,5Hz>. La generatrice est moin stable est a une fréquence généralement supérieure a 51Hz.
# Une valeur nule indique l''absence de la source réseau/génératrice
xtfin_genThresh = 51
xtfin_nosource = 0
xtfincol = "XT_Fin_Hz_I3122"

xtpuicol = "XT_Pout_a_kW_I3101"
xtpuicol_L1 = xtpuicol + "_L1_1"
xtpuicol_L2 = xtpuicol + "_L2_2"

# température moyenne de la batterie I7033
tempTbatcol = "BSP_Tbat_C_I7033_1"
# tensUbatcol = "BSP_Ubat_Vdc_I7030_1"
# ctIbatcol = "BSP_Ibat_Adc_I7031_1"

# Phase de charge de batterie.Dan ce système seule 3 phase devraient apparaitre:
# Charge de masse,(1 rouge), Absorbtion, (2 orange), et Mintient (4 Jaune)
xtphase_cols ={'1':['Charge de masse', 'red'],
                    '2':['Absorption', 'orange'],
                    '4':['Maintien', 'yellow']
               }

prodsol_dayIcol = 'I11007'
bilanEntree_dayIcol = 'I3081'
bilanSortie_dayIcol = 'I3083'
ahCharge_dayIcol = "I7007"
ahDecharge_dayIcol = "I7008"
dayStat_cols = [prodsol_dayIcol,
                                  bilanEntree_dayIcol,
                                  bilanSortie_dayIcol,
                                  ahCharge_dayIcol,
                                  ahDecharge_dayIcol]

time_txt_cols = [db_timecol]
time_real_cols =  ["XT_Ubat_MIN_Vdc_I3090_L1",
"XT_Ubat_MIN_Vdc_I3090_L2",
"XT_Uin_Vac_I3113_L1",
"XT_Uin_Vac_I3113_L2",
"XT_Iin_Aac_I3116_L1",
"XT_Iin_Aac_I3116_L2",
"XT_Pout_kVA_I3098_L1",
"XT_Pout_kVA_I3098_L2",
"XT_Pout_kVA_I3097_L1",
"XT_Pout_kVA_I3097_L2",
"XT_Fout_Hz_I3110_L1",
"XT_Fout_Hz_I3110_L2",
"XT_Fin_Hz_I3122_L1",
"XT_Fin_Hz_I3122_L2",
"XT_Phase_I3010_L1",
"XT_Phase_I3010_L2",
"XT_Mode_I3028_L1",
"XT_Mode_I3028_L2",
"XT_Transfert_I3020_L1",
"XT_Transfert_I3020_L2",
"XT_E_CMD_I3086_L1",
"XT_E_CMD_I3086_L2",
"XT_Aux_1_I3054_L1",
"XT_Aux_1_I3054_L2",
"XT_Aux_2_I3055_L1",
"XT_Aux_2_I3055_L2",
"XT_Ubat_Vdc_I3092_L1_1",
"XT_Ubat_Vdc_I3092_L2_2",
"XT_Ibat_Adc_I3095_L1_1",
"XT_Ibat_Adc_I3095_L2_2",
"XT_Pin_a_kW_I3119_L1_1",
"XT_Pin_a_kW_I3119_L2_2",
"XT_Pout_a_kW_I3101_L1_1",
"XT_Pout_a_kW_I3101_L2_2",
"XT_Tp1_MAX_C_I3103_L1_1",
"XT_Tp1_MAX_C_I3103_L2_2",
"VT_PsoM_kW_I11043_1",	 ### ajout VT
"VT_PsoM_kW_I11043_ALL",
"VT_Mode_I11016_1",
"VT_Tp1M_C_I11045_1",
"VT_UpvM_Vdc_I11041_1",
"VT_IbaM_Adc_I11040_1",
"VT_UbaM_Vdc_I11039_1", 
"VT_Phase_I11038_1",
"VT_E_CMD_I11082_1",
"VT_Aux_1_I11061_1",
"VT_Aux_2_I11062_1",  
"BSP_Ubat_Vdc_I7030_1",
"BSP_Ibat_Adc_I7031_1",
"BSP_SOC_I7032_1",
"BSP_Tbat_C_I7033_1",
"Solar_power_ALL_kW_I17999_ALL",
"DEV_XT_DBG1_I3140_1",
"DEV_BSP_locE_I7059_1",
"DEV_VT_locEr_I11076_1",              
"DEV_SYS_MSG_I17997_1",
"DEV_SYS_SCOM_ERR_I17998_1"]

time_added_cols = [col.replace('_L1', '_L1_L2') for col in time_real_cols
    if col.endswith('_L1') and col.replace('_L1', '_L2') in time_real_cols
                   and not col.replace('_L1', '_L1_L2')  in time_real_cols]


## somme de colonnes ajoutées par calcul
# time_added_cols = ["XT_Iin_Aac_I3116_tot",
#                    "XT_Pin_a_kW_I3119_tot",
#                    "XT_Pout_a_kW_I3101_tot"]


day_txt_cols = [db_daycol]
# dayP_real_cols =  ['P1107', 'P1567', 'P1138', 'P1108', 'P1140', 'P1155', 'P1156', 'P1163',
#        'P1164', 'P6001']
dayP_cols =  ['P1107', 'P1567', 'P1138', 'P1108', 'P1140', 'P1155', 'P1156', 'P1163',
       'P1164', 'P6001']
dayP_real_cols = ([x + "_1" for x in dayP_cols] +
                  [x + "_2" for x in dayP_cols] +
                  [x + "_3" for x in dayP_cols])
dayI_cols = ['I3081', 'I3083', 'I7007', 'I7008', 'I11006', 'I11007', 'I15016',
       'I15017', 'I7053', 'I7054', 'I7055', 'I7056', 'I7067']
dayI_real_cols = ([x + "_1" for x in dayI_cols] +
                  [x + "_2" for x in dayI_cols])

#assert nColsTime == len(time_txt_cols) + len(time_real_cols)

showcols_settings = {
    "XT_Ubat_MIN_Vdc_I3090_L1": {
        "lab" : "XT Ubat MIN L1 [Vdc]",
        "description": "tension de la batterie (battery voltage (minute min))", ### PAS TROUVE !!!
        "unit" : "Vdc",
        "scale": "",
        "step":""
    },
    "XT_Uin_Vac_I3113_L1": { ### PAS TROUVE !!!
        "lab" : "XT Uin L1 [Vac]",
        "description": "tension d'entrée ou du réseau public ou de la génératrice (input voltage (minute avg))",
        "unit": "Vac",
        "scale": "190-250V",
        "step":""
    },
    "XT_Iin_Aac_I3116_L1": {
        "lab" : "XT Iin L1 [Aac]",
        "description": "courant d'entrée de XTS (input current (minute avg))",
        "unit": "Aac",
        "scale": "auto" ,
        "step":"1A"
    },
    # "XT_Iin_Aac_I3116_tot": { ### PAS TROUVE !!!
    #     "lab" : "XT Iin L1+L2 [Aac]",
    #     "description": "somme Iin I3116 L1+L2 [calculated)",
    #     "unit": "Aac",
    #     "scale": "auto",
    #     "step": "1A"
    # },
    "XT_Pout_kVA_I3098_L1": {
        "lab" : "XT Pout L1 [kVA]",
        "description": "puissance de sortie (output power (minute avg))",
        "unit": "kVA",
        "scale": "auto",
        "step": "100W"
    },
    "XT_Pout_kVA_I3097_L1": {
        "lab" : "XT Pout L1 [kVA]",
        "description": "puissance de sortie+ (output power+ (minute max))",
        "unit": "kVA",
        "scale": "auto",
        "step": "100W"
    },
# Output frequency (minute avg)  (HZ)
    "XT_Fout_Hz_I3110_L1":  {
        "lab" : "XT Fout L1 [Hz]",
        "description": "",
        "unit": "Hz",
        "scale": "",
        "step": ""
    },
    "XT_Fout_Hz_I3110_L2": {
        "lab" : "XT Fout L2 [Hz]",
        "description": "",
        "unit": "Hz",
        "scale": "",
        "step": ""
    },
    "XT_Fin_Hz_I3122_L1": {
        "lab" : "XT Fin L1 [Hz]",
        "description": "fréquence du réseau (stable, < 51 Hz) ou de la génératrice (moins stable, > 51 Hz) (input frequency (minute avg))",
        "unit": "Hz",
        "scale": "45-55",
        "step": ""
    },
# Phase de charge de batterie (----,
    # Ch.masse, Absorpt., Egalise, Maintien, Maint.ré, Abs.pér.,
    # Brassage, Formage) (3010) # Battery cycle phase
#0:Invalid value,1:Bulk,2:Absorpt.,3:Equalise, 4:Floating,5:R.float.,6:Per.abs.,7:Mixing,8:Forming
    "XT_Phase_I3010_L1": {
        "lab" : "XT Phase L1 [enum]",
        "description": "phase de charge de batterie (battery cycle phase) (1/rouge : charge de masse, 2/orange : absorbtion, 4/jaune : maintien)",
        "unit": "CAT",
        "scale": "1-4",
        "step": "1"
    },
# Mode de fonctionnement (----, Onduleur, Chargeur, Boost, Injection) (3028)
    # Operating state
    # give current working mode of the inverter
#0:Invalid value,1:Inverter,2:Charger,3:Boost,4:Injection
    "XT_Mode_I3028_L1" :{
        "lab" : "XT Mode L1 [enum]",
        "description": "current working mode of the inverter (0=invalid, 1=inverter, 2=charger, 3=boost, 4=injection)",
        "unit": "CAT",
        "scale": "1-4",
        "step": "1"
    },
    "XT_Mode_I3028_L2" : {
        "lab" : "XT Mode L2 [enum]",
        "description": "current working mode of the inverter (0=invalid, 1=inverter, 2=charger, 3=boost, 4=injection)",
        "unit": "CAT",
        "scale": "1-4",
        "step": "1"
    },
    "XT_Transfert_I3020_L1": {
#Etat du relais de transfert (Ouvert, Fermé) (3020)
        # State of transfer relay
        "lab": "XT Transfert L1 [bool]",
        "description": "présence du réseau sur les entrées (0=absent, 1=présent) (state of transfer relay (0: opened, 1:closed))",
        "unit": "CAT",
        "scale": "0-1",
        "step": "1"
    },
#Etat de l'entree de commande (E CMD 0, E CMD 1)(3086)
    # Remote entry state 0:RM EN 0 -     # 1:RM EN 1
    "XT_E_CMD_I3086_L1" : {
#Etat du relais de transfert (Ouvert, Fermé) (3020)
        # State of transfer relay
        "lab": "XT E CMD L1 [bool]",
        "description": "présence du réseau sur les entrées (0=absent, 1=présent) (state of transfer relay (0: opened, 1:closed))",
        "unit": "CAT",
        "scale": "0-1",
        "step": "1"
    },
#Etat de l'entree de commande (E CMD 0, E CMD 1)(3086)
    "XT_E_CMD_I3086_L2" :{
#Etat du relais de transfert (Ouvert, Fermé) (3020)
        # State of transfer relay
        "lab": "XT E CMD L2[bool]",
        "description": "présence du réseau sur les entrées (0=absent, 1=présent) (state of transfer relay (0: opened, 1:closed))",
        "unit": "CAT",
        "scale": "0-1",
        "step": "1"
    },
#Mode relais auxiliaire 1 (----, A, I, M, M, G) (3054)
# Relay aux 1 mode 0:Invalid value,1:A, 2:I ,3:M,4:M,5:G
    "XT_Aux_1_I3054_L1" : {
#Etat du relais de transfert (Ouvert, Fermé) (3020)
        # State of transfer relay
        "lab": "XT Aux 1 L1 [enum]",
        "description": "mode relais auxiliaire (0=absent, 1=A, 2=I, 3=M, 4=M, 5=G)",
        "unit": "CAT",
        "scale": "0-1",
        "step": "1"
    },
    # Mode relais auxiliaire 1 (----, A, I, M, M, G) (3054)
    "XT_Aux_1_I3054_L2" : {
#Etat du relais de transfert (Ouvert, Fermé) (3020)
        # State of transfer relay
        "lab": "XT Aux 1 L2 [enum]",
        "description": "mode relais auxiliaire (0=absent, 1=A, 2=I, 3=M, 4=M, 5=G)",
        "unit": "CAT",
        "scale": "0-1",
        "step": "1"
    },
    # Mode relais auxiliaire 2 (----, A, I, M, M, G) (3055)
    # Relay aux 2 mode 0:Invalid value,1:A, 2:I ,3:M,4:M,5:G
    "XT_Aux_2_I3055_L1" : {
#Etat du relais de transfert (Ouvert, Fermé) (3020)
        # State of transfer relay
        "lab": "XT Aux 2 L1 [enum]",
        "description": "mode relais auxiliaire (0=absent, 1=A, 2=I, 3=M, 4=M, 5=G)",
        "unit": "CAT",
        "scale": "0-1",
        "step": "1"
    },
    "XT_Aux_2_I3055_L2" : {
#Etat du relais de transfert (Ouvert, Fermé) (3020)
        # State of transfer relay
        "lab": "XT Aux 2 L2 [enum]",
        "description": "mode relais auxiliaire (0=absent, 1=A, 2=I, 3=M, 4=M, 5=G)",
        "unit": "CAT",
        "scale": "0-1",
        "step": "1"
    },
### Battery voltage (minute avg) (Adc)
    "XT_Ubat_Vdc_I3092_L1_1" : {
        "lab" : "XT Ubat L1 [Vdc]",
        'description' : 'Battery voltage (minute avg)',
        "unit" : "Adc"},
    "XT_Ubat_Vdc_I3092_L2_2" : {
        'lab':"XT Ubat L2 [Vdc]",
            'description' : 'Battery voltage (minute avg)',
                                "unit" : "Adc"},
### Battery charge current (minute avg)  (Adc)
    "XT_Ibat_Adc_I3095_L1_1" : {
        "lab" : "XT Ibat L1 [Adc]",
        'description' : 'Battery charge current (minute avg)',
        "unit" : "Adc"},
    "XT_Ibat_Adc_I3095_L2_2" : {
        "lab" : "XT Ibat L2 [Adc]",
            'description' : 'Battery charge current (minute avg)',
                                "unit" : "Adc"},
    "XT_Pin_a_kW_I3119_L1_1": { ### PAS TROUVé
        "lab" : "XT Pin L1 [kW]",
        "description": "puissance tirée du réseau (>0) ou injectée sur le réseau (<0)  (input active power (minute avg))",
        "unit": "kW",
        "scale": "",
        "step": ""
    },
    # "XT_Pin_a_kW_I3119_tot": {
    #     "lab": "XT Pin L1+L2 [kW]",
    #     "description": "somme Pin I3119 L1+L2 (calculated)",
    #     "unit": "kW",
    #     "scale": "auto",
    #     "step": "0.01"
    # },
    "XT_Pout_a_kW_I3101_L1_1": {
        "lab" : "XT Pout L1 [kW]",
        "description": "puissance de sortie des circuits secourus (output active power (minute avg))",
        "unit": "kW",
        "scale": "",
        "step": ""
    },
    # "XT_Pout_a_kW_I3101_tot": {
    #     "lab": "XT Pout L1+L2 [kW]",
    #     "description": "somme Pout I3101 L1+L2 (calculated)",
    #     "unit": "kW",
    #     "scale": "auto",
    #     "step": "0.01"
    # },
#### "electronic temperature 1+ (minute max) (°C)",
    "XT_Tp1_MAX_C_I3103_L1_1": {
        "lab" : "XT Tp1 MAX L1 1 [°C]",
        "description":  "electronic temperature 1 (minute max)",
        "unit": "°C",
        "scale": "",
        "step": ""
    },

"VT_PsoM_kW_I11043_1": {
    "lab" : "VT PsoM 1 [kW]",
        "description": "PV power (min. avg)",
        "unit": "kW",
        "scale": "",
        "step":""
    },
"VT_PsoM_kW_I11043_ALL": {
    "lab":"VT PsoM ALL [kW]",
        "description": "PV power (min. avg)",
        "unit": "kW",
        "scale": "",
        "step":""
    },
"VT_Mode_I11016_1": {
    "lab" : "VT Mode 1 [enum]",
        "description": "Operating mode (0:Night, 1:StartUp,3:Charger,5:Security,6:OFF,8-12:Charge)",
        "unit": "kW",
        "scale": "",
        "step":""
    },

"VT_Tp1M_C_I11045_1": {
    "lab" : "VT Tp1M 1 [°C]",
        "description": "Electronic temperature 1 (min. avg)",
        "unit": "°C",
        "scale": "",
        "step":""
    },
"VT_UpvM_Vdc_I11041_1": {
    "lab" : "VT UpvM Vdc 1 [Vdc]",
        "description": "PV voltage (minute avg)",
        "unit": "Vdc",
        "scale": "",
        "step":""
    },
"VT_IbaM_Adc_I11040_1": {
        "lab": "VT IbaM 1 [Adc]",
    "description": "Battery current (minute avg)",
        "unit": "Adc",  #float
        "scale": "",
        "step":""
    },
"VT_UbaM_Vdc_I11039_1": {
    "lab" : "VT UbaM 1 [Vdc]",
        "description": "Battery voltage (minute avg)",
        "unit": "Vdc",
        "scale": "",
        "step":""
    },

"VT_Phase_I11038_1": {
    "lab" : "VT Phase 1",
        "description": "Battery cycle phase (0:Bulk, 1:Absorpt., 2:Equalize, 3:Floating, 6:R.float., 7:Per.abs.)",
        "unit": "",
        "scale": "",
        "step":""
    },
"VT_E_CMD_I11082_1": {
        "lab" : "VT E CMD 1",
        "description": "Remote entry state (0:RM EN 0, 1:RM EN 1)",
        "unit": "",
        "scale": "",
        "step":""
    },
"VT_Aux_1_I11061_1": {
            "lab":"VT Aux 1 [bool]",
        "description": "State of auxiliary relay 1 (0:Opened, 1:Closed)",
        "unit": "",
        "scale": "0-1",
        "step":"1"
    },
"VT_Aux_2_I11062_1": {
    "lab" :"VT Aux 2 [bool]",
        "description": "State of auxiliary relay 2 (0:Opened, 1:Closed)",
        "unit": "",
        "scale": "0-1",
        "step":"1"
    },


## VT manquants dans les premiers fichiers 


    "BSP_Ubat_Vdc_I7030_1": {
         "lab" : "BSP Ubat 1 [Vdc]",
        "description": "tension de la batterie (battery voltage - minute avg)",
        "unit": "Vdc",
        "scale": "40-60",
        "step": ""
    },
    "BSP_Ibat_Adc_I7031_1": {
        "lab": "BSP Ibat 1 [Adc]",
        "description": "courant de la batterie (battery current minute avg)",
        "unit": "Adc",
        "scale": "-30-30",
        "step": ""
    },
# "State of Charge (SOC) (minute avg)" (%)
    "BSP_SOC_I7032_1":  {
        "lab": "BSP SOC 1 [%]",
        "description": "state of charge (minute avg)",
        "unit": "%",
        "scale": "0-100",
        "step": ""
    },
    "BSP_Tbat_C_I7033_1": {
        "lab": "BSP Tbat C [°C]",
        "description": "température de la batterie (battery temp. minute avg)",
        "unit": "°C",
        "scale": "-30-30",
        "step": ""
    },
    "Solar_power_ALL_kW_I17999_ALL":  {
        "lab": "Solar power ALL [kW]",
        "description": "solar power ALL (pas trouvé)",
        "unit": "kW",
        "scale": "",
        "step": ""
    },
    "DEV_XT_DBG1_I3140_1":  {
        "lab": "DEV XT DBG1 1",
        "description": "system debug",
        "unit": "NA",
        "scale": "NA",
        "step": "NA"
    },# System debug 1
    "DEV_BSP_locE_I7059_1":  {
        "lab": "DEV BSP locE 1",
        "description": "Local daily communication error counter (CAN)",
        "unit": "",
        "scale": "",
        "step": ""
    },# local daily communication error counter (CAN)
	"DEV_VT_locEr_I11076_1": { 
		"lab":"DEV VT locEr 1 [int]",
            "description": "Local daily communication error counter (CAN)",
		"unit": "",
		"scale": "0-1",
		"step":"1"
	},
    "DEV_SYS_MSG_I17997_1":  {
        "lab": "pas trouvé",
        "description": "pas trouvé",
        "unit": "NA",
        "scale": "NA",
        "step": "NA"
    }, # PAS trouvé
    "DEV_SYS_SCOM_ERR_I17998_1":  {
        "lab": "pas trouvé",
        "description": "pas trouvé",
        "unit": "NA",
        "scale": "NA",
        "step": "NA"
    }# pas trouv é
}


for icol in time_added_cols:
    if not icol in showcols_settings:
        showcols_settings[icol] =  showcols_settings[icol.replace('_L1_L2', '_L1')].copy()
        showcols_settings[icol]['lab'] =showcols_settings[icol]['lab'].replace("L1", "L1+L2")
        showcols_settings[icol]['description'] =showcols_settings[icol]['description'].replace("L1", "L1+L2")

showcols_settings["XT_Tp1_MAX_C_I3103_L2_2"] = showcols_settings["XT_Tp1_MAX_C_I3103_L1_1"]
showcols_settings["XT_Pout_kVA_I3097_L2"] = showcols_settings["XT_Pout_kVA_I3097_L1"]
showcols_settings["XT_Ubat_MIN_Vdc_I3090_L2"] = showcols_settings["XT_Ubat_MIN_Vdc_I3090_L1"]
showcols_settings["XT_Uin_Vac_I3113_L2"] = showcols_settings["XT_Uin_Vac_I3113_L1"]
showcols_settings["XT_Iin_Aac_I3116_L2"] = showcols_settings["XT_Iin_Aac_I3116_L1"]
showcols_settings["XT_Pout_kVA_I3098_L2"] = showcols_settings["XT_Pout_kVA_I3098_L1"]
showcols_settings["XT_Fin_Hz_I3122_L2"] = showcols_settings["XT_Fin_Hz_I3122_L1"]
showcols_settings["XT_Phase_I3010_L2"] = showcols_settings["XT_Phase_I3010_L1"]
showcols_settings["XT_Transfert_I3020_L2"] = showcols_settings["XT_Transfert_I3020_L1"]
showcols_settings["XT_Pin_a_kW_I3119_L2_2"] = showcols_settings["XT_Pin_a_kW_I3119_L1_1"]
showcols_settings["XT_Pout_a_kW_I3101_L2_2"] = showcols_settings["XT_Pout_a_kW_I3101_L1_1"]

assert set(showcols_settings.keys()) == set(time_real_cols+time_added_cols)


IvarsOfInterset = ["I3081",
                   "I3083",
                   "I7007",
                   "I7008",
                   "I11006",
                   "I11007"]


dayIcols_settings={
"I7007": {
    "lab" : "Charge du jour [Ah]",
    "description": "Energie chargée (daily) (Ah charged today)",
    "unit": "Ah",
    "scale": "",
    "step": "",
    "source":"BSP"
},
"I7008": {
    "lab": "Décharge du jour [Ah]",
    "description": "Energie déchargée (daily) (Ah discharged today)",
    "unit": "Ah",
    "scale": "",
    "step": "",
    "source":"BSP"
},
"I11006": {### VarioTrack
    "lab" : "Production du jour [Ah]",
    "description": "Production (daily) (Production in  Ah for the current day)",
    "unit": "Ah",
    "scale": "",
    "step": "",
    "source": "VarioTrack"
},
"I11007": {### VarioTrack
    "lab" :"Production du jour [kWh]",
    "description": "Production solaire (daily) (Production in  kWh for the current day)",
    "unit": "kWh",
    "scale": "",
    "step": "",
    "source": "VarioTrack"
},
    # Energie AC-In de la journée en cours (3081)
# XTender
"I3081": { # Bilan journalier de l'energie (kWh) prise ou injectée (-) sur le réseau (entrée) L1
    "lab" : "Energie AC-In du jour [kWh]",
    "description": "Energie (bilan) sur les entrées (daily) (energy AC-In from the current day)",
    "unit": "kWh",
    "scale": "",
    "step": "",
    "source": "XTender"
},
    # nergie consommée de la journee en cours
    # XTender
"I3083": { # Bilan journalier de l'energie (kWh) conssommée sur les 2 circuit secouru L1
    "lab" : "Energie consommée du jour [kWh]",
    "description": "Energie (bilan) sur les sorties (daily) (consumers energy of the current day (sortie réseau AC-Out))",
    "unit": "kWh",
    "scale": "",
    "step": "",
    "source": "XTender"
},
"I15016": {
    "lab" : "Production PV du jour [Ah]",
    "description": "Production PV in (Ah) for the current day",
    "unit": "Ah",
    "scale": "",
    "step": "",
    "source": "Variostring"
},
"I15017": {
"lab" : "Production PV du jour [kWh]",
    "description": "Production PV in (kWh) for the current day",
    "unit": "kWh",
    "scale": "",
    "step": "",
    "source": "Variostring"
},
"I7053": {
"lab" : "Type de batterie",
    "description": "Battery Type",
    "unit": "",
    "scale": "",
    "step": "",
    "source": "Xcom-CAN BMS"
},
"I7054": {
    "lab" : "Version du BMS",
    "description": "BMS Version",
    "unit": "",
    "scale": "",
    "step": "",
    "source": "Xcom-CAN BMS"
},
"I7055": {
    "lab" : "Capacité de batterie [Ah]",
    "description": "Nominal or remaining battery capacity",
    "unit": "Ah",
    "scale": "",
    "step": "",
    "source": "Xcom-CAN BMS"
},
"I7056": {
    "lab": "Reserve ID fabricant",
    "description": "Reserved Manufacturer ID",
    "unit": "",
    "scale": "",
    "step": "",
    "source": "Xcom-CAN BMS"
},
"I7067": {
    "lab": "Manufacturer name",
    "description": "Manufacturer name",
    "unit": "",
    "scale": "0-3",
    "step": "1",
    "source": "Xcom-CAN BMS"
}
}


dayPcols_settings={
"P1107": {
    "description": "Maximum current of AC source (Input limit)",
    "unit": "Aac",
    "scale": "",
    "step": "",
    "source": "XTender"
},
"P1567": {
    "description": "Second maximum current of the AC source (Input limit)",
    "unit": "Aac",
    "scale": "",
    "step": "",
    "source": "XTender"
},
"P1138": {
    "description": "Battery charge current",
    "unit": "Adc",
    "scale": "0-200",
    "step": "",
    "source": "XTender"
},
"P1108": {
    "description": "Battery undervoltage level without load",
    "unit": "Vdc",
    "scale": "",
    "step": "",
    "source": "XTender"
},
"P1140": {
    "description": "Floating voltage",
    "unit": "Vdc",
    "scale": "",
    "step": "",
    "source": "XTender"
},
    "P1155": {
    "description": "Absorption phase allowed (0=no, 1=yes)",
    "unit": "",
    "scale": "",
    "step": "",
    "source": "XTender"
},
"P1156": {
    "description": "Absorption voltage",
    "unit": "Vdc",
    "scale": "",
    "step": "",
    "source": "XTender"
},
"P1163": {
    "description": "Equalization allowed (0=no, 1=yes)",
    "unit": "",
    "scale": "",
    "step": "",
    "source": "XTender"
},
"P1164": {
    "description": "Equalization voltage",
    "unit": "Vdc",
    "scale": "37.9-72",
    "step": "0.1",
    "source": "XTender"
},
"P6001": {
    "description": "Nominal capacity",
    "unit": "Ah",
    "scale": "20-20000",
    "step": "10",
    "source": "XTender"
}
}

### Xtender
# 1107 Maximum current of AC source (Input limit) (Aac]
# 1567 Second maximum current of the AC source (Input limit) (Aac]
# 1138 Battery charge current [Adc] 0-200 FLOAT def. 60
# 1108 Battery undervoltage level without load Vdc 36-72 FLOAT def. 46.3
# 1140 Floating voltage Vdc def. 54.4 37.9-72 FLOAT
# 1155 Absorption phase allowed def. 1:Yes ; 0:No 1:Yes BOOL
# 1156 Absorption voltage Vdc 57.6 37.9 72  FLOAT
# 1163 Equalization allowed 0:No 0:No 1:Yes BOOL
# 1164 Equalization voltage Vdc 62.4 37.9 72 FLOAT step 0.1
# 6001 6001 Nominal capacity Ah 110 20 20000 FLOAT 10
# missing_desc_cols_dayP = ["","","","","","",""]
# for icol in missing_desc_cols_dayP:
#     dayPcols_settings[icol] = { # Bilan journalier de l'energie [kWh] conssommée sur les 2 circuit secouru L1
#     "description": "-description manquante-"
# }

start_colsI = list(dayIcols_settings.keys())
for icol in start_colsI:
    dayIcols_settings[icol+"_1"] = dayIcols_settings[icol]
    dayIcols_settings[icol + "_2"] = dayIcols_settings[icol]

# start_colsP = list(dayPcols_settings.keys())
# for icol in start_colsP:
#     dayPcols_settings[icol + "_1"] = dayPcols_settings[icol]
#     dayPcols_settings[icol + "_2"] = dayPcols_settings[icol]
#     dayPcols_settings[icol + "_3"] = dayPcols_settings[icol]
# Configuration de la disposition des axes y
yaxis_layout = dict(
    title="yaxis title",
    titlefont=dict(color=timePlotLineCols[0]),
    tickfont=dict(color=timePlotLineCols[0]),
    showline=True,
    linewidth=2,
    linecolor='black'
)
yaxis2_layout = dict(
    title="yaxis2 title",
    titlefont=dict(color=timePlotLineCols[1]),
    tickfont=dict(color=timePlotLineCols[1]),
    overlaying="y",
    side="right",
    showline=True,
    linewidth=2,
    linecolor='black'
)
yaxis3_layout = dict(
    title="yaxis3 title",
    titlefont=dict(color=timePlotLineCols[2]),
    tickfont=dict(color=timePlotLineCols[2]),
    anchor="free",
    overlaying="y",
    autoshift=True,
    showline=True,
    linewidth=2,
    linecolor='black'
)
yaxis4_layout = dict(
    title="yaxis4 title",
    titlefont=dict(color=timePlotLineCols[3]),
    tickfont=dict(color=timePlotLineCols[3]),
    anchor="free",
    overlaying="y",
    side="right",
    autoshift=True,
    showline=True,
    linewidth=2,
    linecolor='black'
)