-
Notifications
You must be signed in to change notification settings - Fork 2
/
Activity_Monitor.groovy
3002 lines (2652 loc) · 205 KB
/
Activity_Monitor.groovy
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
/** Authors Notes:
* For more information on Activity Monitor & Attribute Monitor check out these resources.
* Original posting on Hubitat Community forum: https://community.hubitat.com/t/release-tile-builder-build-beautiful-dashboards/118822
* Tile Builder Documentation: https://github.com/GaryMilne/Hubitat-TileBuilder/blob/main/Tile%20Builder%20Help.pdf
*
* Copyright 2022 Gary J. Milne
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
* License:
* You are free to use this software in an un-modified form. Software cannot be modified or redistributed.
* You may use the code for educational purposes or for use within other applications as long as they are unrelated to the
* production of tabular data in HTML form, unless you have the prior consent of the author.
* You are granted a license to use Tile Builder in its standard configuration without limits.
* Use of Tile Builder in it's Advanced requires a license key that must be issued to you by the original developer. [email protected]
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* CHANGELOG
* Version 1.0.0 - Internal
* Version 1.0.1 - Cleaned up some UI pieces. Removed tile1 as the default when publishing so that it is a conscious choice to avoid overrides.
* Version 1.0.2 - Fixed bug with 'No Selection' in UI. Changed logic to handle 0 rows in table.
* Version 1.0.3 - Allows 'Tables' with only a title for use as a placeholder on the Dashboard.
* Version 1.0.4 - Added logic to hide\show publishing buttons based on required fields.
* Version 1.0.5 - Consolidate Attribute Monitor and Activity Monitor into unified code.
* Version 1.0.6 - Added removal of all items with opacity=0 from the final HTML.
* Version 1.0.7 - Added custom size option for preview window.
* Version 1.0.8 - Added append option on overrides. Added extra options to sample overrides.
* Version 1.0.9 - Fixed issue with importing of overrides string.
* Version 1.1.0 - Added %count% as a macro for number of displayed records. Useful for scrolling windows or null results.
* Version 1.1.1 - Added tags for #high1# and #high2# for modifying highlight classes. Provides an alternate method of formatting a result vs using a class.
* Version 1.1.2 - Added filtering ability for integer and float values. Made filtering an advanced feature.
* Version 1.1.3 - Added ability to merge Column header fields.
* Version 1.1.4 - Fixed bug with display of floating point numbers when filtering is enabled.
* Version 1.2.0 - Cleaned up a variety of message text. Version revved to match other components and Help file for first public release.
* Version 1.2.1 - Minor bug fix relating to the handling of Units
* Version 1.2.2 - Roughed in File Support
* Version 1.2.3 - Convert Overrides from string to textarea.
* Version 1.2.4 - Update screen handling for > 1024. Eliminate #pre# and #post#, add animation examples to overrides helper.
* Version 1.2.5 - Splits Overrides Helper examples into categories for easier navigation.
* Version 1.2.6 - Expanded Keywords and Thresholds to 5 values. Added 'isCompactDisplay' to free up some screen space.
* Version 1.2.7 - Fixed bug in applyStyle not handling "textArea" data type introduced in 1.2.3
* Version 1.2.8 - Cleaned up handling of some style settings.
* Version 1.3.0 - Multiple updates and fixes. Implements %value% macro, use search and replace strings vs just strip strings. Added button type to Activity Monitor list, added valve, healthStatus and variable types, added padding to floats, \
* reduced floating point options to 0 or 1. Added opacity option to table background. Converted Thresholds to use numbered comparators. Changed storage of #top variables. Implemented supportFunction for child recovery.
* Version 1.3.1 - Added null checking to multiple lines to correct app errors, especially when picking "No Selection" which returns null. Fixed bug with substituting values for fields #22 and #27. Fixed bug when subscribing to camelCase attributes.
* Version 1.4.0 - Added improvements first introduced in Multi-Attribute Monitor such as Attribute and Color compression. Added %time1% and %time2% for proper 24hr and 12hr times. Added selector for Device Naming. Added attribute "level". Updated Threshold operators and variables from using numbers 1-5 to 6-10.
* Version 1.4.1 - Bugfix: Make sure that the eventTimeout variable has a value if detected as null.
* Version 1.4.2 - Bugfix: Units were not displaying when selected.
* Version 1.4.3 - Cosmetic Changes to the Menu Bar and Title. Adds a counter to a comment field for results > 1024 which ensures that every update is unique and causes the file to be reloaded in the Dashboard on any change. Added Character Replacement capability.
* Version 1.4.4 - Bugfix: Added ternary operators in highlightValue for float values that come back as null because the attribute is not populated.
* Version 1.4.5 - Bugfix: Incorrect Module Name
* Version 1.4.6 - Bugfix: Correct issue with logic in highlightValue related to use of Ternary operators (introduced v1.4.4). Corrected issue with duplicate units under some conditions.
* Version 1.4.7 - Added Minimum Republish interval as introduced in Grid 1.0. Only applies to Attribute Monitor.
* Version 1.4.8 - Bugfix: Corrected issue with newly initialised variables.
* Version 1.4.9 - Bugfix: Improved handling of the lastPublished info and checking. Better null handling for input controls.
* Version 1.5.0 - Bugfix: Added error handling when the device has a Null value for a monitored attribute.
* Version 1.5.1 - Feature: Expanded the Device Name Modification from 3 to 5 values. - No External Release
* Version 1.5.2 - Feature: Added Cloud Endpoints as a publishing option for output > 1,024 bytes.
* Version 1.5.3 - Bugfix: Handle errors that are caused by OAuth not being enabled on the app. Cloud Endpoints only active as needed.
*
* Gary Milne - July 15th, 2024
*
* This code is Activity Monitor and Attribute Monitor combined.
* The personality is dictated by @Field static moduleName a few lines ahead of this.
* You must comment out the moduleName line that does not apply.
* You must also comment out the 3 lines in the definition that do not apply.
* That is all that needs to be done.
*
**/
import groovy.transform.Field
//These are supported capabilities. Layout is "device.selector":"attribute". Keeping them in 3 separate maps makes it more readable and easier to identify the sort criteria.
@Field static final capabilitiesInteger = ["airQuality":"airQualityIndex", "battery":"battery", "colorTemperature":"colorTemperature","illuminanceMeasurement":"illuminance", "signalStrength":"rssi", "switchLevel":"level"]
@Field static final capabilitiesString = ["*":"variable","carbonDioxideDetector":"carbonMonoxide", "contactSensor":"contact", "healthCheck":"healthStatus", "lock":"lock", "motionSensor":"motion", "presenceSensor":"presence", "smokeDetector":"smoke", "switch":"switch", "valve":"valve", "waterSensor":"water", "windowBlind":"windowBlind"]
//The first field has to be unique so we append the capability with a number so that all of the entries appear in the list even when the capability is really the same. Without this we can only use "*" once.
//These three are used by Zigbee Monitor Driver.
@Field static final capabilitiesCustom = ["signalStrength1":"deviceNeighbors", "signalStrength2":"deviceRepeaters", "signalStrength3":"deviceRoutes", "signalStrength4":"deviceChildren", "signalStrength5":"deviceChildCount", "signalStrength6":"deviceRouteCount", "signalStrength7":"deviceRepeaterCount"]
@Field static final capabilitiesFloat = ["currentMeter": "amperage", "energyMeter":"energy", "powerMeter":"power", "relativeHumidityMeasurement":"humidity", "temperatureMeasurement":"temperature","voltageMeasurement":"voltage"]
//These are unknown as to whether they report integer or float values.
//capabilitiesUnknown = [" "carbonDioxideMeasurement":"carbonDioxide","pressureMeasurement":"pressure","relativeHumidityMeasurement":"humidity", "ultravioletIndex":"ultravioletIndex"]
//Cloud Endpoint Mapping
mappings { path("/tb") { action: [GET: "getTile"] } }
@Field static final codeDescription = "<b>Tile Builder Activity Monitor v1.5.3 (7/15/24)</b>"
@Field static final codeVersion = 153
@Field static final moduleName = "Activity Monitor"
//@Field static final moduleName = "Attribute Monitor"
definition(
name: "Tile Builder - Activity Monitor",
description: "Monitors a list of devices to look for those that are inactive\\overactive and may need attention. Publishes an HTML table of results for a quick and attractive display in the Hubitat Dashboard environment.",
importUrl: "https://raw.githubusercontent.com/GaryMilne/Hubitat-TileBuilder/main/Activity_Monitor.groovy",
//name: "Tile Builder - Attribute Monitor",
//description: "Monitors a single attribute for a list of devices. Publishes an HTML table of results for a quick and attractive display in the Hubitat Dashboard environment.",
//importUrl: "https://raw.githubusercontent.com/GaryMilne/Hubitat-TileBuilder/main/Attribute_Monitor.groovy",
namespace: "garyjmilne",
author: "Gary J. Milne",
category: "Utilities",
iconUrl: "",
iconX2Url: "",
iconX3Url: "",
singleThreaded: true,
parent: "garyjmilne:Tile Builder",
installOnOpen: true
)
preferences {
page(name: "mainPage")
if (moduleName == "Activity Monitor") page (name: "devicePage")
}
def mainPage() {
//Basic initialization for the initial release
if (state.initialized == null ) initialize()
//Handles the initialization of new variables added after the original release.
if (state.variablesVersion == null || state.variablesVersion < codeVersion) updateVariables()
//Checks for critical Null values that can be introduced by the user by clicking "No Selection" in an enum dialog.
checkNulls()
//Checks to see if there are any messages for this child app. This is used to recover broken child apps from certain error conditions
//Although this function is complete I'm leaving it dormant for the present release - 1.4.0
myMessage = parent.messageForTile( app.label )
if ( myMessage != "" ) supportFunction ( myMessage )
if (moduleName == "Attribute Monitor") {
//See if the user has selected a different capability. If so a flag is set and the device list is cleared on the refresh.
isMyCapabilityChanged()
}
refreshTable()
refreshUIbefore()
def pageTitle = (parent.checkLicense() == true) ? moduleName + " - Advanced" : moduleName + " - Standard";
dynamicPage(name: "mainPage", title: titleise("<center><h2>$pageTitle</h2></center>"), uninstall: true, install: true, singleThreaded:true) {
//paragraph buttonLink ("test", "test", 0)
section{
if (state.show.Devices == true) {
//paragraph buttonLink ("test", "test", 0) //Used for temporary testing.
if (moduleName == "Attribute Monitor"){
input(name: 'btnShowDevices', type: 'button', title: 'Select Device and Attributes ▼', backgroundColor: 'navy', textColor: 'white', submitOnChange: true, width: 3, newLineAfter: true) //▼ ◀ ▶ ▲
capabilities = capabilitiesInteger.clone() + capabilitiesString.clone() + capabilitiesFloat.clone() + capabilitiesCustom.clone()
newCapabilityString = ""
//This input device list the items by attribute name but actually returns the capability.
input (name: "myCapability", title: "<b>Select the Attribute to Monitor</b>", type: "enum", options: capabilities.sort{it.value} , submitOnChange:true, width:3, defaultValue: 1)
//Retreive the attribute type and save it to state.
state.myAttribute = capabilities.get(myCapability)
//If the capability is found in list1 it must be numeric. We use the flag for logic control later when Thresholds are implemented.
if (isLogInfo) log.info ("myCapability is: $myCapability and state.myAttribute is: $state.myAttribute")
if (capabilitiesInteger.get(myCapability) != null) state.attributeType = "Integer"
if (capabilitiesFloat.get(myCapability) != null) state.attributeType = "Float"
if (capabilitiesString.get(myCapability) != null) state.attributeType = "String"
// Check if the last character is a digit. If it is then remove it.
if (myCapability && myCapability[-1] =~ /\d/) { newCapabilityString = myCapability[0..-2] }
else newCapabilityString = myCapability
input "myDeviceList", "capability.$newCapabilityString", title: "<b>Select Devices to Monitor</b>" , multiple: true, required: false, submitOnChange: true, width: 4
}
if (moduleName == "Activity Monitor"){
input(name: 'btnShowDevices', type: 'button', title: 'Select Attribute and Devices ▼', backgroundColor: 'navy', textColor: 'white', submitOnChange: true, width: 3, newLineAfter: true) //▼ ◀ ▶ ▲
input (name: "useList", title: "<b>Use List</b>", type: "enum", options: [1:"All Devices", 2:"Battery Devices", 3:"Motion Devices", 4:"Presence Sensors", 5:"Switches", 6:"Contact Sensors", 7:"Temperature Sensors", 8:"Buttons"], required:true, state: selectOk?.devicePage ? "complete" : null, submitOnChange:true, width:2, defaultValue: 1)
if (useList == "1" ) input "devices1", "capability.*", title: "All Devices to be monitored" , multiple: true, required: false, defaultValue: null, width: 6
if (useList == "2" ) input "devices2", "capability.battery", title: "Battery Devices to be Monitored" , multiple: true, required: false, defaultValue: null, width: 6
if (useList == "3" ) input "devices3", "capability.motionSensor", title: "Motion Detectors to be Monitored" , multiple: true, required: false, defaultValue: null, width: 6
if (useList == "4" ) input "devices4", "capability.presenceSensor", title: "Presence Sensors to be Monitored" , multiple: true, required: false, defaultValue: null, width: 6
if (useList == "5" ) input "devices5", "capability.switch", title: "Switches to be Monitored" , multiple: true, required: false, defaultValue: null, width: 6
if (useList == "6" ) input "devices6", "capability.contactSensor", title: "Contacts to be monitored" , multiple: true, required: false, defaultValue: null, width: 6
if (useList == "7" ) input "devices7", "capability.temperatureMeasurement", title: "Temperature Sensors to be monitored" , multiple: true, required: false, defaultValue: null, width: 6
if (useList == "8" ) input "devices8", "capability.button", title: "Buttons to be monitored" , multiple: true, required: false, defaultValue: null, width: 6
if (isLogInfo) log.info ("devicePage: useList is:*${useList}*")
}
}
else input(name: 'btnShowDevices', type: 'button', title: 'Select Attribute and Devices ▶', backgroundColor: 'dodgerBlue', textColor: 'white', submitOnChange: true, width: 3) //▼ ◀ ▶ ▲
paragraph line(2)
if (state.show.Report == true) {
input(name: 'btnShowReport', type: 'button', title: 'Select Report Options ▼', backgroundColor: 'navy', textColor: 'white', submitOnChange: true, width: 3, newLineAfter: true) //▼ ◀ ▶ ▲
if (moduleName == "Activity Monitor") input (name: "inactivityThreshold", title: "<b>Inactivity threshold</b>", type: "enum", options: parent.inactivityTime(), submitOnChange:true, width:2, defaultValue: 24)
input (name: "myDeviceLimit", title: "<b>Device Limit Threshold</b>", type: "enum", options: parent.deviceLimit(), submitOnChange:true, width:2, defaultValue: 20)
input (name: "myDeviceNaming", title: "<b>Device Naming Scheme</b>", type: "enum", options: ['Use Device Name', 'Use Device Label'], submitOnChange:true, width:2, defaultValue: "Use Device Label", newLine:false)
input (name: "myTruncateLength", title: "<b>Truncate Device Name</b>", type: "enum", options: parent.truncateLength(), submitOnChange:true, width:2, defaultValue: 20)
input (name: "mySortOrder", title: "<b>Sort Order</b>", type: "enum", options: sortOrder(), submitOnChange:true, width:2, defaultValue: 1 ) //Sort alphabetically by device name
if (moduleName == "Attribute Monitor") input (name: "myDecimalPlaces", title: "<b>Decimal Places</b>", type: "enum", options: [0,1], submitOnChange:true, width:2, defaultValue: 1)
if (moduleName == "Attribute Monitor") input (name: "myUnits", title: "<b>Units</b>", type: "enum", options: parent.unitsMap() , submitOnChange:true, width:2, defaultValue: "None")
input (name: "isShowDeviceNameModification", type: "bool", title: "<b>Show Device Name Modification</b>", required: false, multiple: false, defaultValue: false, submitOnChange: true, width: 3, newLine:true )
input (name: "isAbbreviations", type: "bool", title: "<b>Use Abbreviations in Device Names</b>", required: false, multiple: false, defaultValue: false, submitOnChange: true, width: 3 )
if (isShowDeviceNameModification == true) {
input (name: "mySearchText1", title: "<b>Search Device Text #1</b>", type: "string", submitOnChange:true, width:2, defaultValue: "?", newLine:true)
input (name: "myReplaceText1", title: "<b>Replace Device Text #1</b>", type: "string", submitOnChange:true, width:2, defaultValue: "")
input (name: "mySearchText2", title: "<b>Search Device Text #2</b>", type: "string", submitOnChange:true, width:2, defaultValue: "?", newLine:true)
input (name: "myReplaceText2", title: "<b>Replace Device Text #2</b>", type: "string", submitOnChange:true, width:2, defaultValue: "")
input (name: "mySearchText3", title: "<b>Search Device Text #3</b>", type: "string", submitOnChange:true, width:2, defaultValue: "?", newLine:true)
input (name: "myReplaceText3", title: "<b>Replace Device Text #3</b>", type: "string", submitOnChange:true, width:2, defaultValue: "")
input (name: "mySearchText4", title: "<b>Search Device Text #4</b>", type: "string", submitOnChange:true, width:2, defaultValue: "?", newLine:true)
input (name: "myReplaceText4", title: "<b>Replace Device Text #4</b>", type: "string", submitOnChange:true, width:2, defaultValue: "")
input (name: "mySearchText5", title: "<b>Search Device Text #5</b>", type: "string", submitOnChange:true, width:2, defaultValue: "?", newLine:true)
input (name: "myReplaceText5", title: "<b>Replace Device Text #5</b>", type: "string", submitOnChange:true, width:2, defaultValue: "")
}
if (moduleName == "Activity Monitor") myText = "<b>Inactivity Threshold:</b> Only devices without activity since the threshold are eligible to be reported on. Using an inactivity time of 0 can be used to generate a most recently active list.<br>"
if (moduleName == "Attribute Monitor") myText = ""
myText += "<b>Device Threshold Limit:</b> This limits the maximum number of devices that can appear in the table. The actual number of devices may be less depending on other parameters. Lowering the number of devices is one way to reduce the size of the table but usually less effective " +\
"than eliminating some of the formatting elements available in the table customization options.<br>"
myText += "<b>Truncate Device Name:</b> This can shorten the name of the device to improve table formatting as well as reduce the size of the overall data.<br>"
myText += "<b>Sort Order:</b> Changes the sort order of the results allowing the creation of reports that show most active devices as well as least active. Longest inactivity would be good for detecting down devices, perhaps with failed batteries. Shortest inactivity would be useful for " +\
"activity monitoring such as contacts, motion sensors or switches.<br>"
myText += "<b>Decimal Places:</b> Allows you to format floating point data. Saves space and has neater presentation. This value does not affect any of the comparisons performed in filtering or highlighting.<br>"
myText += "<b>Units:</b> You can append units to the data in the table. Unit options with a leading '_' places a space between the numeric value and the unit.<br>"
myText += "<b>Replace Device Text:</b> Allows you to strip\\replace unwanted strings from the device name, such as ' on Office' for meshed hubs or a ' -' after truncating at the second space for a hyphenated name."
paragraph summary("Report Notes", myText)
}
else input(name: 'btnShowReport', type: 'button', title: 'Select Report Options ▶', backgroundColor: 'dodgerBlue', textColor: 'white', submitOnChange: true, width: 3) //▼ ◀ ▶ ▲
paragraph line(2)
//Filter Results based on value
if (moduleName == "Attribute Monitor" && parent.checkLicense() == true) {
if (state.show.Filter == true) {
input(name: 'btnShowFilter', type: 'button', title: 'Select Filter Options ▼', backgroundColor: 'navy', textColor: 'white', submitOnChange: true, width: 3, newLineAfter: true) //▼ ◀ ▶ ▲
input (name: "myFilterType", title: "<b>Filter Type</b>", type: "enum", options: parent.filterList(), submitOnChange:true, width:2, defaultValue: 0, newLine:false)
if (myFilterType != null && myFilterType.toInteger() >= 1 ) input (name: "myFilterText", title: "<b>Enter Comparison Value</b>", type: "string", submitOnChange:true, width:3, defaultValue: "")
paragraph summary("Filter Notes", parent.filterNotes() )
}
else input(name: 'btnShowFilter', type: 'button', title: 'Select Filter Options ▶', backgroundColor: 'dodgerBlue', textColor: 'white', submitOnChange: true, width: 3) //▼ ◀ ▶ ▲
paragraph line(2)
}
//Section for customization of the table.
if (state.show.Design == true) {
input (name: 'btnShowDesign', type: 'button', title: 'Design Table ▼', backgroundColor: 'navy', textColor: 'white', submitOnChange: true, width: 3, newLine: true, newLineAfter: true) //▼ ◀ ▶ ▲
//input (name: "Refresh", type: "button", title: "<big>🔄 Refresh Table 🔄</big>", backgroundColor: "#27ae61", textColor: "white", submitOnChange: true, width: 2)
input (name: "Refresh", type: "button", title: "Refresh Table", backgroundColor: "#27ae61", textColor: "white", submitOnChange: true, width: 2)
input (name: "isCustomize", type: "bool", title: "Customize Table", required: false, multiple: false, defaultValue: false, submitOnChange: true, width: 2 )
if (isCustomize == true){
//Allows the user to remove informational lines.
input (name: "isCompactDisplay", type: "bool", title: "Compact Display", required: false, multiple: false, defaultValue: false, submitOnChange: true, width: 2 )
//Set the default advancedStyle to be disabled (non-activated) and overwrite it if the app is activated.
advancedStyle = "<td style='background-color:#CCCCCC;pointer-events:none !important' .td:hover{box-shadow: 0 5px 0 0 gray !important;padding:0px}>"
if (parent.checkLicense() == true ) advancedStyle = "<td>"
//Setup the Table Style
paragraph "<style>#buttons {font-family: Arial, Helvetica, sans-serif;width:100%;text-align:'Center'} #buttons td,tr {background:#00a2ed;color:#FFFFFF;text-align:Center;opacity:0.75;padding: 8px} #buttons td:hover {background: #27ae61;opacity:1}</style>"
part1 = "<table id='buttons'><td>" + buttonLink ('General', 'General', 1) + "</td><td>" + buttonLink ('Title', 'Title', 2) + "</td><td>" + buttonLink ('Headers', 'Headers', 3) + "</td>"
part2 = "<td>" + buttonLink ('Borders', 'Borders', 4) + "</td><td>" + buttonLink ('Rows', 'Rows', 5) + "</td><td>" + buttonLink ('Footer', 'Footer', 6) + "</td>"
//These Tabs may be Enabled or Disabled depending on the Activation Status.
if (moduleName == "Attribute Monitor") part3 = advancedStyle + buttonLink ('Highlights', 'Highlights', 7) + "</td>" + advancedStyle + buttonLink ('Styles', 'Styles', 8) + "</td>" + advancedStyle + buttonLink ('Advanced', 'Advanced', 9) + "</td>"
if (moduleName == "Activity Monitor") part3 = advancedStyle + buttonLink ('Styles', 'Styles', 8) + "</td>" + advancedStyle + buttonLink ('Advanced', 'Advanced', 9) + "</td>"
table = part1 + part2 + part3 + "</table>"
if (isCompactDisplay == false) paragraph titleise("Select a Section to Customize")
paragraph table
//General Properties
if (activeButton == 1){
if (isCompactDisplay == false) paragraph titleise("General Properties")
input (name: "tw", type: "enum", title: bold("Width %"), options: parent.tableSize(), required: false, defaultValue: "90", submitOnChange: true, width: 2)
input (name: "th", type: "enum", title: bold("Height %"), options: parent.tableSize(), required: false, defaultValue: "Auto", submitOnChange: true, width: 2)
input (name: "tbc", type: "color", title: bold2("Table Background Color", tbc), required:false, defaultValue: "#ffffff", width:2, submitOnChange: true)
input (name: "tbo", type: "enum", title: bold("Table Background Opacity"), options: parent.opacity(), required: false, defaultValue: "1", submitOnChange: true, width: 2)
input (name: "tff", type: "enum", title: bold("Font"), options: parent.fontFamily(), required: false, defaultValue: "Roboto", submitOnChange: true, width: 2, newLineAfter: true)
input (name: "bm", type: "enum", title: bold("Border Mode"), options: parent.tableStyle(), required: false, defaultValue: "Collapse", submitOnChange: true, width: 2)
input (name: "bfs", type: "enum", title: bold("Base Font Size"), options: parent.baseFontSize(), required: false, defaultValue: "18", submitOnChange: true, width: 2)
input (name: "isComment", type: "bool", title: "<b>Add comment?</b>", required: false, multiple: false, defaultValue: false, submitOnChange: true, width: 2)
if (isComment == true){
input (name: "comment", type: "text", title: bold("Comment"), required: false, defaultValue: "?", width:4, submitOnChange: true)
}
input (name: "isFrame", type: "bool", title: bold("Add Frame"), required: false, multiple: false, defaultValue: false, submitOnChange: true, width: 2, newLine: false)
if (isFrame == true){
input (name: "fbc", type: "color", title: bold2("Frame Color", fbc), required: false, defaultValue: "#90C226", submitOnChange: true, width: 3, newLine: false)
}
input (name: "tilePreview", type: "enum", title: bold("Select Tile Preview Size"), options: parent.tilePreviewList(), required: false, defaultValue: 2, submitOnChange: true, width: 3, newLine: true)
input (name: "isCustomSize", type: "bool", title: "<b>Use Custom Preview Size?</b>", required: false, multiple: false, defaultValue: false, submitOnChange: true, width: 2)
if (isCustomSize == true){
input (name: "customWidth", type: "text", title: bold("Tile Width"), required:false, defaultValue: "200", submitOnChange: true, width: 1)
input (name: "customHeight", type: "text", title: bold("Tile Height"), required:false, defaultValue: "190", submitOnChange: true, width: 1)
}
input (name: "iFrameColor", type: "color", title: bold2("Dashboard Color", iFrameColor ), required: false, defaultValue: "#000000", submitOnChange: true, width: 3)
if (isCompactDisplay == false) {
paragraph line(1)
paragraph summary("General Notes", parent.generalNotes() )
}
}
//Title Properties
if (activeButton == 2){
if (isCompactDisplay == false) paragraph titleise("Title Properties")
input (name: "isTitle", type: "bool", title: "<b>Display Title?</b>", required: false, multiple: false, defaultValue: false, submitOnChange: true, width: 2)
if (isTitle == true){
input (name: "tt", title: "<b>Title Text</b>", type: "string", required:false, defaultValue: "Inactive Devices", width:3, submitOnChange: true, newLine: true)
input (name: "ts", type: "enum", title: bold("Text Size %"), options: parent.textScale(), required: false, defaultValue: "150", width:2, submitOnChange: true)
input (name: "ta", type: "enum", title: bold("Alignment"), options: parent.textAlignment(), required: false, defaultValue: "Center", width:2, submitOnChange: true, newLineAfter: true)
input (name: "tc", type: "color", title: bold2("Text Color", tc), required:false, defaultValue: "#000000", width:3, submitOnChange: true)
input (name: "to", type: "enum", title: bold("Text Opacity"), options: parent.opacity(), required: false, defaultValue: "1", submitOnChange: true, width: 2)
input (name: "tp", type: "enum", title: bold("Text Padding"), options: parent.elementSize(), required: false, defaultValue: "0", width:2, submitOnChange: true, newLineAfter:true)
input (name: "isTitleShadow", type: "bool", title: "<b>Add Shadow Text?</b>", required: false, multiple: false, defaultValue: false, submitOnChange: true, width: 2)
if (isTitleShadow == true){
input (name: "shcolor", type: "color", title: bold2("Shadow Color", shcolor), required:false, defaultValue: "#FF0000", width:3, submitOnChange: true)
input (name: "shhor", type: "enum", title: bold("Hor Offset"), options: parent.pixels(), required: false, defaultValue: "5", width:2, submitOnChange: true)
input (name: "shver", type: "enum", title: bold("Ver Offset"), options: parent.pixels(), required:false, defaultValue: "5", width:2, submitOnChange: true)
input (name: "shblur", type: "enum", title: bold("Blur"), options: parent.borderRadius(), required: false, defaultValue: "5", width:2, submitOnChange: true)
}
}
if (isCompactDisplay == false) {
paragraph line(1)
paragraph summary("Title Notes", parent.titleNotes() )
}
}
//Header Properties
if (activeButton == 3){
if (isCompactDisplay == false) paragraph titleise("Header Properties")
input (name: "isHeaders", type: "bool", title: "<b>Display Headers?</b>", required: false, multiple: false, defaultValue: false, submitOnChange: true, width: 2)
if (isHeaders == true ){
//Manage the UI if the headers are merged.
input (name: "isMergeHeaders", type: "bool", title: "<b>Merge Headers?</b>", required: false, multiple: false, defaultValue: false, submitOnChange: true, width: 2, newLineAfter:true)
if (isMergeHeaders == true) {
input (name: "A0", type: "text", title: bold("Heading 1"), required:false, defaultValue: "Device", submitOnChange: true, width: 4)
}
else {
input (name: "A0", type: "text", title: bold("Heading 1"), required:false, defaultValue: "Device", submitOnChange: true, width: 2)
input (name: "B0", type: "text", title: bold("Heading 2"), required:false, defaultValue: "State", submitOnChange: true, width: 2)
}
input (name: "hts", type: "enum", title: bold("Text Size %"), options: parent.textScale(), required: false, defaultValue: "125", submitOnChange: true, width: 2)
input (name: "hta", type: "enum", title: bold("Alignment"), options: parent.textAlignment(), required: false, defaultValue: 2, submitOnChange: true, width: 2)
input (name: "htc", type: "color", title: bold2("Text Color", htc), required: false, defaultValue: "#000000", submitOnChange: true, width: 3)
input (name: "hto", type: "enum", title: bold("Text Opacity"), options: parent.opacity(), required: false, defaultValue: "1", submitOnChange: true, width: 2, newLine: true)
input (name: "hp", type: "enum", title: bold("Text Padding"), options: parent.elementSize(), required: false, defaultValue: "0", submitOnChange: true, width: 2)
input (name: "hbc", type: "color", title: bold2("Background Color", hbc), required: false, defaultValue: "#90C226", submitOnChange: true, width: 3)
input (name: "hbo", type: "enum", title: bold("Background Opacity"), options: parent.opacity(), required: false, defaultValue: "1", submitOnChange: true, width: 2)
}
if (isCompactDisplay == false) {
paragraph line(1)
paragraph summary("Header Notes", parent.headerNotes() )
}
}
//Border Properties
if (activeButton == 4){
if (isCompactDisplay == false) paragraph titleise("Border Properties")
input (name: "isBorder", type: "bool", title: "<b>Display Borders?</b>", required: false, multiple: false, defaultValue: true, submitOnChange: true, width: 2, newLineAfter:true)
if (isBorder == true ){
input (name: "bs", type: "enum", title: bold("Style"), options: parent.borderStyle(), required: false, defaultValue: "Solid", submitOnChange: true, width: 2)
input (name: "bw", type: "enum", title: bold("Width"), options: parent.elementSize(), required: false, defaultValue: 2, submitOnChange: true, width: 2)
input (name: "bc", type: "color", title: bold2("Border Color", bc), required: false, defaultValue: "#000000", submitOnChange: true, width: 3)
input (name: "bo", type: "enum", title: bold("Opacity"), options: parent.opacity(), required: false, defaultValue: "1", submitOnChange: true, width: 2, newLine:true)
input (name: "br", type: "enum", title: bold("Radius"), options: parent.borderRadius(), required: false, defaultValue: "0", submitOnChange: true, width: 2)
input (name: "bp", type: "enum", title: bold("Padding"), options: parent.elementSize(), required: false, defaultValue: "0", submitOnChange: true, width: 2)
}
if (isCompactDisplay == false) {
paragraph line(1)
paragraph summary("Border Notes", parent.borderNotes() )
}
}
//Row Properties
if (activeButton == 5){
if (isCompactDisplay == false) paragraph titleise("Data Row Properties")
input (name: "rts", type: "enum", title: bold("Text Size %"), options: parent.textScale(), required: false, defaultValue: "100", submitOnChange: true, width: 2)
input (name: "rta", type: "enum", title: bold("Alignment"), options: parent.textAlignment(), required: false, defaultValue: 15, submitOnChange: true, width: 2)
input (name: "rtc", type: "color", title: bold2("Text Color", rtc), required: false, defaultValue: "#000000" , submitOnChange: true, width: 3)
input (name: "rto", type: "enum", title: bold("Text Opacity"), options: parent.opacity(), required: false, defaultValue: "1", submitOnChange: true, width: 2)
input (name: "rp", type: "enum", title: bold("Text Padding"), options: parent.elementSize(), required: false, defaultValue: "0", submitOnChange: true, width: 2, newLine: true)
input (name: "rbc", type: "color", title: bold2("Row Background Color", rbc), required: false, defaultValue: "#BFE373" , submitOnChange: true, width: 3)
input (name: "rbo", type: "enum", title: bold("Row Background Opacity"), options: parent.opacity(), required: false, defaultValue: "1", submitOnChange: true, width: 2)
input (name: "isAppendUnits", type: "bool", title: bold("Append Units<br>to Data?"), required: false, defaultValue: true, submitOnChange: true, width: 2, newLine: true)
input (name: "isAlternateRows", type: "bool", title: bold("Use Alternate<br>Row Colors?"), required: false, defaultValue: true, submitOnChange: true, width: 2, newLine: false)
if (isAlternateRows == true){
input (name: "ratc", type: "color", title: bold2("Alternate Text Color", ratc), required: false, defaultValue: "#000000", submitOnChange: true, width: 3)
input (name: "rabc", type: "color", title: bold2("Alternate Background Color", rabc), required: false, defaultValue: "#E9F5CF", submitOnChange: true, width: 3)
}
if (isCompactDisplay == false) {
paragraph line(1)
paragraph summary("Row Notes", parent.rowNotes() )
}
}
//Footer Properties
if (activeButton == 6){
if (isCompactDisplay == false) paragraph titleise("Footer Properties")
input (name: "isFooter", type: "bool", title: "<b>Display Footer?</b>", required: false, multiple: false, defaultValue: true, submitOnChange: true, width: 2, newLineAfter:true)
if (isFooter == true) {
input (name: "ft", type: "text", title: bold("Footer Text"), required: false, defaultValue: "%time%", width:3, submitOnChange: true)
input (name: "fs", type: "enum", title: bold("Text Size %"), options: parent.textScale(), required: false, defaultValue: "50", width:2, submitOnChange: true)
input (name: "fa", type: "enum", title: bold("Alignment"), options: parent.textAlignment(), required: false, defaultValue: "Center", width:2, submitOnChange: true)
input (name: "fc", type: "color", title: bold2("Text Color", fc), required:false, defaultValue: "#000000", width:3, submitOnChange: true)
}
if (isCompactDisplay == false) {
paragraph line(1)
paragraph summary("Footer Notes", parent.footerNotes() )
}
}
//Highlight Properties
if (activeButton == 7){
if (isCompactDisplay == false) paragraph titleise("Highlights")
if (moduleName == "Attribute Monitor"){
//Keywords
if (state.show.Keywords == true) {
input(name: 'btnShowKeywords', type: 'button', title: 'Show Keywords ▼', backgroundColor: 'navy', textColor: 'white', submitOnChange: true, width: 3, newLine: true) //▼ ◀ ▶ ▲
input (name: "myKeywordCount", title: "<b>How Many Keywords?</b>", type: "enum", options: [0,1,2,3,4,5], submitOnChange:true, width:2, defaultValue: 0, newLine: true, newLineAfter:true)
if (myKeywordCount.toInteger() >= 1 ){
input (name: "k1", type: "text", title: bold("Enter Keyword #1"), required: false, displayDuringSetup: true, defaultValue: "?", submitOnChange: true, width: 2, newLine:true)
input (name: "ktr1", type: "text", title: bold("Replacement Text #1"), required: false, displayDuringSetup: true, defaultValue: "?", submitOnChange: true, width: 2)
input (name: "hc1", type: "color", title: bold2("Highlight 1 Color", hc1), required: false, defaultValue: "#008000", submitOnChange: true, width: 2) //Default as green shade
input (name: "hts1", type: "enum", title: bold("Highlight 1 Text Scale"), options: parent.textScale(), required: false, submitOnChange: true, defaultValue: "125", width: 2, newLineAfter:true)
}
if (myKeywordCount.toInteger() >= 2 ){
input (name: "k2", type: "text", title: bold("Enter Keyword #2"), required: false, displayDuringSetup: true, defaultValue: "?", submitOnChange: true, width: 2, newLine:true)
input (name: "ktr2", type: "text", title: bold("Replacement Text #2"), required: false, displayDuringSetup: true, defaultValue: "?", submitOnChange: true, width: 2)
input (name: "hc2", type: "color", title: bold2("Highlight 2 Color", hc2), required: false, defaultValue: "#CA6F1E", submitOnChange: true, width: 2) //Default as orange shade
input (name: "hts2", type: "enum", title: bold("Highlight 2 Text Scale"), options: parent.textScale(), required: false, submitOnChange: true, defaultValue: "125", width: 2, newLineAfter:true)
}
if (myKeywordCount.toInteger() >= 3 ){
input (name: "k3", type: "text", title: bold("Enter Keyword #3"), required: false, displayDuringSetup: true, defaultValue: "?", submitOnChange: true, width: 2, newLine:true)
input (name: "ktr3", type: "text", title: bold("Replacement Text #3"), required: false, displayDuringSetup: true, defaultValue: "?", submitOnChange: true, width: 2)
input (name: "hc3", type: "color", title: bold2("Highlight 3 Color", hc3), required: false, defaultValue: "#00FF00", submitOnChange: true, width: 2) //Default as red shade
input (name: "hts3", type: "enum", title: bold("Highlight 3 Text Scale"), options: parent.textScale(), required: false, submitOnChange: true, defaultValue: "125", width: 2, newLineAfter:true)
}
if (myKeywordCount.toInteger() >= 4 ){
input (name: "k4", type: "text", title: bold("Enter Keyword #4"), required: false, displayDuringSetup: true, defaultValue: "?", submitOnChange: true, width: 2, newLine:true)
input (name: "ktr4", type: "text", title: bold("Replacement Text #4"), required: false, displayDuringSetup: true, defaultValue: "?", submitOnChange: true, width: 2)
input (name: "hc4", type: "color", title: bold2("Highlight 4 Color", hc4), required: false, defaultValue: "#0000FF", submitOnChange: true, width: 2) //Default as blue shade
input (name: "hts4", type: "enum", title: bold("Highlight 4 Text Scale"), options: parent.textScale(), required: false, submitOnChange: true, defaultValue: "125", width: 2, newLineAfter:true)
}
if (myKeywordCount.toInteger() >= 5 ){
input (name: "k5", type: "text", title: bold("Enter Keyword #5"), required: false, displayDuringSetup: true, defaultValue: "?", submitOnChange: true, width: 2, newLine:true)
input (name: "ktr5", type: "text", title: bold("Replacement Text #5"), required: false, displayDuringSetup: true, defaultValue: "?", submitOnChange: true, width: 2)
input (name: "hc5", type: "color", title: bold2("Highlight 5 Color", hc5), required: false, defaultValue: "#FF0000", submitOnChange: true, width: 2) //Default as orange shade
input (name: "hts5", type: "enum", title: bold("Highlight 5 Text Scale"), options: parent.textScale(), required: false, submitOnChange: true, defaultValue: "125", width: 2, newLineAfter:true)
}
}
else input(name: 'btnShowKeywords', type: 'button', title: 'Show Keywords ▶', backgroundColor: 'dodgerBlue', textColor: 'white', submitOnChange: true, width: 3, newLineAfter: true) //▼ ◀ ▶ ▲
//Thresholds
if (state.show.Thresholds == true) {
input(name: 'btnShowThresholds', type: 'button', title: 'Show Thresholds ▼', backgroundColor: 'navy', textColor: 'white', submitOnChange: true, width: 3, newLine: true) //▼ ◀ ▶ ▲
input (name: "myThresholdCount", title: "<b>How Many Thresholds?</b>", type: "enum", options: [0,1,2,3,4,5], submitOnChange:true, width:2, defaultValue: 0, newLine: true, newLineAfter:true)
if (myThresholdCount.toInteger() >= 1 ){
input (name: "top6", type: "enum", title: bold("Operator #6"), required: false, options: parent.comparators(), displayDuringSetup: true, defaultValue: 0, submitOnChange: true, width: 1, newLine: true)
input (name: "tcv6", type: "number", title: bold("Comparison Value #6"), required: false, displayDuringSetup: true, defaultValue: 1, submitOnChange: true, width: 2)
input (name: "ttr6", type: "text", title: bold("Replacement Text #6"), required: false, displayDuringSetup: true, defaultValue: "?", submitOnChange: true, width: 2)
input (name: "hc6", type: "color", title: bold2("Highlight 6 Color", hc6), required: false, defaultValue: "#008000", submitOnChange: true, width: 2) //Default as green shade
input (name: "hts6", type: "enum", title: bold("Highlight 6 Text Scale"), options: parent.textScale(), required: false, submitOnChange: true, defaultValue: "125", width: 2, newLineAfter:true)
}
if (myThresholdCount.toInteger() >= 2 ){
input (name: "top7", type: "enum", title: bold("Operator #7"), required: false, options: parent.comparators(), displayDuringSetup: true, defaultValue: "None", submitOnChange: true, width: 1, newLine: true)
input (name: "tcv7", type: "number", title: bold("Comparison Value #7"), required: false, displayDuringSetup: true, defaultValue: 1, submitOnChange: true, width: 2)
input (name: "ttr7", type: "text", title: bold("Replacement Text #7"), required: false, displayDuringSetup: true, defaultValue: "?", submitOnChange: true, width: 2)
input (name: "hc7", type: "color", title: bold2("Highlight 7 Color", hc7), required: false, defaultValue: "#CA6F1E", submitOnChange: true, width: 2) //Default as orange shade
input (name: "hts7", type: "enum", title: bold("Highlight 7 Text Scale"), options: parent.textScale(), required: false, submitOnChange: true, defaultValue: "125", width: 2, newLineAfter:true)
}
if (myThresholdCount.toInteger() >= 3 ){
input (name: "top8", type: "enum", title: bold("Operator #8"), required: false, options: parent.comparators(), displayDuringSetup: true, defaultValue: 0, submitOnChange: true, width: 1, newLine: true)
input (name: "tcv8", type: "number", title: bold("Comparison Value #8"), required: false, displayDuringSetup: true, defaultValue: 1, submitOnChange: true, width: 2)
input (name: "ttr8", type: "text", title: bold("Replacement Text #8"), required: false, displayDuringSetup: true, defaultValue: "?", submitOnChange: true, width: 2)
input (name: "hc8", type: "color", title: bold2("Highlight 8 Color", hc8), required: false, defaultValue: "#00FF00", submitOnChange: true, width: 2) //Default as red shade
input (name: "hts8", type: "enum", title: bold("Highlight 3 Text Scale"), options: parent.textScale(), required: false, submitOnChange: true, defaultValue: "125", width: 2, newLineAfter:true)
}
if (myThresholdCount.toInteger() >= 4 ){
input (name: "top9", type: "enum", title: bold("Operator #9"), required: false, options: parent.comparators(), displayDuringSetup: true, defaultValue: 0, submitOnChange: true, width: 1, newLine: true)
input (name: "tcv9", type: "number", title: bold("Comparison Value #9"), required: false, displayDuringSetup: true, defaultValue: 1, submitOnChange: true, width: 2)
input (name: "ttr9", type: "text", title: bold("Replacement Text #9"), required: false, displayDuringSetup: true, defaultValue: "?", submitOnChange: true, width: 2)
input (name: "hc9", type: "color", title: bold2("Highlight 9 Color", hc9), required: false, defaultValue: "#0000FF", submitOnChange: true, width: 2) //Default as blue shade
input (name: "hts9", type: "enum", title: bold("Highlight 9 Text Scale"), options: parent.textScale(), required: false, submitOnChange: true, defaultValue: "125", width: 2, newLineAfter:true)
}
if (myThresholdCount.toInteger() >= 5 ){
input (name: "top10", type: "enum", title: bold("Operator #10"), required: false, options: parent.comparators(), displayDuringSetup: true, defaultValue: 0, submitOnChange: true, width: 1, newLine: true)
input (name: "tcv10", type: "number", title: bold("Comparison Value #10"), required: false, displayDuringSetup: true, defaultValue: 1, submitOnChange: true, width: 2)
input (name: "ttr10", type: "text", title: bold("Replacement Text #10"), required: false, displayDuringSetup: true, defaultValue: "?", submitOnChange: true, width: 2)
input (name: "hc10", type: "color", title: bold2("Highlight 10 Color", hc10), required: false, defaultValue: "#FF0000", submitOnChange: true, width: 2) //Default as orange shade
input (name: "hts10", type: "enum", title: bold("Highlight 10 Text Scale"), options: parent.textScale(), required: false, submitOnChange: true, defaultValue: "125", width: 2, newLineAfter:true)
}
}
else input(name: 'btnShowThresholds', type: 'button', title: 'Show Thresholds ▶', backgroundColor: 'dodgerBlue', textColor: 'white', submitOnChange: true, width: 3, newLine: true, newLineAfter:true) //▼ ◀ ▶ ▲
//Replace Chars
if (state.show.ReplaceCharacters == true) {
input(name: 'btnShowReplaceCharacters', type: 'button', title: 'Show Replace Chars ▼', backgroundColor: 'navy', textColor: 'white', submitOnChange: true, width: 2, newLine: true, newLineAfter: true) //▼ ◀ ▶ ▲
input (name: "isReplaceCharacters", type: "bool", title: "<b>Replace Characters?</b>", required: false, multiple: false, defaultValue: true, submitOnChange: true, width: 2, newLine:false)
if (isReplaceCharacters == true) {
input (name: "oc1", type: "text", title: bold("Original Character(s)"), required: false, displayDuringSetup: true, defaultValue: "?", submitOnChange: true, width: 2, newLine:false)
input (name: "nc1", type: "text", title: bold("New Character(s)"), required: false, displayDuringSetup: true, defaultValue: "?", submitOnChange: true, width: 2, newLine: false)
}
}
else input(name: 'btnShowReplaceCharacters', type: 'button', title: 'Show Replace Chars ▶', backgroundColor: 'dodgerBlue', textColor: 'white', submitOnChange: true, width: 3, newLine: true) //▼ ◀ ▶ ▲
input (name: "isHighlightDeviceNames", type: "bool", title: bold("Also Highlight Device Names"), required: false, multiple: false, defaultValue: false, submitOnChange: true, width: 2, newLine: true)
if (isCompactDisplay == false) {
paragraph line(1)
paragraph summary("Highlight Notes", parent.highlightNotes() )
}
}
}
//Styles
if (activeButton == 8){
if (isCompactDisplay == false) paragraph titleise("Styles")
input (name: "applyStyleName", type: "enum", title: bold("Select Style to Apply"), options:parent.listStyles() , required: false, submitOnChange: true, defaultValue: null, width: 3)
input (name: "saveStyleName", type: "text", title: bold("Save as Style: (Tab or Enter)"), backgroundColor: "#27ae61", textColor: "white", submitOnChange: true, defaultValue: "?", width: 3)
input (name: "deleteStyleName", type: "enum", title: bold("Select Style to Delete"), options:parent.listStyles() , required: false, submitOnChange: true, defaultValue: null, width: 3)
input (name: "isShowImportExport", type: "bool", title: "<b>Show Import\\Export?</b>", required: false, multiple: false, defaultValue: false, submitOnChange: true, width: 3, newLineAfter:true)
if (applyStyleName != null)
input (name: "applyStyle", type: "button", title: "Apply Style", backgroundColor: "#27ae61", textColor: "white", submitOnChange: true, width: 3, newLine: true, newLineAfter: false)
else
input (name: "doNothing", type: "button", title: "Apply Style", backgroundColor: "#D3D3D3", textColor: "black", submitOnChange: true, width: 3, newLine: true, newLineAfter: false)
//This does not work quite right. The "doNothing" button does not show until there is a secondary refresh.
if (saveStyleName != null && saveStyleName != "?") input (name: "saveStyle", type: "button", title: "Save Current Style", backgroundColor: "#27ae61", textColor: "white", submitOnChange: true, width: 3, newLine: false, newLineAfter: false)
if (saveStyleName == null || saveStyleName == "?") input (name: "doNothing", type: "button", title: "Save Current Style", backgroundColor: "#D3D3D3", textColor: "black", submitOnChange: true, width: 3, newLine: false, newLineAfter: false)
if (deleteStyleName != null)
input (name: "deleteStyle", type: "button", title: "Delete Selected Style", backgroundColor: "#27ae61", textColor: "white", submitOnChange: true, width: 3, newLine: false, newLineAfter: true)
else
input (name: "doNothing", type: "button", title: "Delete Selected Style", backgroundColor: "#D3D3D3", textColor: "black", submitOnChange: true, width: 3, newLine: false, newLineAfter: true)
if (isCompactDisplay == false) {
paragraph line(1)
paragraph summary("Styles Notes", parent.styleNotes())
}
if (isShowImportExport == true) {
//if (isCompactDisplay == false) paragraph line(1)
paragraph "<b>Export</b><br>These are your currently active settings. You can copy these and share them with others via the Hubitat Community forum. Tweaking can be addictive but a lot of fun to explore!"
paragraph "<style><div {width: 150px; border: 5px solid #000000;} div.a {word-wrap: break-word;}</style><body><div class='a'><b>Basic Settings:</b><br><mark>" + state.myBaseSettingsMap.sort() + "</mark></div></body>"
paragraph "<style><div {width: 150px; border: 5px solid #000000;} div.a {word-wrap: break-word;}</style></head><body><div class='a'><b>Overrides:</b><br><mark>" + overrides.toString() + "</mark></div></body>"
paragraph line(1)
paragraph "<b>Import</b><br>You can paste settings from other people in here and save them as a new sytle. How great is that!"
input (name: "importStyleText", type: "text", title: bold("Paste Basic Settings Here!"), required: false, defaultValue: "?", width:12, height:4, submitOnChange: true)
input (name: "importStyleOverridesText", type: "text", title: bold("Paste Overrides Here!"), required: false, defaultValue: "?", width:12, submitOnChange: true)
//Show a green button if the entered text is long enough, otherwise gray - have to add some validation on the imput.
if (importStyleText == null || importStyleText.size() == 0){
input (name: "doNothing", type: "button", title: "Import Style?", backgroundColor: "#D3D3D3", textColor: "black", submitOnChange: true, width: 3, newLine: false, newLineAfter: false)
input (name: "doNothing", type: "button", title: "Clear Import", backgroundColor: "#D3D3D3", textColor: "black", submitOnChange: true, width: 3, newLine: false, newLineAfter: false)
}
else {
input (name: "importStyle", type: "button", title: "Import Style", backgroundColor: "#27ae61", textColor: "white", submitOnChange: true, width: 3, newLine: true, newLineAfter: false )
input (name: "clearImport", type: "button", title: "Clear Import", backgroundColor: "#27ae61", textColor: "white", submitOnChange: true, width: 3, newLine: true, newLineAfter: false )
}
paragraph "<b>Once you have imported a new Style you can save it if you wish to preserve it.</b>"
}
}
//Advanced Settings
if (activeButton == 9){
if (isCompactDisplay == false) paragraph titleise("Advanced Settings")
input (name: "scrubHTMLlevel", type: "enum", title: bold("HTML Scrub Level"), options: parent.htmlScrubLevel(), required: false, submitOnChange: true, defaultValue: "1", width: 2, newLineAfter:false)
input (name: "isOverrides", type: "bool", title: "<b>Enable Overrides?</b>", required: false, multiple: false, defaultValue: false, submitOnChange: true, width: 2, newLineAfter: false)
input (name: "isShowSettings", type: "bool", title: "<b>Show Effective Settings?</b>", required: false, multiple: false, defaultValue: false, submitOnChange: true, width: 2)
input (name: "isShowHTML", type: "bool", title: "<b>Show Pseudo HTML?</b>", required: false, multiple: false, defaultValue: false, submitOnChange: true, width: 2)
if (isOverrides == true) {
paragraph line(1)
input (name: "overrideHelperCategory", type: "enum", title: bold("Override Category"), options: parent.overrideCategory().sort(), required: true, width:2, submitOnChange: true, newLineAfter: true)
input (name: "overridesHelperSelection", type: "enum", title: bold("$overrideHelperCategory Examples"), options: getOverrideCommands(overrideHelperCategory.toString()), required: false, width:12, submitOnChange: true, newLineAfter: true)
if (state.currentHelperCommand != null ) paragraph "<mark>" + state.currentHelperCommand + "</mark></body>"
input (name: "clearOverrides", type: "button", title: "Clear the Overrides", backgroundColor: "#27ae61", textColor: "white", submitOnChange: true, width: 2, newLine: true, newLineAfter: false )
input (name: "copyOverrides", type: "button", title: "Copy To Overrides", backgroundColor: "#27ae61", textColor: "white", submitOnChange: true, width: 2, newLine: true, newLineAfter: false )
input (name: "appendOverrides", type: "button", title: "Append To Overrides", backgroundColor: "#27ae61", textColor: "white", submitOnChange: true, width: 2, newLine: true, newLineAfter: false )
input (name: "Refresh", type: "button", title: "Refresh Table", backgroundColor: "#27ae61", textColor: "white", submitOnChange: true, width: 2)
input (name: "overrides", type: "textarea", title: titleise("Settings Overrides"), required: false, defaultValue: "?", width:12, rows:5, submitOnChange: true)
if (isCompactDisplay == false) paragraph summary("About Overrides", parent.overrideNotes() )
}
if (isShowSettings == true) {
paragraph line(1)
paragraph "<b>Effective Settings</b>"
paragraph "<head><style><div {width: 150px; border: 5px solid #000000;} div.a {word-wrap: break-word;}</style></head><body><div class='a'><mark>" + state.myEffectiveSettingsMap.sort() + "</mark></div></body>"
}
if (isShowHTML == true) {
paragraph line(1)
paragraph "<b>Pseudo HTML</b>"
myHTML = state.iFrameHTML
paragraph "<head><style><div {width: 150px; border: 5px solid #000000;} div.a {word-wrap: break-word;}</style></head><body><div class='a'><mark>" + unHTML(state.HTML) + "</mark></div></body>"
}
if (isCompactDisplay == false) {
paragraph line(1)
paragraph summary("Advanced Notes", parent.advancedNotes() )
}
}
if (isCompactDisplay == false) paragraph line(2)
} //End of isCustomize
//Display Table
if (isCompactDisplay == false) paragraph summary("Display Tips", parent.displayTips() )
myHTML = toHTML(state.iframeHTML)
myHTML = myHTML.replace("#iFrame1#","body{background:${iFrameColor};font-size:${bfs}px;}")
state.iFrameFinalHTML = myHTML
if (isCustomSize == false){
if (tilePreview == "1" ) paragraph '<iframe srcdoc=' + '"' + myHTML + '"' + ' width="190" height="190" style="border:solid" scrolling="no"></iframe>'
if (tilePreview == "2" ) paragraph '<iframe srcdoc=' + '"' + myHTML + '"' + ' width="190" height="380" style="border:solid" scrolling="no"></iframe>'
if (tilePreview == "3" ) paragraph '<iframe srcdoc=' + '"' + myHTML + '"' + ' width="190" height="570" style="border:solid" scrolling="no"></iframe>'
if (tilePreview == "4" ) paragraph '<iframe srcdoc=' + '"' + myHTML + '"' + ' width="190" height="760" style="border:solid" scrolling="no"></iframe>'
if (tilePreview == "5" ) paragraph '<iframe srcdoc=' + '"' + myHTML + '"' + ' width="380" height="190" style="border:solid" scrolling="no"></iframe>'
if (tilePreview == "6" ) paragraph '<iframe srcdoc=' + '"' + myHTML + '"' + ' width="380" height="380" style="border:solid" scrolling="no"></iframe>'
if (tilePreview == "7" ) paragraph '<iframe srcdoc=' + '"' + myHTML + '"' + ' width="380" height="570" style="border:solid" scrolling="no"></iframe>'
if (tilePreview == "8" ) paragraph '<iframe srcdoc=' + '"' + myHTML + '"' + ' width="380" height="760" style="border:solid" scrolling="no"></iframe>'
if (tilePreview == "9" ) paragraph '<iframe srcdoc=' + '"' + myHTML + '"' + ' width="380" height="950" style="border:solid" scrolling="no"></iframe>'
}
else {
//Use a custom size for the preview window.
myString = '<iframe srcdoc=' + '"' + myHTML + '"' + ' width=XXX height=YYY style="border:solid" scrolling="no"></iframe>'
myString = myString.replace("XXX", "${settings.customWidth}")
myString = myString.replace("YYY", "${settings.customHeight}")
paragraph myString
}
if (state.HTMLsizes.Final < 4096 ){
if (isCompactDisplay == false) paragraph "<div style='color:#17202A;text-align:left; margin-top:0em; margin-bottom:0em ; font-size:18px'>Current HTML size is: <font color = 'green'><b>${state.HTMLsizes.Final}</b></font color = '#17202A'> bytes. Maximum size for dashboard tiles is <b>4,096</b> bytes.</div>"
}
else {
if (isCompactDisplay == false) paragraph "<div style='color:#17202A;text-align:left; margin-top:0em; margin-bottom:0em ; font-size:18px'>Current HTML size is: <font color = 'red'><b>${state.HTMLsizes.Final}</b></font color = '#17202A'> bytes. Maximum size for dashboard tiles is <b>4,096</b> bytes.</div>"
}
if (isCustomize == true){
overridesSize = 0
if (settings.overrides?.size() != null && isOverrides == true) overridesSize = settings.overrides?.size()
line = "<b>Enabled Features:</b> Comment:${isComment}, Frame:${isFrame}, Title:${isTitle}, Title Shadow:${isTitleShadow}, Headers:${isHeaders}, Border:${isBorder}, Alternate Rows:${isAlternateRows}, Footer:${isFooter}, Overrides:${isOverrides} ($overridesSize bytes)<br>"
line += "<b>Space Usage:</b> Comment: <b>${state.HTMLsizes.Comment}</b> Head: <b>${state.HTMLsizes.Head}</b> Body: <b>${state.HTMLsizes.Body}</b> Interim Size: <b>${state.HTMLsizes.Interim}</b> Final Size: <b>${state.HTMLsizes.Final}</b> (Scrubbing level is: ${parent.htmlScrubLevel()[scrubHTMLlevel.toInteger()] })<br>"
//line += "<b>Devices:</b> Selected: <b>${myDeviceList?.size() || 0}</b> Limit: <b>${myDeviceLimit?.toInteger() || 0}</b>"
line = line.replace("true","<b><font color = 'green'> On</font color = 'black'></b>")
line = line.replace("false","<b><font color = 'grey'> Off</font color = 'grey'></b>")
if (isCompactDisplay == false) {
paragraph note("", line)
if (state.HTMLsizes.Final < 1024 ) paragraph note("Note: ","Current tile is less than 1,024 bytes and will be stored within an attribute.")
else paragraph note("Note: ","Current tile is greater than 1,024 bytes and will be stored as a file in File Manager and linked with an attribute.")
}
}
} //End of showDesign
else input(name: 'btnShowDesign', type: 'button', title: 'Design Table ▶', backgroundColor: 'dodgerBlue', textColor: 'white', submitOnChange: true, width: 3, newLine: true) //▼ ◀ ▶ ▲
paragraph line(2)
//End of Display Table
//Configure Data Refresh
if (state.show.Publish == true) {
input(name: 'btnShowPublish', type: 'button', title: 'Publish Table ▼', backgroundColor: 'navy', textColor: 'white', submitOnChange: true, width: 3, newLineAfter: true) //▼ ◀ ▶ ▲
if (moduleName == "Attribute Monitor") myText = "Here you will configure where the table will be stored. It will be refreshed whenever a monitored attribute changes."
if (moduleName == "Activity Monitor") myText = "Here you will configure where the table will be stored. It will be refreshed at the frequency you specify."
//myText += "HTML data is less than 1,024 bytes it will be published via a tile attribute on the storage device.<br>"
//myText += "If HTML data is greater than 1,024 it will be published via file with the tile attribute being link to that file.<br>"
paragraph myText
input (name: "myTile", title: "<b>Tile Attribute to store the table?</b>", type: "enum", options: parent.allTileList(), required:true, submitOnChange:true, width:2, defaultValue: 0, newLine:false)
input (name:"myTileName", type:"text", title: "<b>Name this Tile</b>", submitOnChange: true, width:2, newLine:false, required: true)
input (name: "tilesAlreadyInUse", type: "enum", title: bold("For Reference Only: Tiles in Use"), options: parent.getTileList(), required: false, defaultValue: "Tile List", submitOnChange: false, width: 2)
input (name: "eventTimeout", type: "enum", title: "<b>Event Timeout (millis)</b>", required: false, multiple: false, defaultValue: "2000", options: ["0","250","500","1000","2000","5000","10000"], submitOnChange: true, width: 2)
if (moduleName == "Attribute Monitor") input (name: "republishDelay", type: "enum", title: "<b>Republish Delay (minutes)</b>", required: false, multiple: false, defaultValue: 0, options: [0,1,2,3,4,5,10,15,20,25,30,35,40,45,50,55,60], submitOnChange: true, width: 2)
input (name: "oversizeTileHandling", type: "enum", title: "<b>Oversize Tile Handling</b>", required: false, multiple: false, defaultValue: "File Manager", options: ["File Manager","Cloud Endpoint"], submitOnChange: true, width: 2, newLineAfter:true)
if (myTileName) app.updateLabel(myTileName)
myText = "The <b>Tile Name</b> given here will also be used as the name for this instance of Tile Builder. Appending the name with your chosen tile number can make parent display more readable.<br>"
myText += "The <b>Event Timeout</b> period is how long Tile Builder will wait for subsequent events before publishing the table. Devices that do bulk updates create a lot of events in a short period of time. This setting batches requests within this period into a single publishing event. "
myText += "The default timeout period is 2000 milliseconds (2 seconds). If you want a more responsive table you can lower this number, but it will slightly increase the CPU utilization.<br>"
myText += "The <b>Republish Delay</b> sets a minimum amount of time before a Tile is re-published. This can be used to prevent <b>chatty sensors</b> from causing a Tile to republish too frequently. The default value for this setting is 0 (no delay)." +\
"<b>Republish Delay</b> is not available in Activity Monitor because it already works on a timed basis.<br>"
myText += "<b>When immediate updates are important such as switches, locks, motion or contact sensors then set both the the Event Timeout and Republish Delay to 0.</b><br><br>"
myText += "<b>Oversize Tiles:</b> Tiles over 1,024 bytes can either be stored in Hubitat File Manager or published to a Hubitat Cloud Endpoint<br>"
myText += "Tiles stored to the Hubitat File Manager are only accessible from the local LAN or when using a VPN.<br>"
myText += "Tiles stored to a Hubitat Cloud Endpoint are accessible from the local LAN or the cloud via the Hubitat App but does require the internet to be operational in order to display.<br>"
myText += "Storing oversize tiles in File Manager is the faster of the two options and is the default operation. Only use cloud endpoints when you have an explicit need for the information to be availble via the internet.<br>"
myText += "<b>Important: If you wish to use cloud endpoints you must go to the Apps / Code for this module and enable OAuth using the default Auto-Generated values.</b><br>"
if (state.cloudEndpoint != null ) myText += "The Hubitat Cloud Endpoint for this Tile Builder table is: ${state.cloudEndpoint}"
paragraph summary("Publishing Notes", myText)
paragraph line(1)
if ( state.HTMLsizes.Final < 4096 && settings.myTile != null && myTileName != null ) {
if (moduleName == "Activity Monitor") {
input (name:"publishInterval", title: "<b>Table Refresh Interval</b>", type: "enum", options: parent.refreshInterval(), required:false, submitOnChange:true, width:2, defaultValue: 1)
input (name: "publish", type: "button", title: "Publish Table", backgroundColor: "#27ae61", textColor: "white", submitOnChange: true, width: 12)
}
if (moduleName == "Attribute Monitor") {
input (name: "publishSubscribe", type: "button", title: "Publish and Subscribe", backgroundColor: "#27ae61", textColor: "white", submitOnChange: true, width: 12)
input (name: "unsubscribe", type: "button", title: "Delete Subscription", backgroundColor: "#27ae61", textColor: "white", submitOnChange: true, width: 12)
}
}
else input (name: "cannotPublish", type: "button", title: "Publish", backgroundColor: "#D3D3D3", textColor: "black", submitOnChange: false, width: 12)
}
else input(name: 'btnShowPublish', type: 'button', title: 'Publish Table ▶', backgroundColor: 'dodgerBlue', textColor: 'white', submitOnChange: true, width: 3, newLineAfter: true) //▼ ◀ ▶ ▲
if (isCompactDisplay == false) paragraph line(2)
input (name:"isMore", type: "bool", title: "More Options", required: false, multiple: false, defaultValue: false, submitOnChange: true, width: 2)
if (isMore == true){
paragraph "<div style='background:#FFFFFF; height: 1px; margin-top:0em; margin-bottom:0em ; border: 0;'></div>" //Horizontal Line
input (name: "isLogInfo", type: "bool", title: "<b>Enable info logging?</b>", defaultValue: false, submitOnChange: true, width: 2)
input (name: "isLogTrace", type: "bool", title: "<b>Enable trace logging?</b>", defaultValue: false, submitOnChange: true, width: 2)
input (name: "isLogDebug", type: "bool", title: "<b>Enable debug logging?</b>", defaultValue: false, submitOnChange: true, width: 2)
input (name: "isLogWarn", type: "bool", title: "<b>Enable warn logging?</b>", defaultValue: true, submitOnChange: true, width: 2)
input (name: "isLogError", type: "bool", title: "<b>Enable error logging?</b>", defaultValue: true, submitOnChange: true, width: 2)
input (name: "isLogEvents", type: "bool", title: "<b>Enable Device Event logging?</b>", defaultValue: false, submitOnChange: true, width: 2, newLine:true)
}
//Now add a footer.
myDocURL = "<a href='https://github.com/GaryMilne/Hubitat-TileBuilder/blob/main/Tile%20Builder%20Help.pdf' target=_blank> <i><b>Tile Builder Help</b></i></a>"
myText = '<div style="display: flex; justify-content: space-between;">'
myText += '<div style="text-align:left;font-weight:small;font-size:12px"> <b>Documentation:</b> ' + myDocURL + '</div>'
myText += '<div style="text-align:center;font-weight:small;font-size:12px">Version: ' + codeDescription + '</div>'
myText += '<div style="text-align:right;font-weight:small;font-size:12px">Copyright 2022 - 2024</div>'
myText += '</div>'
paragraph myText
} //End Configure Data Refresh
refreshUIafter()
}
}
//Checks for critical Null values that can be introduced by the user by clicking "No Selection" in an enum dialog.
//This occurs when the specific control value is accessed by various functions during the screen refresh before the "defaultValue" can be applied.
def checkNulls(){
if (myThresholdCount == null ) app.updateSetting("myThresholdCount", [value:"0", type:"enum"])
if (myKeywordCount == null ) app.updateSetting("myKeywordCount", [value:"0", type:"enum"])
if (myDeviceLimit == null ) app.updateSetting("myDeviceLimit", [value:"0", type:"enum"])
if (eventTimeout == null) app.updateSetting("eventTimeout", "2000")
if (tbo == null) app.updateSetting("tbo", [value:"1", type:"enum"])
if (to == null) app.updateSetting("to", [value:"1", type:"enum"])
if (bo == null) app.updateSetting("bo", [value:"1", type:"enum"])
if (hbo == null) app.updateSetting("hbo", [value:"1", type:"enum"])
if (hto == null) app.updateSetting("hto", [value:"1", type:"enum"])
if (rbo == null) app.updateSetting("rbo", [value:"1", type:"enum"])
if (rto == null) app.updateSetting("rto", [value:"1", type:"enum"])
if (bp == null) app.updateSetting("bp", [value:"0", type:"enum"])
if (scrubLevelHTML == null ) app.updateSetting("scrubHTMLlevel", [value:"1", type:"enum"])
}
//Get a list of supported attributes for a given device and return a sorted list.
def getAttributeList (thisDevice){
if (thisDevice != null) {
myAttributesList = []
supportedAttributes = thisDevice.supportedAttributes
supportedAttributes.each { attributeName -> myAttributesList << attributeName.name }
return myAttributesList.unique().sort()
}
}
//************************************************************************************************************************************************************************************************************************
//************************************************************************************************************************************************************************************************************************
//************************************************************************************************************************************************************************************************************************
//**************
//************** Functions Related to the Management of the UI
//**************
//************************************************************************************************************************************************************************************************************************
//************************************************************************************************************************************************************************************************************************
//************************************************************************************************************************************************************************************************************************
//This is the refresh routine called at the start of the page. This is used to replace\clear screen values that do not respond when performed in the mainline code.
//This function is unique between modules
void refreshUIbefore(){
//Get the oveerrides helper selection and look it up in the global map and use the key pair value as an on-screen guide.
state.currentHelperCommand = ""
overridesHelperMap = parent.getOverridesListAll()
state.currentHelperCommand = overridesHelperMap.get(overridesHelperSelection)
if (state.flags.isClearOverridesHelperCommand == true){
if (isLogTrace == true) log.trace ("Clearing overrides.")
app.updateSetting("overrides", [value:"", type:"textarea"]) //Works
state.flags.isClearOverridesHelperCommand = false
}
if (moduleName == "Activity Monitor") {
if (mySelectedTile != null){
details = mySelectedTile.tokenize(":")
if (details[0] != null ) {
tileName = details[0].trim()
if (isLogDebug) log.debug ("tileName is $tileName")
//We use the tile number when publishing so we strip off the leading word tile.
tileNumber = tileName.replace("tile","")
app.updateSetting("myTile", tileNumber)
}
if (details[1] != null ) {
tileName = details[1].trim()
if (isLogInfo) log.info ("tileName is $tileName")
app.updateSetting("myTileName", tileName)
}
}
}
}
//This is the refresh routine called at the end of the page. This is used to replace\clear screen values that do not respond when performed in the mainline code.
void refreshUIafter(){
//This checks a flag for the saveStlye operation and clears the text field if the flag has been set. Neccessary to do this so the UI updates correctly.
if (state.flags.styleSaved == true ){
app.updateSetting("saveStyleName","?")
state.flags.styleSaved = false
}
//If the myCapability flag has been changed then the myDeviceList is cleared as the potential device list would be different based on the capability selected.
//Only applies to Activity Monitor but retained for ease of maintenance.
if (state.flags.myCapabilityChanged == true ) {
//log.info ("Reset list")
app.updateSetting("myDeviceList",[type:"capability",value:[]])
state.flags.myCapabilityChanged == false
}
//Copy the selected command to the Overrides field and replace any existing text.
if (state.flags.isCopyOverridesHelperCommand == true){
myCommand = state.currentHelperCommand
app.updateSetting("overrides", [value:myCommand, type:"textarea"]) //Works
state.flags.isCopyOverridesHelperCommand = false
}
//Appends the selected command to current contents of the Overrides field.
if (state.flags.isAppendOverridesHelperCommand == true){
myCurrentCommand = overrides.toString()
myCurrentCommand = myCurrentCommand.replace("[", "")
myCurrentCommand = myCurrentCommand.replace("]", "")
combinedCommand = myCurrentCommand.toString() + " | \n" + state.currentHelperCommand.toString()
app.updateSetting("overrides", [value:combinedCommand.toString(), type:"textarea"]) //Works
state.flags.isAppendOverridesHelperCommand = false
}
}
//Runs recovery functions when messaged from the parent app. This can be used to recoved a child app when an error condidtion arises.
def supportFunction ( supportCode ){
if ( supportCode.toString() == "0" ) return
log.info "Running supportFunction with code: $supportCode"
switch(supportCode) {
case "disableOverrides":
app.updateSetting("isOverrides", false)
break
case "disableKeywords":
app.updateSetting("myKeywordCount", 0)
break
case "disableThresholds":
app.updateSetting("myThresholdCount", 0)
break
case "clearDeviceList":
app.updateSetting("myDeviceList",[type:"capability",value:[]])
break
}
}
//Generic placeholder for test function.
void test(){
//top6 = top1
app.updateSetting("scrubHTMLlevel", [value:"1", type:"enum"])
app.updateSetting("myDeviceNaming", "Use Device Label")
if (myKeywordCount > 0) state.show.Keywords = true
if (myThresholdCount > 0) state.show.Thresholds = true
}
//This is the standard button handler that receives the click of any button control.
def appButtonHandler(btn) {
switch(btn) {
case 'btnShowReport':
state.show.Report = state.show.Report ? false : true;
break
case 'btnShowFilter':
state.show.Filter = state.show.Filter ? false : true;
break
case 'btnShowDevices':
state.show.Devices = state.show.Devices ? false : true;
break
case 'btnShowKeywords':
state.show.Keywords = state.show.Keywords ? false : true;
break
case 'btnShowThresholds':
state.show.Thresholds = state.show.Thresholds ? false : true;
break
case 'btnShowFormatRules':
state.show.FormatRules = state.show.FormatRules ? false : true;
break
case 'btnShowReplaceCharacters':
state.show.ReplaceCharacters = state.show.ReplaceCharacters ? false : true;
break
case 'btnShowDesign':
state.show.Design = state.show.Design ? false : true;
break
case 'btnShowPublish':
state.show.Publish = state.show.Publish ? false : true;
break
case "Refresh":
//We don't need to do anything. The refreshTable will be called by the submitOnChange.
if (isLogTrace==true) log.trace("appButtonHandler: Clicked on Refresh")
break
case "publish":
//We will publish it right away and then schedule the refresh as requested.
if (isLogTrace) log.trace("appButtonHandler: Clicked on publish")
publishTable()
createSchedule()
break
case "cannotPublish":
if (isLogTrace) log.trace("appButtonHandler: Clicked on publish (cannotPublish)")
cannotPublishTable()
break
case "General":
if (isLogTrace) log.trace("appButtonHandler: Clicked on General")
app.updateSetting("activeButton", 1)
break
case "Title":
if (isLogTrace) log.trace("appButtonHandler: Clicked on Title")
app.updateSetting("activeButton", 2)
break
case "Headers":
if (isLogTrace) log.trace("appButtonHandler: Clicked on Headers")
app.updateSetting("activeButton", 3)
break
case "Borders":
if (isLogTrace) log.trace("appButtonHandler: Clicked on Borders")
app.updateSetting("activeButton", 4)
break
case "Rows":
if (isLogTrace) log.trace("appButtonHandler: Clicked on Rows")
app.updateSetting("activeButton", 5)
break
case "Footer":
if (isLogTrace) log.trace("appButtonHandler: Clicked on Footer")
app.updateSetting("activeButton", 6)
break
case "Highlights":
if (isLogTrace) log.trace("appButtonHandler: Clicked on Highlights")
app.updateSetting("activeButton", 7)
break
case "Styles":
if (isLogTrace) log.trace("appButtonHandler: Clicked on Styles")
app.updateSetting("activeButton", 8)
break
case "Advanced":
if (isLogTrace) log.trace("appButtonHandler: Clicked on Advanced")
app.updateSetting("activeButton", 9)
break
case "test":
test()
break
case "copyOverrides":
if (isLogTrace) log.trace("appButtonHandler: Clicked on copyOverrides")
state.flags.isCopyOverridesHelperCommand = true
break
case "appendOverrides":
if (isLogTrace) log.trace("appButtonHandler: Clicked on appendOverrides")
state.flags.isAppendOverridesHelperCommand = true
break
case "clearOverrides":
if (isLogTrace) log.trace("appButtonHandler: Clicked on clearOverrides")
state.flags.isClearOverridesHelperCommand = true
break
case "applyStyle":
if (isLogTrace) log.trace("appButtonHandler: Clicked on applyStyle")
myStyle = loadStyle(applyStyleName.toString())
applyStyle(myStyle)
refreshTable()
break
case "saveStyle":
if (isLogTrace) log.trace("appButtonHandler: Clicked on saveStyle")
saveCurrentStyle(saveStyleName)
state.flags.styleSaved = true
break
case "deleteStyle":
if (isLogTrace) log.trace("appButtonHandler: Clicked on deleteStyle")
deleteSelectedStyle(deleteStyleName)
break
case "importStyle":
if (isLogTrace) log.trace("appButtonHandler: Clicked on Importing Style")
app.updateSetting("overrides", importStyleOverridesText)
def myImportMap = [:]
def myOverridesMap = [:]
//Add an overrides item to the the empty map.
myOverridesMap.overrides = importStyleOverrides
//Convert the base settings string to a map.
myImportMap = importStyleString(settings.importStyleText)
myImportStyle = myImportMap.clone()
applyStyle(myImportStyle)
break
case "clearImport":
if (isLogTrace) log.trace("appButtonHandler: Clicked on clearImport")
app.updateSetting("importStyleText", "")
app.updateSetting("importStyleOverridesText", "")
break
case "publishSubscribe":
publishSubscribe()
break
case "unsubscribe":