-
Notifications
You must be signed in to change notification settings - Fork 1
/
HMinfoTools.js
1875 lines (1772 loc) · 73.8 KB
/
HMinfoTools.js
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
FW_version["HMinfoTools.js"] = "$Id: HMinfoTools.js 2005 2021-12-02 18:00:00Z frank $";
var HMinfoTools_debug = true;
var HMinfoTools_csrf;
var devMap = new Map();
function HMinfoTools_initMapDevice(device) {
var devObj = {name: device,
parentDev: '',
errors: [],
model: '',
commState: '',
rssi: '',
IODev: '',
aIODev: '',
IOgrp: '',
cfgState: '',
actCycle: '',
actStatus: '',
activity: '',
battery: '',
motorErr: '',
sabotageError: '',
sabotageAttack: '',
smokeDetect: ''
};
devMap.set(device,devObj);
}
var HMinfoTools_icons = [
{name: 'commState',poll: 'parent',svg: 'rc_dot',colorElements: ['path'],clickG: 'clearG msgErrors',click: 'HMinfoTools_setClearMsgEvents'},
{name: 'rssi',poll: 'parent',svg: 'it_wifi',colorElements: ['g'],clickG: 'clearG rssi',click: 'HMinfoTools_setClearRssi'},
{name: 'IODev',poll: 'parent',svg: 'cul_868',colorElements: ['g'],clickG: '',click: ''},
{name: 'cfgState',poll: 'device',svg: 'edit_settings',colorElements: ['g'],clickG: '',click: 'HMinfoTools_setGetConfig'},
{name: 'Activity',poll: 'parent',svg: 'message_attention',colorElements: ['path'],clickG: 'cmdRequestG ping',click: ''},
{name: 'battery',poll: 'parent',svg: 'measure_battery_75',colorElements: ['g'],clickG: '',click: 'HMinfoTools_setBatteryChange'},
{name: 'motorErr',poll: 'device',svg: 'sani_domestic_waterworks',colorElements: ['g'],clickG: '',click: ''},
{name: 'sabotageError',poll: 'device',svg: 'secur_locked',colorElements: ['g'],clickG: '',click: ''},
{name: 'sabotageAttack',poll: 'parent',svg: 'ring',colorElements: ['polygon','path','rect'],clickG: 'clearG attack',click: 'HMinfoTools_setClearAttack'},
{name: 'smokeDetect',poll: 'device',svg: 'secur_smoke_detector',colorElements: ['g'],clickG: '',click: ''}
];
$(document).ready(function() {
var body = document.querySelector('body');
if(body != null) {HMinfoTools_csrf = body.getAttribute('fwcsrf');}
var seldiv = document.querySelector('div.makeSelect');
var weblinkdiv = document.getElementById('hminfotools_weblink');
if(seldiv != null) {
var hminfo = seldiv.getAttribute('dev');
HMinfoTools_parseErrorDevices(hminfo,weblinkdiv);
}
else if(weblinkdiv != null) {
var hminfo = weblinkdiv.getAttribute('dev');
HMinfoTools_parseErrorDevices(hminfo,weblinkdiv);
}
});
function HMinfoTools_getAllRssiData() {
var hminfo = $('#hminfotools').attr('device');
var cmd = 'get ' +hminfo+ ' rssiG full';
if(HMinfoTools_debug) {log('HMinfoTools: ' + cmd);}
var url = HMinfoTools_makeCommand(cmd);
$.get(url,function(data) {
if(data != null) {
/*
rssiG done:
Device receive from last avg min_max count
DimUP01 DimUP01 cul868 -59.0 -58.7 -59.0< -58.0 3
DimUP01 DimUP01 hmlan1 -62.0 -63.6 -66.0< -62.0 12
DimUP01 cul868 DimUP01 -62.0 -61.8 -63.0< -60.5 15
DimUP01 hmlan1 DimUP01 -62.0 -62.1 -67.0< -61.0 15
DimUP01 hmuart1 DimUP01 -60.0 -58.2 -60.0< -57.0 12
*/
var rssiMap = new Map();
var lines = data.split('\n');
for(var l = 2; l < lines.length; ++l) {
var line = lines[l];
var match = line.match(/^\s*([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^<]+)<\s+([^\s]+)\s*([^\s]+)\s*$/);
if(match != null) {
var device = match[1];
var rssiObj = {};
rssiObj.to = match[2];
rssiObj.from = match[3];
rssiObj.lst = match[4];
rssiObj.avg = match[5];
rssiObj.min = match[6];
rssiObj.max = match[7];
rssiObj.cnt = match[8];
var rssiDevObj = {};
if(rssiMap.has(device)) {
rssiDevObj = rssiMap.get(device);
rssiDevObj.rssiArr.push(rssiObj);
}
else {
rssiDevObj.rssiArr = [rssiObj];
}
rssiMap.set(device,rssiDevObj);
}
}
var div = $("<div id='FW_okDialog'>");
$(div).html('rssi table' + '<br><br>');
$("body").append(div);
// rssi table
var table = document.createElement('table');
$(div).append(table);
table.id = 'HMinfoTools_rssiTable';
table.style.margin = '10px 0px 0px 0px';
var thead = document.createElement('thead');
table.appendChild(thead);
var row = document.createElement('tr');
thead.appendChild(row);
row.id = 'HMinfoTools_rssiTable_header';
var headerList = ['device','receive','from','last','min','avg','max','count',
'delta<br>minMax','delta<br>avgMax','delta<br>avgAvg','IODev<br>ranking','IOgrp<br>setting'];
for(var h = 0; h < headerList.length; ++h) {
var thCol = document.createElement('th');
row.appendChild(thCol);
//thCol.setAttribute('scope','col');
if(h > 2) {thCol.align = 'center';}
thCol.innerHTML = headerList[h];
}
var tbody = document.createElement('tbody');
table.appendChild(tbody);
var deviceCnt = 0;
rssiMap.forEach(function(value,key,map) {
++deviceCnt;
var curIODev = devMap.has(key)? devMap.get(key).IODev: '';
var curIOgrp = devMap.has(key)? devMap.get(key).IOgrp: '';
var devObj = map.get(key);
var rssiOutArr = devObj.rssiArr.filter(item => item.to != key);
rssiOutArr.sort((a,b) => {
var c1 = parseInt(a.cnt);
var c2 = parseInt(b.cnt);
var a1 = parseFloat(a.avg);
var a2 = parseFloat(b.avg);
if(c1 < c2) return 1;
if(c1 > c2) return -1;
if(a1 < a2) return 1;
if(a1 > a2) return -1;
return 0;
});
for(var r = 0; r < devObj.rssiArr.length; ++r) {
var row = document.createElement('tr');
tbody.appendChild(row);
row.id = 'HMinfoTools_rssiTable_row_' +key+ '_r' + r;
row.style.backgroundColor = (deviceCnt%2 == 0)? '#333333': '#111111';
//row header
var c0 = document.createElement('td');
row.appendChild(c0);
c0.style.color = 'lightblue';
if(r == 0) {c0.innerHTML = '<a href="/fhem?detail=' +key+ '">' +key+ '</a>';}
var c1 = document.createElement('td');
row.appendChild(c1);
c1.align = 'left';
c1.innerHTML = '<a href="/fhem?detail=' +devObj.rssiArr[r].to+ '">' +devObj.rssiArr[r].to+ '</a>';
var c2 = document.createElement('td');
row.appendChild(c2);
c2.align = 'left';
var fromDevName = devObj.rssiArr[r].from.replace(/\/.+$/,'');
c2.innerHTML = '<a href="/fhem?detail=' +fromDevName+ '">' +devObj.rssiArr[r].from+ '</a>';
var c3 = document.createElement('td');
row.appendChild(c3);
c3.align = 'right';
c3.innerHTML = devObj.rssiArr[r].lst;
var c4 = document.createElement('td');
row.appendChild(c4);
c4.align = 'right';
c4.style.color = doColorAbs(devObj.rssiArr[r].min);
c4.innerHTML = devObj.rssiArr[r].min;
var c5 = document.createElement('td');
row.appendChild(c5);
c5.align = 'right';
if(curIODev == devObj.rssiArr[r].to || curIODev == devObj.rssiArr[r].from) {c5.style.backgroundColor = '#888888';}
c5.style.color = doColorAbs(devObj.rssiArr[r].avg);
c5.innerHTML = devObj.rssiArr[r].avg;
var c6 = document.createElement('td');
row.appendChild(c6);
c6.align = 'right';
c6.style.color = doColorAbs(devObj.rssiArr[r].max);
c6.innerHTML = devObj.rssiArr[r].max;
var c7 = document.createElement('td');
row.appendChild(c7);
c7.align = 'right';
c7.innerHTML = devObj.rssiArr[r].cnt;
var c8 = document.createElement('td');
row.appendChild(c8);
c8.align = 'right';
c8.style.color = doColorDiff(Math.abs(devObj.rssiArr[r].min-devObj.rssiArr[r].max).toFixed(1));
c8.innerHTML = (devObj.rssiArr[r].min-devObj.rssiArr[r].max).toFixed(1);
var c9 = document.createElement('td');
row.appendChild(c9);
c9.align = 'right';
c9.style.color = doColorDiff(Math.abs(devObj.rssiArr[r].avg-devObj.rssiArr[r].max).toFixed(1));
c9.innerHTML = (devObj.rssiArr[r].avg-devObj.rssiArr[r].max).toFixed(1);
var c10 = document.createElement('td');
row.appendChild(c10);
c10.align = 'right';
if(devObj.rssiArr[r].to == key) {
var avg1 = devObj.rssiArr[r].avg;
var io = devObj.rssiArr[r].from;
devObj.rssiArr.forEach(function(rssiToIO) {
if(rssiToIO.to != key) {
var test = rssiToIO.cnt;
}
if(rssiToIO.to == io) {
var avg2 = rssiToIO.avg;
c10.style.color = doColorDiff(Math.abs(avg1-avg2).toFixed(1));
c10.innerHTML = (avg1-avg2).toFixed(1);
}
});
}
var c11 = document.createElement('td');
row.appendChild(c11);
c11.align = 'center';
if(devObj.rssiArr[r].to != key) {
rssiOutArr.forEach((rssiToIO,index) => {
if(rssiToIO.to == devObj.rssiArr[r].to) {
c11.style.color = (index == 0 && curIODev == devObj.rssiArr[r].to)? 'lime': (curIODev == devObj.rssiArr[r].to)? 'red': '';
c11.innerHTML = (index+1) + '.';
}
});
}
var c12 = document.createElement('td');
row.appendChild(c12);
c12.align = 'center';
c12.style.whiteSpace = 'nowrap';
if(r == (devObj.rssiArr.length - rssiOutArr.length) && curIOgrp != '') { //first row of rssiOut
var input = document.createElement('input');
c12.appendChild(input);
input.id = 'IOgrp_inp_'+key;
input.disabled = true;
input.placeholder = curIOgrp;
input.setAttribute('orgvalue',curIOgrp);
input.style.margin = '0px 0px 0px 0px';
input.style.width = '140px';
input.title = 'current: '+curIOgrp;
input.setAttribute('onchange','HMinfoTools_updateChangedValues("'+input.id+'")');
var val = curIOgrp.replace(/:.*$/,'') + ':';
var prefCnt = (rssiOutArr.length < 3)? rssiOutArr.length: 2;
for(var p = 0; p < prefCnt; ++p) {
if(p == 0) {val += rssiOutArr[p].to;}
else {val += ',' + rssiOutArr[p].to;}
}
//input.style.color = (val == curIOgrp)? 'lime': 'red';
if(val != curIOgrp) {
input.setAttribute('class','changed');
}
input.value = val;
var check = document.createElement('input');
c12.appendChild(check);
check.type = 'checkbox';
check.id = 'IOgrp_check_' + key;
check.checked = false;
check.style.margin = '10px 0px 0px 0px';
check.title = 'check => enable IOgrp setting';
check.style.cursor = 'pointer';
check.setAttribute('onchange','HMinfoTools_enableSetIOgrp("'+key+'")');
}
}
});
function doColorAbs(rssi) {
var color = 'lightblue';
if(-80 < rssi) {color = 'lime';}
else if(-90 < rssi && rssi <= -80) {color = 'yellow';}
else if(-99 <= rssi && rssi <= -90) {color = 'orange';}
else if(rssi < -99) {color = 'red';}
return color;
}
function doColorDiff(rssi) {
var color = 'blue';
if(5 > rssi) {color = 'lime';}
else if(10 > rssi && rssi >= 5) {color = 'yellow';}
else if(15 > rssi && rssi >= 10) {color = 'orange';}
else if(rssi >= 15) {color = 'red';}
return color;
}
function doAllOnOff(opt) {
$("[id^='IOgrp_check_']").each(function() {
var inp = document.getElementById(this.id.replace(/check/,'inp'));
if(opt && inp.getAttribute('orgvalue') != inp.value) {this.checked = true;}
else {this.checked = false;}
HMinfoTools_enableSetIOgrp(this.id.replace(/IOgrp_check_/,''))
});
}
function doSetIOgrp() {
// check for enabled devices and set attributes
var cmd = '';
$("[id^='IOgrp_check_']").each(function() {
if(this.checked) {
var inp = document.getElementById(this.id.replace(/check/,'inp'));
if(inp.getAttribute('orgvalue') != inp.value && inp.value != '') {
var device = inp.id.replace(/IOgrp_inp_/,'');
cmd += 'attr ' +device+ ' IOgrp ' +inp.value+ ';';
}
}
});
var url = HMinfoTools_makeCommand(cmd);
if(cmd != '') {
if(HMinfoTools_debug) {log('HMinfoTools: ' + cmd);}
$.get(url, function(data){
if(data) {FW_okDialog(data);}
else {
$(div).dialog('close');
location.reload();
}
});
}
else {FW_okDialog('No changed attributes enabled, nothing to do');}
}
function doClose() {
$(div).dialog('close');
$(div).remove();
}
$(div).dialog({ dialogClass:'no-close', modal:true, width:$('#HMinfoTools_rssiTable').width()*1.1, closeOnEscape:true,
maxWidth:$(window).width()*0.9, maxHeight:$(window).height()*0.9,
//maxWidth:$(window).width()*0.9, height: 'auto+20',
buttons: [{text:'All Changed On', click:function(){doAllOnOff(true);}},
{text:'All Off', click:function(){doAllOnOff(false);}},
{text:'Set IOgrp', click:function(){doSetIOgrp();}},
{text:'Cancel', click:function(){doClose();}}]
});
}
});
}
function HMinfoTools_updateChangedValues(id) {
var inp = document.getElementById(id);
if(inp.getAttribute('orgvalue') != inp.value) {inp.setAttribute('class','changed');}
else {inp.removeAttribute('class','changed');}
}
function HMinfoTools_enableSetIOgrp(device) {
document.getElementById('IOgrp_inp_'+device).disabled = (document.getElementById('IOgrp_check_'+device).checked? false: true);
}
function HMinfoTools_setAttrIOgrp() {
}
/*
*/
function HMinfoTools_parseDevFromJson(device,data) {
var devObj = devMap.get(device);
//parentDev
devObj.parentDev = (data.Internals.DEF.length == 6)? data.Internals.NAME: data.Internals.device;
//model
devObj.model = (data.Attributes.model != null)? data.Attributes.model: 'missing_model';
//commState
devObj.commState = (data.Readings.commState != null)? data.Readings.commState.Value: 'Info_Unknown';
//rssi
internalsString = JSON.stringify(data.Internals);
var curIoDev = (data.Internals.IODev != null && !data.Internals.IODev.match(/^HASH\(/))
? data.Internals.IODev
: 'missing_IODev';
devObj.rssi = 'rssi_at_'+curIoDev+' => ' + ((internalsString.match('rssi_at_'+curIoDev))
? data.Internals['rssi_at_'+curIoDev]
: 'missing_rssi');
//IODev
if(data.Internals.IODev != null) {devObj.IODev = (data.Internals.IODev != null)? data.Internals.IODev: 'missing_IODev';}
//aIODev
devObj.aIODev = (data.Attributes.aIODev != null)? data.Attributes.aIODev: 'missing_aIODev';
//IOgrp
devObj.IOgrp = (data.Attributes.IOgrp != null)? data.Attributes.IOgrp: 'missing_IOgrp';
//cfgState
devObj.cfgState = (data.Readings.cfgState != null)? data.Readings.cfgState.Value: 'Info_Unknown';
//actCycle
devObj.actCycle = (data.Attributes.actCycle != null)? data.Attributes.actCycle: 'unknown';
//actStatus
devObj.actStatus = (data.Attributes.actStatus != null)? data.Attributes.actStatus: 'unknown';
//activity
if(data.Attributes.actCycle != null) {
if(data.Attributes.actCycle == '000:00') {devObj.activity = 'switchedOff';}
else {devObj.activity = (data.Attributes.actStatus != null)? data.Attributes.actStatus: 'unknown';}
}
else {devObj.activity = 'unused';}
//battery
if(data.Readings.battery != null) {devObj.battery = data.Readings.battery.Value;}
//motorErr
if(data.Readings.motorErr != null) {devObj.motorErr = data.Readings.motorErr.Value;}
//sabotage
if(data.Readings.sabotageError != null) {devObj.sabotageError = data.Readings.sabotageError.Value;}
//attack
if(data.Readings.sabotageAttack_ErrIoAttack_cnt != null) {devObj.sabotageAttack = data.Readings.sabotageAttack_ErrIoAttack_cnt.Value;}
//smokeDetect
if(data.Readings.smoke_detect != null) {devObj.smokeDetect = data.Readings.smoke_detect.Value;}
devMap.set(device,devObj);
}
function HMinfoTools_parseErrorDevices(hminfo,weblinkdiv) {
var cmd = 'jsonlist2 ' + hminfo;
if(HMinfoTools_debug) {log('HMinfoTools: ' + cmd);}
var url = HMinfoTools_makeCommand(cmd);
$.getJSON(url).done(function(data) {
var object = data.Results[0];
if(object != null && object.Internals.TYPE == 'CUL_HM' && object.Attributes.model != 'ACTIONDETECTOR') {
if(typeof HMdeviceTools_createRegisterTable == 'function') { //for cul_hm device details (hm.js)
if(HMinfoTools_debug) {log('HMinfoTools: ' + 'HMdeviceTools is present');}
var isHMdeviceTools = false;
var isHMdeviceTools_pendingInfo = false;
//install mutationObserver to manage perfect handling
const observer3 = new MutationObserver(function(mutationList,observer) {
mutationList.forEach((mutation) => {
if(mutation.type == 'attributes' && mutation.target == document.getElementById('HMdeviceTools_toolsTable')){
if(mutation.attributeName == 'installation') {
if(mutation.oldValue == null) { //value=init
if(HMinfoTools_debug) {log('HMinfoTools: ' + 'HMdeviceTools => started installation');}
}
else if(mutation.oldValue == 'init') { //value=ready
isHMdeviceTools = true;
if(HMinfoTools_debug) {log('HMinfoTools: ' + 'HMdeviceTools => finished installation');}
HMinfoTools_loadIcons(object.Internals.NAME,document.getElementById('HMdeviceTools_toolsTable_svg'));
$('#HMdeviceTools_toolsTable').attr('errordevices_data','start'); //1. run (allready done)
$('#HMdeviceTools_toolsTable').attr('errordevices_data','first'); //1. run (allready done)
$('#HMdeviceTools_toolsTable').attr('errordevices_list',object.Internals.NAME);
if(isHMdeviceTools_pendingInfo && object.Internals.DEF.length == 8) {
$('#HMdeviceTools_toolsTable').attr('errordevices_list',(object.Internals.NAME+':'+data.Results[0].Internals.NAME));
$('#HMdeviceTools_toolsTable').attr('errordevices_data','ready'); //2. run (allready done)
}
else if(object.Internals.DEF.length == 6) {
$('#HMdeviceTools_toolsTable').attr('errordevices_data','ready'); //only 1. run (allready done)
}
}
}
var isInstallationReady = ($('#HMdeviceTools_toolsTable').attr('installation') == 'ready')? true: false;
var areIconsLoaded = ($('#HMdeviceTools_toolsTable').attr('loaded_icons') == HMinfoTools_icons.length)? true: false;
//var isErrDataFirst = ($('#HMdeviceTools_toolsTable').attr('errordevices_data') == 'first')? true: false;
var isErrDataReady = ($('#HMdeviceTools_toolsTable').attr('errordevices_data') == 'ready')? true: false;
if(isInstallationReady && areIconsLoaded && isErrDataReady) { //all icons and infos loaded
observer3.disconnect();
var errorList = $('#HMdeviceTools_toolsTable').attr('errordevices_list');
var errorDevices = errorList.split(':')[0];
if(errorDevices != '') {
if(HMinfoTools_debug) {log('HMinfoTools: ' + 'HMdeviceTools => all data ready');}
HMinfoTools_createIconCells(document.getElementById('HMdeviceTools_toolsTable_icons'),object.Internals.NAME);
HMinfoTools_initIcons(object.Internals.NAME);
var informDevices = (errorList.match(/:$/))? errorList.replace(/:$/,''): errorList.replace(/:/,',');
setTimeout(HMinfoTools_changeInformChannel(informDevices),1000);
}
}
}
});
});
observer3.observe(document.body,{subtree: true,
childList: false,
attributeFilter: ['installation','loaded_icons','errordevices_data'],
attributeOldValue: true}
);
HMinfoTools_initMapDevice(object.Internals.NAME);
HMinfoTools_parseDevFromJson(object.Internals.NAME,object);
if(object.Internals.DEF.length == 8) {
var cmd = 'jsonlist2 ' + object.Internals.device;
if(HMinfoTools_debug) {log('HMinfoTools: ' + cmd);}
var url = HMinfoTools_makeCommand(cmd);
$.getJSON(url,function(data) {
if(data.Results[0] != null) {
HMinfoTools_initMapDevice(data.Results[0].Internals.NAME);
HMinfoTools_parseDevFromJson(data.Results[0].Internals.NAME,data.Results[0]);
if(isHMdeviceTools) {
$('#HMdeviceTools_toolsTable').attr('errordevices_list',(object.Internals.NAME+':'+data.Results[0].Internals.NAME));
$('#HMdeviceTools_toolsTable').attr('errordevices_data','ready'); //2. run (allready done)
}
else {isHMdeviceTools_pendingInfo = true;}
}
});
}
if(document.getElementById('HMdeviceTools_toolsTable') != null && $('#HMdeviceTools_toolsTable').attr('installation') == 'ready') {
isHMdeviceTools = true;
if(HMinfoTools_debug) {log('HMinfoTools: ' + 'HMdeviceTools => is ready');}
HMinfoTools_loadIcons(hminfo,document.getElementById('HMdeviceTools_toolsTable_svg'));
$('#HMdeviceTools_toolsTable').attr('errordevices_data','start'); //1. run (allready done)
$('#HMdeviceTools_toolsTable').attr('errordevices_data','first'); //1. run (allready done)
$('#HMdeviceTools_toolsTable').attr('errordevices_list',object.Internals.NAME); //1. run (allready done)
if(object.Internals.DEF.length == 6) {
$('#HMdeviceTools_toolsTable').attr('errordevices_data','ready'); //only 1. run (allready done)
}
}
else {
}
}
}
else if(object != null && object.Internals.TYPE == 'HMinfo') { //for hminfo details or weblink
if(document.getElementById('hminfotools') == null) { // 1. run, we want to install basic things
var lastChange = ((object.Readings.lastErrChange == null)?
'updated: Info_Unknown': object.Readings.lastErrChange.Value);
HMinfoTools_createHMinfoTools(hminfo,weblinkdiv,lastChange);
$('#hminfotools').attr('device_mode',((object.Attributes.HMinfoTools_deviceMode == null)
? ''
: object.Attributes.HMinfoTools_deviceMode));;
var check = document.getElementById('hminfo_allDev_check');
check.checked = ($('#hminfotools').attr('device_mode') == 'all')? true: false;
var checkCell = document.getElementById('hminfo_allDev');
checkCell.hidden = ($('#hminfotools').attr('device_mode') == '')? true: false;
var ssAttr = ((object.Attributes.HMinfoTools_screenshotPort == null)?
'': object.Attributes.HMinfoTools_screenshotPort);
var ssArgs = ssAttr.split(',');
$('#hminfotools').attr('ss_port',((ssArgs[0] != null)? ssArgs[0]: ''));
$('#hminfotools').attr('ss_room',((ssArgs[1] != null)? ssArgs[1]: ''));
}
HMinfoTools_parseIOsFromHMinfo(object.Internals.iI_HM_IOdevices);
/*search for devices with errors: CRI_, ERR_, W_
"iCRI__protocol":"SwitchPBU06",
"iERR___rssiCrit":"Thermostat.Keller",
"iERR__actDead":"SwitchUP01",
"iERR__protocol":"Ventil.AZ.Nord,Ventil.AZ.West,Ventil.Bad,Ventil.Kueche,Ventil.WZ",
"iERR_battery":"Thermostat.WZ",
"iERR_sabotageError":"Tuer.SZ",
"iW__protoNames":"DimUP01",
"iW__unreachNames":"DimPBU01_Sw1_V01,DimPBU01_Sw1_V02,SwitchPBU01_Sw_02"
*/
var errorDevices = '';
var internalsString = JSON.stringify(object.Internals);
var mErrorInternal = internalsString.match(/i(?:CRI_|ERR_|W_)[^"]+/g);
if(mErrorInternal != null) {
for(var i = 0; i < mErrorInternal.length; ++i) {
if(object.Internals[mErrorInternal[i]] != undefined) {
var devices = object.Internals[mErrorInternal[i]].split(',');
for(var d = 0; d < devices.length; ++d) {
var devObj = {};
if(!devMap.has(devices[d])) {
errorDevices += devices[d] +',';
HMinfoTools_initMapDevice(devices[d]);
devObj = devMap.get(devices[d]);
devObj.errors = [mErrorInternal[i]];
}
else {
devObj = devMap.get(devices[d]);
devObj.errors.push(mErrorInternal[i]);
}
devMap.set(devices[d],devObj);
}
}
}
}
if($('#hminfotools').attr('device_mode') == 'all') { //all devices w/o problems
var cmd = 'list TYPE=CUL_HM:FILTER=DEF=......:FILTER=DEF!=000000 i:NAME';
if(HMinfoTools_debug) {log('HMinfoTools: ' + cmd);}
var url = HMinfoTools_makeCommand(cmd);
$.get(url,function(data) {
if(data != null) {
//SwitchES01 SwitchES01
var deviceList = '';
var lines = data.split('\n');
for(var l = 0; l < lines.length; ++l) {
if(lines[l] != '') {
var device = lines[l].match(/[^\s]+$/)[0];
deviceList += device + ',';
if(!devMap.has(device)) {
errorDevices += device + ',';
HMinfoTools_initMapDevice(device);
}
}
}
deviceList = deviceList.replace(/,$/,'');
$('#hminfotools').attr('alldevices_list',deviceList);
errorDevices = errorDevices.replace(/,$/,'');
$('#hminfotools').attr('errordevices_list',errorDevices);
if(errorDevices != '') {
$('#hminfotools').attr('errordevices_data','start');
HMinfoTools_getInfoFromErrorDevices('hminfotools'); //1. run (mode=allDevices)
}
else {
$('#hminfotools').attr('errordevices_data','ready');
HMinfoTools_changeInformChannel('');
document.getElementById('hminfo_info').innerHTML = ' => waiting for problems...';
}
}
});
}
else { //only devices with problems
errorDevices = errorDevices.replace(/,$/,'');
$('#hminfotools').attr('errordevices_list',errorDevices);
if(errorDevices != '') {
$('#hminfotools').attr('errordevices_data','start');
HMinfoTools_getInfoFromErrorDevices('hminfotools'); //1. run (mode=errDevices)
}
else {
$('#hminfotools').attr('errordevices_data','ready');
HMinfoTools_changeInformChannel('');
document.getElementById('hminfo_info').innerHTML = ' => waiting for problems...';
}
}
}
})
.fail(function(xhr,status,err) {
if(xhr.status == 400 && typeof HMinfoTools_csrf != 'undefined') {
HMinfoTools_csrf = '';
location.reload();
}
});
}
function HMinfoTools_createHMinfoTools(hminfo,weblinkdiv,lastChange) {
var div = document.createElement('div');
var header;
if(weblinkdiv == null) {
// we will insert the table before the internals
var intdiv = document.querySelector('div.makeTable.wide.internals');
intdiv.parentElement.insertBefore(div,intdiv);
header = intdiv.firstElementChild.cloneNode(false);
}
else {
weblinkdiv.appendChild(div);
header = document.createElement('div');
header.setAttribute('class','col_header pinHeader detail_Internals');
}
div.id = 'hminfotools';
div.setAttribute('device',hminfo); // name of hminfo device
div.setAttribute('installation','init'); // init, ready
div.setAttribute('loaded_icons','init'); // 0_icons: "init"; 9_icons: "9"
div.setAttribute('errordevices_data','init'); // init, start, first, ready
div.setAttribute('errordevices_list','init'); // list of current errorDevices
div.setAttribute('lost','0'); // list of lost connections
div.setAttribute('class','makeTable wide internals');
//var header = document.createElement('div');
div.appendChild(header);
//header.setAttribute('class','col_header pinHeader detail_Internals');
header.innerHTML = '<a href="/fhem?detail=' +hminfo+ '">HMinfoTools</a>';
const elementToObserve = div;
const observer1 = new MutationObserver(function(mutationList,observer) {
mutationList.forEach((mutation) => {
if(mutation.type == 'attributes'){
var isInstallationReady = ($('#hminfotools').attr('installation') == 'ready')? true: false;
var areIconsLoaded = ($('#hminfotools').attr('loaded_icons') == HMinfoTools_icons.length)? true: false;
var isErrDataFirst = ($('#hminfotools').attr('errordevices_data') == 'first')? true: false;
var isErrDataReady = ($('#hminfotools').attr('errordevices_data') == 'ready')? true: false;
if(isErrDataFirst) {HMinfoTools_getInfoFromErrorDevices('hminfotools');} //2. run
if(isInstallationReady && areIconsLoaded && isErrDataReady) { //all icons and infos loaded
var errorList = $('#hminfotools').attr('errordevices_list');
var errorDevices = errorList.split(':')[0];
if(errorDevices != '') {
if(HMinfoTools_debug) {log('HMinfoTools: ' + 'all data ready, new table creation!');}
HMinfoTools_createErrorDevicesTable(errorDevices);
var informDevices = (errorList.match(/:$/))? errorList.replace(/:$/,''): errorList.replace(/:/,',');
setTimeout(HMinfoTools_changeInformChannel(informDevices),1000);
if(typeof html2canvas == 'function') {
var curPort = location.port;
var ssPort = $('#hminfotools').attr('ss_port');
var curRoom = ($('div#content').attr('room') == undefined)? '': $('div#content').attr('room');
var ssRoom = $('#hminfotools').attr('ss_room');
if(curPort == ssPort && curRoom == ssRoom) {
if(HMinfoTools_debug) {log('HMinfoTools: ' + 'sreenshot');}
//connection-lost-dead-loop, wenn ss_port=8083 vom pc browser
//scheinbar verzögert setTimeout hier die initialisierung des longpoll websocket!!!
setTimeout(HMinfoTools_createScreenshot(),10000);
}
}
}
else {if(HMinfoTools_debug) {log('HMinfoTools: ' + 'all data ready, no table creation!');}}
}
}
});
});
observer1.observe(div,{attributeFilter: ['installation','loaded_icons','errordevices_data']});
const observer2 = new MutationObserver(function(mutationList,observer) {
mutationList.forEach((mutation) => {
if(mutation.type == 'childList' && mutation.addedNodes.length > 0) {
var errmsg = document.getElementById('errmsg');
//10:27:38.598 ERRMSG:Connection lost, trying a reconnect every 5 seconds.<
if(errmsg != null && errmsg.innerHTML == 'Connection lost, trying a reconnect every 5 seconds.') {
var lost = parseInt($('#hminfotools').attr('lost'));
if(HMinfoTools_debug) {log('HMinfoTools: ' + '"Connection lost" detected! ('+lost+')');}
if(lost > 5) {
if(HMinfoTools_debug) {log('HMinfoTools: ' + 'close and open informchannel');}
$('#hminfotools').attr('lost','0');
location.reload(true);
}
else {$('#hminfotools').attr('lost',lost+1);}
}
}
});
});
observer2.observe(document.body,{subtree: false,childList: true,attributes: false});
var info = document.createElement('span');
div.appendChild(info);
info.id = 'hminfo_info';
info.innerHTML = ' => waiting for problems...';
var table = document.createElement('table');
div.appendChild(table);
table.id = 'devicetable';
table.setAttribute('class','block wide internals');
table.style.backgroundColor = '#333333';
table.style.color = '#CCCCCC';
var thead = document.createElement('thead');
table.appendChild(thead);
thead.style.backgroundColor = '#111111';
var tr = document.createElement('tr');
thead.appendChild(tr);
var icons = document.createElement('td');
tr.appendChild(icons);
icons.style.whiteSpace = 'nowrap';
HMinfoTools_loadIcons(hminfo,icons); //################################################################
var td = document.createElement('td');
tr.appendChild(td);
var ios = document.createElement('span');
td.appendChild(ios);
ios.id = 'hminfo_ios';
var td = document.createElement('td');
tr.appendChild(td);
var left = document.createElement('td');
td.appendChild(left);
var change = document.createElement('span');
left.appendChild(change);
change.id = 'hminfo_change';
change.style.whiteSpace = 'nowrap';
change.innerHTML = lastChange;
var right = document.createElement('td');
td.appendChild(right);
right.align = 'right';
right.style.whiteSpace = 'nowrap';
var edit = document.createElement('span');
right.appendChild(edit);
edit.id = 'hminfo_edit';
edit.title = 'rssi overview';
edit.style.cursor = 'pointer';
edit.setAttribute('onclick','HMinfoTools_getAllRssiData()');
var cmd = "{FW_makeImage('rc_SETUP@white')}";
if(HMinfoTools_debug) {log('HMinfoTools: ' + cmd);}
var url = HMinfoTools_makeCommand(cmd);
$.ajax({
url: url,
type: "GET",
context: edit,
success: function(data){
if(data) {
this.innerHTML = data;
$('#' +this.id+ ' svg').css('height','20px');
$('#' +this.id+ ' svg').css('width','20px');
}
}
});
var allDev = document.createElement('span');
right.appendChild(allDev);
allDev.id = 'hminfo_allDev';
allDev.hidden = true;
var check = document.createElement('input');
allDev.appendChild(check);
check.id = 'hminfo_allDev_check';
check.type = 'checkbox';
check.checked = false;
check.style.margin = '5px 0px 0px 0px';
check.title = 'check => "attr ' +hminfo+' HMinfoTools_deviceMode all"';
check.style.cursor = 'pointer';
check.setAttribute('onclick','HMinfoTools_setAttrDeviceMode()');
var tbody = document.createElement('tbody');
table.appendChild(tbody);
tbody.id = 'hminfo_table_errDev';
$('#hminfotools').attr('installation','ready');
}
function HMinfoTools_setAttrDeviceMode() {
var hminfo = $('#hminfotools').attr('device');
var val = ($('#hminfotools').attr('device_mode') == 'all')? 'err': 'all';
var cmd = 'attr ' +hminfo+ ' HMinfoTools_deviceMode ' + val;
if(HMinfoTools_debug) {log('HMinfoTools: ' + cmd);}
var url = HMinfoTools_makeCommand(cmd);
$.get(url,function(data) {
if(data) {FW_okDialog(data);}
else {location.reload();}
});
}
function HMinfoTools_parseIOsFromHMinfo(ioInfoRaw) {
var vcculist = '';
var iolist = '';
var ioInfo = ioInfoRaw;
if(ioInfoRaw != null && !ioInfoRaw.match(/>/)) { //old (current) hminfo version
//iI_HM_IOdevices Initialized: cul868;disconnected: hmuart1;dummy: hmusb1;ok: hmlan1;
var ios = ioInfoRaw.match(/\s[^;]+/g);
ios.forEach(function(io,idx,arr) {arr[idx] = io.trim();});
iolist = ios.join(',');
ios = iolist.split(',');
ios.forEach(function(io) {
var color = (ioInfoRaw.match('(?:Initialized|ok):\\s[^;]*'+io+'[^;]*;'))? 'lime': 'red';
ioInfo = ioInfo.replace(io,'<a href="/fhem?detail='+io+'"><span style="color: '+color+';">'+io+'</span></a>');
});
}
else if(ioInfoRaw != null && ioInfoRaw.match(/>/)) { //new hminfo version
//iI_HM_IOdevices ccu>Initialized:cul868;ok:hmlan1,hmuart1; noVccu>dummy:hmusb2; vccu2>dummy:hmusb1;
var vccus = ioInfoRaw.match(/(?<=^|\s)[^>]+/g);
var tmpVccuRawArr = ioInfoRaw.split(' ');
tmpVccuRawArr.forEach(function(vccuStr) {
var vccu = vccuStr.match(/(?<=^|\s)[^>]+/g);
var vccuIOs = vccuStr.match(/(?<=:|,)[^,;]+/g);
if(vccu != 'noVccu') {
vcculist += (vcculist == '')? vccu+':'+vccuIOs.join(','): ' '+vccu+':'+vccuIOs.join(',');
}
});
var ios = ioInfoRaw.match(/(?<=:|,)[^,;]+/g);
iolist = ios.join(',');
vccus.forEach(function(vccu) {
var color = 'lightblue';
if(vccu == 'noVccu') {ioInfo = ioInfo.replace(vccu,'<span style="color: '+color+';">'+vccu+'</span>');}
else {ioInfo = ioInfo.replace(vccu,'<a href="/fhem?detail='+vccu+'"><span style="color: '+color+';">'+vccu+'</span></a>');}
});
ios.forEach(function(io) {
var color = (ioInfoRaw.match('(?:Initialized|ok):[^;]*'+io+'[^;]*;'))? 'lime': 'red';
ioInfo = ioInfo.replace(io,'<a href="/fhem?detail='+io+'"><span style="color: '+color+';">'+io+'</span></a>');
});
}
else {ioInfo = 'IO_Devices: Info_Unknown';} //from fhem-restart until first hminfo-update
$('#hminfotools').attr('vcculist',vcculist);
$('#hminfotools').attr('iolist',iolist);
document.getElementById('hminfo_ios').innerHTML = ioInfo;
}
function HMinfoTools_getInfoFromErrorDevices(idStr) {
var deviceList;
var isFirstRun = ($('#'+idStr).attr('errordevices_data') == 'start')? true: false;
if(isFirstRun) {
if(HMinfoTools_debug) {log('HMinfoTools: get data, 1. run');}
deviceList = document.getElementById(idStr).getAttribute('errordevices_list');
}
else {
if(HMinfoTools_debug) {log('HMinfoTools: get data, 2. run');}
deviceList = document.getElementById(idStr).getAttribute('errordevices_list').split(':')[1];
if(deviceList != '') {
devices = deviceList.split(',');
for(var d = 0; d < devices.length; ++d) {
HMinfoTools_initMapDevice(devices[d]);
var newObj = devMap.get(devices[d]);
newObj.parentDev = devices[d];
devMap.set(devices[d],newObj);
}
}
else {
$('#'+idStr).attr('errordevices_data','ready');
return;
}
}
//var ios = document.getElementById('hminfotools').getAttribute('iolist').split(',');
//var test2 = Array.from(devMap.values());
var iolist = document.getElementById(idStr).getAttribute('iolist');
var ios = iolist.split(',');
var cmd = 'list ' +deviceList+ ' i:DEF i:device ';
cmd += 'a:model ';
cmd += 'r:commState ';
cmd += 'r:sabotageAttack_ErrIoAttack_cnt ';
cmd += 'a:actCycle a:actStatus ';
cmd += 'r:sabotageError ';
cmd += 'i:IODev ';
for(var i = 0; i < ios.length; ++i) {cmd += 'i:rssi_at_' +ios[i]+ ' ';}
cmd += 'a:IOgrp ';
cmd += 'a:IODev ';
cmd += 'r:battery ';
cmd += 'r:motorErr ';
cmd += 'r:smoke_detect ';
cmd += 'r:cfgState ';
cmd += 'i:NAME';
if(HMinfoTools_debug) {log('HMinfoTools: ' + cmd);}
var url = HMinfoTools_makeCommand(cmd);
$.get(url,function(data) {
if(data != null) {
/*
HM_196BD8 DEF 196BD8
model HM-SEC-RHS
2021-03-17 18:10:43 commState Info_Cleared
2021-02-21 19:54:41 sabotageError on
IODev cul868
2021-02-21 19:54:41 battery ok
2021-03-18 20:14:41 cfgState PeerIncom,RegMiss
NAME HM_196BD8
*/
var informDevices = deviceList + ',';
var devObj = {};
var lines = data.split('\n');
for(var l = 0; l < lines.length; ++l) {
var deviceEnd = false;
var line = lines[l];
if(line.match(/\sDEF\s/)) {
var device = line.match(/^[^\s]+/)[0];
devObj = devMap.get(device);
devObj.name = device;
if(line.match(/[^\s]+$/)[0].length == 6) {devObj.parentDev = devObj.name;}
}
else if(line.match(/\sdevice\s/)) {devObj.parentDev = line.match(/[^\s]*$/)[0];}
else if(line.match(/\smodel\s/)) {devObj.model = line.match(/[^\s]*$/)[0];}
else if(line.match(/\scommState\s/)) {devObj.commState = line.match(/[^\s]*$/)[0];}
else if(line.match(/\ssabotageAttack_ErrIoAttack_cnt\s/)) {devObj.sabotageAttack = line.match(/[^\s]*$/)[0];}
else if(line.match(/\sactCycle\s/)) {devObj.actCycle = line.match(/[^\s]*$/)[0];}
else if(line.match(/\sactStatus\s/)) {devObj.actStatus = line.match(/[^\s]*$/)[0];}
else if(line.match(/\ssabotageError\s/)) {devObj.sabotageError = line.match(/[^\s]*$/)[0];}
else if(line.match(/\sIODev\s/)) {
if(devObj.IODev == '') {devObj.IODev = line.match(/[^\s]*$/)[0];}
else {devObj.aIODev = line.match(/[^\s]*$/)[0];}
}
else if(line.match(/\sIOgrp\s/)) {devObj.IOgrp = line.match(/[^\s]*$/)[0];}
else if(line.match('\\srssi_at_' +devObj.IODev+ '\\s')) {devObj.rssi = line.match(/cnt:.+$/)[0];}
else if(line.match(/\sbattery\s/)) {devObj.battery = line.match(/[^\s]*$/)[0];}
// 2021-01-06 14:42:48 motorErr adjusting range too small //err: parse only "small"
else if(line.match(/\smotorErr\s/)) {devObj.motorErr = line.match(/[^\s]*$/)[0];}
else if(line.match(/\ssmoke_detect\s/)) {devObj.smokeDetect = line.match(/[^\s]*$/)[0];}
else if(line.match(/\scfgState\s/)) {devObj.cfgState = line.match(/[^\s]*$/)[0];}
else if(line.match(/\sNAME\s/)) {deviceEnd = true;}
if(deviceEnd) { //save and check info from device
if(devObj.parentDev != devObj.name) { //current device is channelDevice
if(informDevices.match(devObj.parentDev + ',') == null) {
informDevices += devObj.parentDev +',';
}
}
else { //current device is parentDevice
if(devObj.commState == '') {devObj.commState = 'Info_Unknown';}
if(devObj.actCycle != '') {
if(devObj.actCycle == '000:00') {devObj.activity = 'switchedOff';}
else {devObj.activity = ((devObj.actStatus != '')? devObj.actStatus: 'unknown');}
}
else {devObj.activity = 'unused';}
if(devObj.IODev == '' || devObj.IODev.match(/^helper=HASH\(/)) {devObj.IODev = 'missing_IODev';}
devObj.rssi = 'rssi_at_'+devObj.IODev+' => ' + ((devObj.rssi == '')? 'missing_rssi': devObj.rssi);
if(devObj.aIODev == '') {devObj.aIODev = 'missing_aIODev';}
if(devObj.IOgrp == '') {devObj.IOgrp = 'missing_IOgrp';}
}
if(devObj.model == '') {devObj.model = 'missing_model';}
if(devObj.cfgState == '') {devObj.cfgState = 'Info_Unknown';}
devMap.set(devObj.name,devObj);
}
}
if(isFirstRun) {
$('#'+idStr).attr('errordevices_data','first');
informDevices = informDevices.replace(/,$/,'');
informDevices = (informDevices == deviceList)? '': informDevices.replace(deviceList+',','');
$('#'+idStr).attr('errordevices_list',deviceList +':'+ informDevices);
}
else {$('#'+idStr).attr('errordevices_data','ready');}
}
});
}
function HMinfoTools_changeInformChannel(informDevices) {
if($('#hminfotools').attr('device') != null) {
informDevices = $('#hminfotools').attr('device')+((informDevices == '')? '': ',' + informDevices);
}
var weblinkdiv = document.getElementById('hminfotools_weblink');
if(weblinkdiv != null) { //other devices on a room-site
//SB_PLAYER_0004201e98ec
//SB_PLAYER_0004201e98ec-volume
var roomDevices = '';
$("[informid]").each(function() {
var inform = this.getAttribute('informid');
if(!inform.match(/-/) && !roomDevices.match(inform + ',')) {roomDevices += inform + ',';}
});
roomDevices = roomDevices.replace(/,$/,'');
informDevices += ((roomDevices == '')? '': ',' + roomDevices);
}
document.body.setAttribute('longpollfilter',informDevices);
FW_closeConn();
setTimeout(FW_longpoll,300); // forum # 112181
}
//###### icons,longpoll #######################################################################################
function HMinfoTools_UpdateLine(d) {
if(document.getElementById('hminfotools') == null && document.getElementById('HMdeviceTools_toolsTable') == null) {return;}
if(d[0].match(/-commState$/)) {
var evtDevice = d[0].match(/^[^-]+/)[0];
$("[id^='icon_commState_'][pollid='" +evtDevice+ "']").each(function() {
var errDevice = this.id.replace(/icon_commState_/,'');
HMinfoTools_setIconFromCommState(errDevice,d[1]);
});
return;
}
if(d[0].match(/-Activity$/)) {
var evtDevice = d[0].match(/^[^-]+/)[0];
$("[id^='icon_Activity_'][pollid='" +evtDevice+ "']").each(function() {
var errDevice = this.id.replace(/icon_Activity_/,'');
HMinfoTools_setIconFromActivity(errDevice,d[1]);
});
return;
}
if(d[0].match(/-rssi_at_/)) {
var evtDevice = d[0].match(/^[^-]+/)[0];
$("[id^='icon_rssi_'][pollid='" +evtDevice+ "']").each(function() {
var errDevice = this.id.replace(/icon_rssi_/,'');