-
Notifications
You must be signed in to change notification settings - Fork 2
/
Tile_Builder_Grid.groovy
3514 lines (3096 loc) · 219 KB
/
Tile_Builder_Grid.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
// hubitat start
// hub: 192.168.0.200 <- this is hub's IP address
// type: app <- valid values here are "app" and "device"
// id: 1084 <- this is app or driver's id
// hubitat end
//This only works of the destination Hub is running the appropriate Beta version of the Hubitat firmware.
/** Authors Notes:
* For more information on Tile Builder Grid check out these resources.
* Original posting on Hubitat Community forum: https://community.hubitat.com/t/release-tile-builder-build-beautiful-tiles-of-tabular-data-for-your-dashboard/118822
* Tile Builder Documentation: https://github.com/GaryMilne/Hubitat-TileBuilder/blob/main/Tile%20Builder%20Grid%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. TileBuilderApp@gmail.com
*
* 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 - Initial Public Release
* Version 1.0.1 - Added %lastOpen% and %lastClosed% as variables for contacts. Added logic to handle device with a deviceLabel of null. Added logic for Boolean values to dataType(). Cleanup up some logging.
* Version 1.0.2 - Bugfix: Fixed typo in line 969\970
* Version 1.0.3 - Added Try\Catch logic around device\hub variable retrieval in the event of a deleted or renamed device or hub variable. Split %lastEvent% into %lastEvent% (changed attribute) and %lastEventValue% (changed attribute value)
* Version 1.0.4 - Bugfix: Fixes issue with incomplete subscriptions when in Device Group mode.
* Version 1.0.5 - Bugfix: Fixes issue where only the first first attribute of interest would be subscribed correctly when in Device Group mode.
* Version 1.0.6 - Breaks out attribute subscription to a separate function and adds improved error handling and logging.
* Version 1.0.7 - Bugfix: Corrects error where switching from Device Group to Free From prevents multiple rows from being displayed. Adds function checkNulls() to check for any unhandled null values introduced by the user selecting "No Selection" from a dialog box.
* Version 1.0.8 - Bugfix: Keywords not working properly, needed Break statements to exit case statement correctly. Eliminates "double refresh" resulting from the "Refresh" action.
* Version 1.0.9 - Feature: Added %deviceID% to allow creation of Dynamic URL's using keyword substitution. Some cosmetic changes to Keyword screen.
* Version 1.0.9A - Bugfix: Performed datatype check on line 896. Version not revved!
* Version 1.1.0 - Feature: Added %sunrise%, %sunset% variables with variations. (Unreleased)
* Version 1.2.0 - Features: Added input options for Device Details and Hub Properties when using Free Form mode. Improved logging and minor UI tweaks. (Unreleased)
* Version 2.0.0 - Complete overhaul - see documentation. Preliminary release April 2024. Production release May 18, 2024.
* Version 2.0.1 - Bugfix: Spurious characters causing errors.
* Version 2.0.2 - Bugfix: Missing controls under certain null conditions.
*
* Gary Milne - May 20th, 2024 2:18 PM
*
**/
//file:noinspection GroovyVariableNotAssigned
//file:noinspection GroovyVariableNotAssigned
//file:noinspection GroovyAssignabilityCheck
//file:noinspection GrEqualsBetweenInconvertibleTypes
import groovy.transform.Field
import java.text.SimpleDateFormat
import java.util.Date
import java.time.LocalDate
import java.time.LocalDateTime
import java.text.ParseException
import java.util.regex.Pattern
//These are supported capabilities. Layout is "device.selector":["attribute","attribute2"].
static def capabilities() {
return ["accelerationSensor" : ["acceleration"], "airQuality": ["airQualityIndex"], "alarm": ["alarm"], "audioVolume": ["mute", "volume"], "battery": ["battery"], "beacon": ["presence"], "bulb": ["switch"], "button": ["button", "holdableButton", "numberOfButtons"],
"carbonDioxideMeasurement": ["carbonMonoxide"], "carbonMonoxideDetector": ["carbonMonoxide"], "chime": ["soundEffects", "soundName"], "colorControl": ["RGB", "color", "colorName", "hue", "saturation"], "colorMode": ["CT", "RGB", "EFFECTS"],
"colorTemperature" : ["colorName", "colorTemperature"], "consumable": ["consumableStatus"], "contactSensor": ["contact"], "currentMeter": ["amperage"], "doorControl": ["door"], "doubleTappableButton": ["doubleTapped", "doubleTap", "buttonNumber"],
"energyMeter" : ["energy"], "estimatedTimeOfArrival": ["eta"], "fanControl": ["speed", "supportedFanSpeeds"], "filterStatus": ["filterStatus"], "flash": ["rateToFlash"], "garageDoorControl": ["door"], "gasDetector": ["naturalGas"], "healthCheck": ["healthCheck"],
"holdableButton" : ["held", "buttonNumber"], "illuminanceMeasurement": ["illuminance"], "imageCapture": ["image"], "indicator": ["indicatorStatus"], "levelPreset": ["levelPreset"], "light": ["switch"], "lightEffects": ["effectName", "lightEffects"],
"liquidFlowRate" : ["rate"], "locationMode": ["mode"], "lock": ["lock"], "lockCodes": ["codeChanged", "lockCodes", "maxCodes"], "mediaController": ["activities", "currentActivity"], "mediaInputSource": ["supportedInputs", "mediaInputSource"],
"mediaTransport" : ["transportStatus"], "motionSensor": ["motion"], "musicPlayer": ["level", "mute", "status", "trackData", "trackDescription"], "outlet": ["switch"], "powerMeter": ["power"], "powerSource": ["powerSource"], "presenceSensor": ["presence"],
"pressureMeasurement" : ["pressure"], "pushableButton": ["numberOfButtons", "pushed"], "relativeHumidityMeasurement": ["humidity"], "relaySwitch": ["switch"], "releasableButton": ["released"], "samsungTV": ["messageButton", "mute", "pictureMode", "soundMode", "volume"],
"securityKeypad" : ["codeChanged", "codeLength", "lockCodes", "maxCodes", "securityKeypad"], "shockSensor": ["shock"], "signalStrength": ["ldi", "rssi"], "sleepSensor": ["sleeping"], "smokeDetector": ["smoke"], "soundPressureLevel": ["soundPressureLevel"],
"soundSensor" : ["sound"], "speechRecognition": ["phraseSpoken"], "stepSensor": ["goal", "steps"], "switch": ["switch"], "switchLevel": ["level", "duration"], "tv": ["channel", "movieMode", "picture", "power", "sound", "volume"], "tamperAlert": ["tamper"], "telnet": ["networkStatus"],
"temperatureMeasurement" : ["temperature"], "thermostat": ["coolingSetpoint", "thermostatFanMode", "thermostatHeatingSetpoint", "thermostatMode", "thermostatOperatingState", "thermostatSchedule", "thermostatSetpoint"], "threeAxis": ["threeAxis"],
"timedSession" : ["sessionStatus", "timeRemaining"], "touchSensor": ["touch"], "ultravioletIndex": ["ultravioletIndex"], "valve": ["valve"], "variable": ["variable"], "videoCamera": ["camera", "mute", "settings"], "videoCapture": ["clip"],
"voltageMeasurement" : ["voltage", "frequency"], "waterSensor": ["water"], "windowBlind": ["position", "windowBlind", "tilt"], "windowShade": ["position", "windowShade"], "zwMultichannel": ["epEvent", "epInfo"], "pHMeasurement": ["pH"]]
}
static def codeDescription() { return ("<b>Tile Builder Grid v2.0.2 (5/20/24)</b>") }
static def codeVersion() { return (202) }
static def cleanups() {
return ["None", "Capitalize", "Capitalize All", "Commas", "0 Decimal Places", "1 Decimal Place", "Upper Case", "OW Code to Emoji", "OW Code to PNG", "Image URL", "Remove Tags [] <>"]
}
static def dateFormatsMap() {
return [1: "To: yyyy-MM-dd HH:mm:ss.SSS", 2: "To: HH:mm", 3: "To: h:mm a", 4: "To: HH:mm:ss", 5: "To: h:mm:ss a", 6: "To: E HH:mm", 7: "To: E h:mm a", 8: "To: EEEE HH:mm", 9: "To: EEEE h:mm a", 10: "To: MM-dd HH:mm", 11: "To: MM-dd h:mm a", \
12: "To: MMMM dd HH:mm", 13: "To: MMMM dd h:mm a", 14: "To: yyyy-MM-dd HH:mm", 15: "To: dd-MM-yyyy h:mm a", 16: "To: MM-dd-yyyy h:mm a", 17: "To: E @ h:mm a", \
21: "To: Elapsed Time (dd):hh:mm:ss", 22: "To: Elapsed Time (dd):hh:mm", 23: "To: Remaining Time (dd):hh:mm:ss", 24: "To: Remaining Time (dd):hh:mm"]
}
static def dateFormatsList() { return dateFormatsMap().values() }
static def deviceDetailDurations() {
return ["lastOnDuration", "lastOffDuration", "lastOpenDuration", "lastClosedDuration", "lastLockedDuration", "lastUnlockedDuration", "lastPresentDuration", "lastNotPresentDuration", "lastActiveDuration", "lastInactiveDuration"]
}
static def deviceDetails() {
return ["deviceID", "deviceName", "deviceLabel", "lastActivity", "roomName", "lastOn", "lastOff", "lastOpen", "lastClosed", "lastEventName", "lastEventValue", "lastLocked", "lastUnlocked", "lastEventDescription", "lastEventType",
"lastPresent", "lastNotPresent", "lastActive", "lastInactive"].sort() + deviceDetailDurations()
}
static def hubProperties() {
return ["sunrise", "sunset", "sunriseTomorrow", "sunsetTomorrow", "hubName", "hsmStatus", "currentMode", "firmwareVersionString", "uptime", "timeZone", "daylightSavingsTime", "currentTime"].sort()
}
static def rules() {
return ["None", "All Keywords", "All Thresholds", "Threshold 1", "Threshold 2", "Threshold 3", "Threshold 4", "Threshold 5", "Format Rule 1", "Format Rule 2", "Format Rule 3", "Replace Chars"]
}
static def invalidAttributeStrings() { return ["N/A", "n/a", " ", "-", "--", "?", "??"] }
//These are the data for the pickers used on the child forms.
static def elementSize() {
return ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '30', '40', '50', '75', '100']
}
static def textScale() {
return ['50', '55', '60', '65', '70', '75', '80', '85', '90', '95', '100', '105', '110', '115', '120', '125', '130', '135', '140', '145', '150', '175', '200', '250', '300', '350', '400', '450', '500']
}
static def fontFamily() {
return ['Arial', 'Arial Sans Serif', 'Arial Black', 'Brush Script MT', 'Comic Sans MS', 'Courier New', 'Garamond', 'Georgia', 'Hubitat', 'Lucid', 'Monospace', 'Palatino', 'Roboto', 'Tahoma', 'Times New Roman', 'Trebuchet MS', 'Verdana']
}
static def borderStyle() {
return ['Dashed', 'Dotted', 'Double', 'Groove', 'Hidden', 'Inset', 'Outset', 'Ridge', 'Solid']
}
static def tableStyle() { return ['Collapse', 'Seperate'] }
static def textAlignment() { return ['Left', 'Center', 'Right', 'Justify'] }
static def tableSize() { return ['Auto', '50', '55', '60', '65', '70', '75', '80', '85', '90', '95', '100'] }
static def opacity() { return ['1', '0.9', '0.8', '0.7', '0.6', '0.5', '0.4', '0.3', '0.2', '0.1', '0'] }
static def inactivityTime() {
return [0: '0 hours', 1: '1 hour', 2: '2 hours', 4: '4 Hours', 8: '8 hours', 12: '12 hours', 24: '1 day', 48: '2 days', 72: '3 days', 168: '1 week', 336: '2 weeks', 730: '1 month', 2190: '3 months', 4380: '6 months', 8760: '1 year']
}
static def deviceLimit() {
return [0: '0 devices', 1: '1 device', 2: '2 devices', 3: '3 devices', 4: '4 devices', 5: '5 devices', 6: '6 devices', 7: '7 devices', 8: '8 devices', 9: '9 devices', 10: '10 devices', 11: '11 device', 12: '12 devices', 13: '13 devices', 14: '14 devices', 15: '15 devices', 16: '16 devices', 17: '17 devices', 18: '18 devices', 19: '19 devices', 20: '20 devices', 21: '21 device', 22: '22 devices', 23: '23 devices', 24: '24 devices', 25: '25 devices', 26: '26 devices', 27: '27 devices', 28: '28 devices', 29: '29 devices', 30: '30 devices']
}
static def truncateLength() {
return [99: 'No truncation.', 98: 'First Space', 97: 'Second Space', 96: 'Third Space', 95: 'Fourth Space', 94: 'Fifth Space', 93: 'Sixth Space', 10: '10 characters.', 12: '12 characters.', 15: '15 characters.', 18: '18 characters.', 20: '20 characters.', 22: '22 characters.', 25: '25 characters.', 30: '30 characters.']
}
static def refreshInterval() {
return [0: 'Never', 1: '1 minute', 2: '2 minutes', 5: '5 minutes', 10: '10 minutes', 15: '15 minutes', 30: '30 minutes', 60: '1 hour', 120: '2 hours', 240: '4 hours', 480: '8 hours', 720: '12 hours', 1440: '24 hours']
}
static def pixels() {
return ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '-1', '-2', '-3', '-4', '-5', '-6', '-7', '-8', '-9', '-10', '-11', '-12', '-13', '-14', '-15', '-16', '-17', '-18', '-19', '-20']
}
static def borderRadius() {
return ['0', '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']
}
static def baseFontSize() {
return ['10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '22', '24', '26', '28', '30', '32', '34', '36', '38', '40']
}
static def tilePreviewList() {
return [1: '1 x 1', 2: '1 x 2', 3: '1 x 3', 4: '1 x 4', 5: '2 x 1', 6: '2 x 2', 7: '2 x 3', 8: '2 x 4', 9: '2 x 5', 10: '3 x 1', 11: '3 x 2', 12: '3 x 3', 13: '3 x 4', 14: '3 x 5']
}
static def allTileList() {
return [1: 'tile1', 2: 'tile2', 3: 'tile3', 4: 'tile4', 5: 'tile5', 6: 'tile6', 7: 'tile7', 8: 'tile8', 9: 'tile9', 10: 'tile10', 11: 'tile11', 12: 'tile12', 13: 'tile13', 14: 'tile14', 15: 'tile15', 16: 'tile16', 17: 'tile17', 18: 'tile18', 19: 'tile19', 20: 'tile20', 21: 'tile21', 22: 'tile22', 23: 'tile23', 24: 'tile24', 25: 'tile25']
}
static def filterList() {
return [0: 'No Filter', 1: 'String ==', 2: 'String !=', 3: 'Numeric ==', 4: 'Numeric <=', 5: 'Numeric >=']
}
static def overrideCategory() {
return ['Animation', 'Background', 'Border', 'Cell Operations', 'Classes', 'Field Replacement', 'Font', 'Margin & Padding', 'Misc', 'Text', 'Transform']
}
static def messageList() {
return ['clearOverrides', 'disableOverrides', 'disableKeywords', 'disableThresholds', 'clearDeviceList', 'clearIconBarADevices', 'clearIconBarBDevices']
}
static def unitsMap() {
return ['None', '°F', '_°F', '°C', '_°C', '%', '_%', 'A', '_A', 'V', '_V', 'W', '_W', 'kWh', '_kWH', 'K', '_K', 'ppm', '_ppm', 'lx', '_lx']
}
static def comparators() { return [0: 'None', 1: '<=', 2: '==', 3: '>='] }
static def htmlScrubLevel() { return [0: 'Basic', 1: 'Normal', 2: 'Aggressive', 3: 'Extreme'] }
static def durationsMap() {
[lastOnDuration : ["lastOn", "lastOff"], lastOffDuration: ["lastOff", "lastOn"], lastOpenDuration: ["lastOpen", "lastClosed"], lastClosedDuration: ["lastClosed", "lastOpen"], lastUnlockedDuration: ["lastUnlocked", "lastLocked"],
lastLockedDuration: ["lastLocked", "lastUnlocked"], lastPresentDuration: ["lastPresent", "lastNotPresent"], lastNotPresentDuration: ["lastNotPresent", "lastPresent"], lastActiveDuration: ["lastActive", "lastInactive"], lastInactiveDuration: ["lastInactive", "lastActive"]]
}
definition(
name: "Tile Builder - Grid",
description: "Monitors multiple attributes for a grid of device information. 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/Grid.groovy",
namespace: "garyjmilne", author: "Gary J. Milne", category: "Utilities", iconUrl: "", iconX2Url: "", iconX3Url: "", singleThreaded: true, parent: "garyjmilne:Tile Builder", installOnOpen: true
)
preferences { page(name: "mainPage") }
def mainPage() {
if (isLogAppPerformance) log.info("Start of Main Page: " + (now() - state.refresh) / 1000 + " seconds")
//Basic initialization for the initial release
if (state.initialized == null) initialize()
checkNulls()
//Handles the initialization of new variables added after the original release.
if (state.variablesVersion == null || state.variablesVersion < codeVersion()) updateVariables()
//Checks to see if there are any messages for this child app. This is used to recover broken child apps from certain error conditions
myMessage = parent.messageForTile(app.label)
if (myMessage != "") supportFunction(myMessage)
//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()
//This causes refresh to run every time the page is refreshed. It may run twice if the called action also initiates a refresh.
refreshUIbefore()
dynamicPage(name: "mainPage", uninstall: true, install: true, singleThreaded: true) {
//This section is used for the control to go full screen or normal.
//Note: Each use of the paragraph statement takes up some vertical room even though the content itself may not be visible so it is all kept to a single line.
if (isLogAppPerformance) log.info("Start of Full Screen\\Normal Section: " + (now() - state.refresh) / 1000 + " seconds")
section(hideable: false, hidden: false) {
if (state.flags.isEnhancedView == true) {
UIsettings = "<style>#divMainUIMenu{width: 0px !important;}</style>"
UIsettings = UIsettings + "<style>#divMainUIHeader{display:none !important}</style>"
UIsettings = UIsettings + "<style>#divLogoContainer{display:none !important}</style>"
UIsettings = UIsettings + "<style>#divAppUISettings{display:none !important}</style>"
UIsettings = UIsettings + "<style>#divMainUIContentContainer{margin-top: 12px !important}</style>"
paragraph buttonLink('EnhancedView', largeText("⏭️ Tile Builder Grid <b>𝄜</b>"), 0) + UIsettings
} else paragraph buttonLink('EnhancedView', largeText("⏮️ Tile Builder Grid <b>𝄜</b>"), 0) + "<style>h3.pre{display:none !important;}</style>"
}
//Allows the user to select the mode of operation.
if (isLogAppPerformance) log.info("Start of Layout Mode Section: " + (now() - state.refresh) / 1000 + " seconds")
section(hideable: true, hidden: state.hidden.LayoutMode, title: buttonLink('btnHideLayoutMode', getSectionTitle("Layout Mode"), 20)) {
//paragraph buttonLink ("test", "test", 0)
input(name: "layoutMode", title: red("<b>Layout Mode</b>"), type: "enum", options: ["Device Group", "Free Form"], submitOnChange: true, defaultValue: "Device Group", style: "width:10%")
myString = "<b>Tile Builder Grid</b> has two modes of operation:<br>"
myString += "<b>1) Device Group:</b> A Device Group is a set of devices with at least one common attribute such as temperature, switch or contact for example. You fill out a one line template and the table is filled using that template for each device.<br>"
myString += "Device Groups are used for showing the status of a list of devices. For example: A Lights table could show the On/Off status, the Bulb Color and the Dimmer setting for each of the bulbs.<br>"
myString += "<b>2) Free Form:</b> In Free Form you determine the exact size of the table and configure a template for each cell. The template is filled with the actual values at run-time.<br>"
myString += "Free Form mode is suited for showing a lot of mixed attribute data, often from a single device, such as Hub Info, Weather etc or mixed data such as Security or HVAC.<br>"
myString += "In both cases the template is filled out using %variable% to represent an attribute and the can be accompanied by other text such us HTML tags or units. Example: Conditions are [b]%temperature%°F[/b] & [b]%humidity%%RH.[/b]<br>"
myString += "<mark>" + red("<b>Important!!!</b> When you switch between modes the current configuration is wiped and you start over. !!!") + "</mark>."
paragraph summary("Layout Mode", myString)
}
//If the layoutMode has changed we reset everything that matters.
if (state.layoutMode != layoutMode.toString()) {
resetVariables()
}
if (isLogAppPerformance) log.info("Start of Device Group Section: " + (now() - state.refresh) / 1000 + " seconds")
//********************************************************************************************************************************************************************************************
//Start of Device Group Section
if (layoutMode.toString() == "Device Group") {
section(hideable: true, hidden: state.hidden.DeviceGroup, title: buttonLink('btnHideDeviceGroup', getSectionTitle("Device Group"), 20)) {
//This input device list the items by attribute name but actually returns the capability.
input(name: "myCapability", title: "<b>Select Filter (Optional)</b>", type: "enum", options: capabilities().keySet().collect { it }.sort(), submitOnChange: true, width: 2, defaultValue: 1)
if (myCapability != null) input "myDeviceList", "capability.$myCapability", title: "<b>Select Devices</b> " + dodgerBlue("(%deviceLabel%)"), multiple: true, required: false, submitOnChange: true, width: 3
else input "myDeviceList", "capability.*", title: "<b>Select Devices</b> " + dodgerBlue("(%deviceLabel%)"), multiple: true, required: false, submitOnChange: true, width: 3
input(name: "myVariableCount", title: "<b>Variable Count?</b>", type: "enum", options: [1, 2, 3, 4, 5, 6], submitOnChange: true, defaultValue: 0, style: "margin-left:20px; width:10%")
input(name: "myColumns", title: "<b>Column Count?</b>", type: "enum", options: [1, 2, 3, 4, 5], submitOnChange: true, defaultValue: 0, newLineAfter: true, style: "margin-left:20px; width:10%")
def variableCount = myVariableCount.toInteger() != null ? myVariableCount.toInteger() : 0
for (int i = 1; i <= variableCount.toInteger(); i++) {
boolean isNewLine = (i % 4 == 0)
result = "(%" + settings["myAttribute$i"] + "%)" // ?: "N/A"
if (result.contains("null")) result = invalidAttribute.toString()
if (myCapability != null) input(name: "myAttribute${i}", title: dodgerBlue("<b>Variable</b> " + result), type: "enum", options: capabilities().values().collectMany { it }.unique().sort(), submitOnChange: true, defaultValue: "Var${i}", newLine: isNewLine, style: "margin-left:10px;width:12%")
else input (name: "myAttribute${i}", title: dodgerBlue("<b>Variable</b> " + result ), type: "enum", options: capabilities().values().collectMany {it}.unique().sort(), submitOnChange: true, defaultValue: "Var${i}", newLine:isNewLine, style: "margin-left:10px;width:12%")
input "actionA${i}", "enum", title: "<b>Cleanup</b>", options: cleanups(), defaultValue: "None", required: false, submitOnChange: true, newLine: false, style: "margin-left:10px;width:8%"
input "actionB${i}", "enum", title: "<b>Rules</b>", options: rules(), defaultValue: "None", required: false, submitOnChange: true, newLine: false, style: "margin-right:20px;width:8%"
myAttr = settings["myAttribute$i"].toString()
app.updateSetting("name$i", [value: myAttr + i, type: "string"])
}
paragraph summary("Cleanup and Rules Help", parent.textCleanupsRules())
paragraph line(1)
input "gatherDeviceDetails", "enum", title: "<b>Gather Device Details</b>", options: deviceDetails(), multiple: true, submitOnChange: true, width: 4, required: false, newLine: false
input(name: "defaultDateTimeFormat", title: "<b>Default Date Time Format</b>", type: "enum", options: dateFormatsMap(), submitOnChange: true, defaultValue: 1, width: 2)
input(name: "myTruncateLength", title: "<b>Truncate Device Name\\Label</b>", type: "enum", options: truncateLength(), submitOnChange: true, defaultValue: 99, width: 2)
input(name: "invalidAttribute", title: "<b>Invalid Attribute String</b>", type: "enum", options: invalidAttributeStrings(), submitOnChange: true, defaultValue: "N/A", width: 2)
paragraph line(2)
def myColumnWidth = 12 / myColumns.toInteger()
for (j = 1; j <= myColumns.toInteger(); j++) {
if (j == 1) input "Template${j}", "string", title: "<b>Template Column ${j}</b>", submitOnChange: true, defaultValue: "%deviceLabel%", newLine: false, width: myColumnWidth.toInteger()
else input "Template${j}", "string", title: "<b>Template Column ${j}</b>", submitOnChange: true, defaultValue: "%variable%", newLine: false, width: myColumnWidth.toInteger()
}
paragraph summary("Text Fields and Variables Help", parent.textFieldNotesGrid())
//Assemble all the variables into strings and display them if at least 1 variable has been defined.
createCellTemplates()
varString = getVariablesDeviceGroup()
makeTable()
}
}
//End of Device Group Section
//********************************************************************************************************************************************************************************************
//********************************************************************************************************************************************************************************************
//Start of Free Form Layout Section
if (isLogAppPerformance) log.info("Start of Free Form Section: " + (now() - state.refresh) / 1000 + " seconds")
if (layoutMode.toString() == "Free Form") {
//Start of variables section
section(hideable: true, hidden: state.hidden.Variables, title: buttonLink('btnHideVariables', getSectionTitle("Variables"), 20)) {
input(name: "myVariableCount", title: "<b>Variable Count?</b>", type: "enum", options: [0, 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], submitOnChange: true, defaultValue: 0, style: "width:10%")
input(name: "varColumns", title: "<b>Variable Columns?</b>", type: "enum", options: [1, 2], submitOnChange: true, defaultValue: 1, style: "margin-left:20px; width:10%")
input "showVariables", "enum", title: "<b>Show Variables?</b>", options: ["Hide Variables", "Show Variables", "Show Variables & HTML"], defaultValue: "Show Variables", required: false, submitOnChange: true, width: 2, newLine: false, style: "width:12%;margin-left:20px;"
input "defaultDevice", "capability.*", title: "<b>Default Device</b> (Optional)", multiple: false, required: false, submitOnChange: true, newLine: false, style: "width:12%;margin-left:20px;"
input(name: "invalidAttribute", title: "<b>Invalid Attribute String</b>", type: "enum", options: invalidAttributeStrings(), submitOnChange: true, defaultValue: "N/A", style: "width:12%;margin-left:20px;")
def variableCount = myVariableCount.toInteger() != null ? myVariableCount.toInteger() : 0
if (myVariableCount.toInteger() > 0) input(name: 'btnClearLastVariable', type: 'button', title: ("Clear Var " + myVariableCount.toString() + "<hr>"), backgroundColor: '#00a2ed', textColor: 'yellow', submitOnChange: true, width: 1, style: "margin-left:20px;")
input(name: "Refresh", type: "button", title: "Submit Changes", backgroundColor: "#27ae61", textColor: "white", submitOnChange: true, width: 1)
for (int i = 1; i <= variableCount; i++) {
boolean isEven = (i % 2 == 0)
if (varColumns.toInteger() == 1) isEven = false
if (!isEven) input "variableSource${i}", "enum", title: dodgerBlue("<b>Source #$i</b>"), options: ["Default Device", "Device Attribute", "Device Detail", "Hub Property", "Hub Variable"], submitOnChange: true, width: 1, defaultValue: "Default Device", newLine: !isEven, style: varColumns == "1" ? "width:12%" : "width:8%"
else input "variableSource${i}", "enum", title: dodgerBlue("<b>Source #$i</b>"), options: ["Default Device", "Device Attribute", "Device Detail", "Hub Property", "Hub Variable"], submitOnChange: true, width: 1, defaultValue: "Default Device", newLine: !isEven, style: varColumns == "1" ? "width:12%" : "width:8%; margin-left:20px;"
input "name${i}", "string", title: "<b>Var Name</b>", submitOnChange: true, width: 1, defaultValue: "Var${i}", newLine: false, style: varColumns == "1" ? "width:6%" : "width:6%;margin-left:10px"
if (settings["variableSource${i}"] == "Default Device") {
input "myAttribute${i}", "enum", title: " <b>Attribute</b>", options: getAttributeList(settings["defaultDevice"]), multiple: false, submitOnChange: true, width: 2, required: false, newLine: false, style: varColumns == "1" ? "margin-left:20px;width:26.5%" : "margin-left:10px;width:16.5%"
myDevice$i = null
}
if (settings["variableSource${i}"] == "Device Attribute") {
input "myDevice${i}", "capability.*", title: "<b>Device</b>", multiple: false, required: false, submitOnChange: true, width: 2, newLine: false, style: varColumns == "1" ? "margin-left:20px; width:13.5%" : "margin-left:10px;width:8%"
input "myAttribute${i}", "enum", title: " <b>Attribute</b>", options: getAttributeList(settings["myDevice${i}"]), multiple: false, submitOnChange: true, width: 2, required: true, newLine: false, style: varColumns == "1" ? "margin-left:20px;width:12%" : "margin-left:10px;width:8%"
}
if (settings["variableSource${i}"] == "Device Detail") {
input "myDevice${i}", "capability.*", title: "<b>Device</b>", multiple: false, required: false, submitOnChange: true, width: 2, newLine: false, style: varColumns == "1" ? "margin-left:20px; width:13.5%" : "margin-left:10px;width:8%"
input "myAttribute${i}", "enum", title: " <b>Device Detail</b>", options: deviceDetails(), multiple: false, submitOnChange: true, width: 2, required: true, newLine: false, style: varColumns == "1" ? "margin-left:20px;width:12%" : "margin-left:10px;width:8%"
}
if (settings["variableSource${i}"] == "Hub Property") {
//input "myDevice${i}", "capability.*", title: "<b>Device</b>", multiple: false, required: false, submitOnChange: true, width: 2, newLine: false, style: varColumns == "1" ? "margin-left:20px; width:13.5%" : "margin-left:10px;width:8%"
input "myAttribute${i}", "enum", title: " <b>Hub Property</b>", options: hubProperties(), multiple: false, submitOnChange: true, width: 2, required: true, newLine: false, style: varColumns == "1" ? "margin-left:20px;width:26.5%" : "margin-left:10px;width:16.5%"
}
if (settings["variableSource${i}"] == "Hub Variable") {
input "myHubVariable${i}", "enum", title: "<b>Hub Variable</b>", submitOnChange: true, width: 2, options: getAllGlobalVars().findAll { it.value.type != null }.keySet().collect().sort { it.capitalize() }, style: varColumns == "1" ? "margin-left:20px;width:26.5%" : "margin-left:10px;width:16%"
}
input "actionA${i}", "enum", title: "<b>Cleanup</b>", options: cleanups() + dateFormatsList(), defaultValue: "None", required: false, submitOnChange: true, width: 2, newLine: false, style: varColumns == "1" ? "margin-left:10px;width:15%" : "margin-left:5px;width:8%"
input "actionB${i}", "enum", title: "<b>Rules</b>", options: rules(), defaultValue: "None", required: false, submitOnChange: true, newLine: false, style: varColumns == "1" ? "margin-left:10px;width:12%" : "margin-left:5px;width:8%"
}
input(name: "Refresh", type: "button", title: "Submit Changes", backgroundColor: "#27ae61", textColor: "white", submitOnChange: true, width: 1)
paragraph summary("Cleanup and Rules Help", parent.textCleanupsRules())
//Assemble all the variables into strings and display them if at least 1 variable has been defined.
varString = getVariablesFreeForm()
//Only populate this line if there is at least one variable populated and we are using Grid Mode Free Form.
if ((variableSource1 != null) && showVariables != "Hide Variables") {
paragraph line(1); paragraph state.highlightStyles + varString
}
makeTable()
}
//End of variables section
//Show the value of the variables even when the variables section is closed.
section { if (state.hidden.Variables == true && variableSource1 != null) { paragraph line(1); paragraph state.highlightStyles + varString } }
//Start of Grid Layout section
section(hideable: true, hidden: state.hidden.GridLayout, title: buttonLink('btnHideGridLayout', getSectionTitle("Grid Layout"), 20)) {
if (isLogAppPerformance) log.info("Start of Grid Layout Section: " + (now() - state.refresh) / 1000 + " seconds")
input(name: "rows", title: "<b>How Many Data Rows?</b>", type: "enum", options: [0, 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], submitOnChange: true, width: 2, defaultValue: 0)
input(name: "myColumns", title: "<b>How Many Data Columns?</b>", type: "enum", options: [1, 2, 3, 4, 5], submitOnChange: true, width: 2, defaultValue: 0)
input(name: "autoRefreshGrid", title: "<b>Auto Refresh Table on Save?</b>", type: "enum", options: ["True", "False"], submitOnChange: true, width: 2, defaultValue: "True", newLineAfter: true)
//noinspection GroovyUnusedAssignment
def columnWidth = 12 / myColumns.toInteger()
for (int i = 1; i <= rows.toInteger(); i++) {
for (j = 1; j <= myColumns.toInteger(); j++) {
def isNewLineAfter = true
def cell = "R${i}C${j}"
if (j / myColumns.toInteger() < 1) isNewLineAfter = false
input "$cell", "string", title: italic("<b>${cell}</b>"), submitOnChange: (autoRefreshGrid != null) ? autoRefreshGrid.toBoolean() : false, defaultValue: "?", newLine: false, newLineAfter: isNewLineAfter, width: columnWidth.toInteger()
}
}
paragraph line(1)
paragraph summary("Text Fields and Variables Help", parent.textFieldNotesGrid())
} //End of Grid Layout Section
}
// End of Free Form Layout
//********************************************************************************************************************************************************************************************
//Start of Design Table Section
section(hideable: true, hidden: state.hidden.Design, title: buttonLink('btnHideDesign', getSectionTitle("Design"), 20)) {
if (isLogAppPerformance) log.info("Start of Design Table Section: " + (now() - state.refresh) / 1000 + " seconds")
//Section for customization of the table.
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)
//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.
part3 = "<td>" + buttonLink('Highlights', 'Highlights', 7) + "</td><td>" + buttonLink('Styles', 'Styles', 8) + "</td><td>" + buttonLink('Advanced', 'Advanced', 9) + "</td>"
table = part1 + part2 + part3 + "</table>"
paragraph table
//General Properties
if (activeButton == 1) {
if (isLogAppPerformance) log.info("Start of General Properties Section: " + (now() - state.refresh) / 1000 + " seconds")
if (isCompactDisplay == false) paragraph titleise("General Properties")
input(name: "tw", type: "enum", title: bold("Table Width %"), options: tableSize(), required: false, defaultValue: "90", submitOnChange: true, width: 1)
input(name: "th", type: "enum", title: bold("Table Height %"), options: tableSize(), required: false, defaultValue: "auto", submitOnChange: true, width: 1)
input(name: "tbc", type: "color", title: bold2("Background Color", tbc), required: false, defaultValue: "#ffffff", width: 2, submitOnChange: true, style: "width:15%")
input(name: "tbo", type: "enum", title: bold("Background Opacity"), options: opacity(), required: false, defaultValue: "1", submitOnChange: true, style: "width:10%")
input(name: "tff", type: "enum", title: bold("Font"), options: fontFamily(), required: false, defaultValue: "Roboto", submitOnChange: true, width: 1, style: "width:10%")
input(name: "bm", type: "enum", title: bold("Border Mode"), options: tableStyle(), required: false, defaultValue: "collapse", submitOnChange: true, width: 1)
input(name: "bfs", type: "enum", title: bold("Base Font Size"), options: baseFontSize(), required: false, defaultValue: "18", submitOnChange: true, width: 1)
input(name: "iFrameColor", type: "color", title: bold2("Dashboard Color", iFrameColor), required: false, defaultValue: "#000000", submitOnChange: true, style: "width:15%", newLine: true)
input(name: "tilePreviewWidth", type: "enum", title: bold("Preview Width (x200px)"), options: [1, 2, 3, 4, 5, 6, 7, 8], required: false, defaultValue: 2, submitOnChange: true, style: "width:12%")
input(name: "tilePreviewHeight", type: "enum", title: bold("Preview Height (x190px)"), options: [1, 2, 3, 4, 5, 6, 7, 8], required: false, defaultValue: 2, submitOnChange: true, style: "width:12%")
input(name: "isComment", type: "bool", title: "<b>Add comment?</b>", required: false, multiple: false, defaultValue: false, submitOnChange: true, width: 1, style: "width:10%")
if (isComment == true) {
input(name: "comment", type: "text", title: bold("Comment"), required: false, defaultValue: "?", width: 3, submitOnChange: true)
}
input(name: "isFrame", type: "bool", title: bold("Add Frame"), required: false, multiple: false, defaultValue: false, submitOnChange: true, width: 2)
if (isFrame == true) {
input(name: "fbc", type: "color", title: bold2("Frame Color", fbc), required: false, defaultValue: "#90C226", submitOnChange: true, width: 3)
}
if (isCompactDisplay == false) {
paragraph line(1)
paragraph summary("General Notes", parent.generalNotes())
}
}
//Title Properties
if (activeButton == 2) {
if (isLogAppPerformance) log.info("Start of Title Properties Section: " + (now() - state.refresh) / 1000 + " seconds")
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, style: "width:10%")
if (isTitle == true) {
input(name: "tt", title: "<b>Title Text</b>", type: "string", required: false, defaultValue: "My Title", width: 3, submitOnChange: true)
input(name: "ts", type: "enum", title: bold("Text Size %"), options: textScale(), required: false, defaultValue: "150", submitOnChange: true, style: "width:10%")
input(name: "ta", type: "enum", title: bold("Alignment"), options: textAlignment(), required: false, defaultValue: "Center", width: 2, submitOnChange: true, style: "width:10%")
input(name: "tc", type: "color", title: bold2("Text Color", tc), required: false, defaultValue: "#000000", width: 3, submitOnChange: true, style: "width:15%")
input(name: "to", type: "enum", title: bold("Text Opacity"), options: opacity(), required: false, defaultValue: "1", submitOnChange: true, style: "width:10%")
input(name: "tp", type: "enum", title: bold("Text Padding"), options: elementSize(), required: false, defaultValue: "0", width: 2, submitOnChange: true, style: "width:10%")
}
if (isCompactDisplay == false) {
paragraph line(1)
paragraph summary("Title Notes", parent.titleNotes())
}
}
//Header Properties
if (activeButton == 3) {
if (isLogAppPerformance) log.info("Start of Header Properties Section: " + (now() - state.refresh) / 1000 + " seconds")
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, style: "width:10%")
if (isHeaders == true) {
//Manage the UI if the headers are merged.
input(name: "isMergeHeaders", type: "enum", title: bold("Merge Headers"), options: ["Do Not Merge", "Merge All", "Merge 2 & 3", "Merge 2, 3 & 4"], required: false, defaultValue: "Do Not Merge", submitOnChange: true, style: "width:10%", newLineAfter: true)
input(name: "R0C1", type: "text", title: bold("Heading 1"), required: false, defaultValue: "Device", submitOnChange: true, width: 2)
if (myColumns.toInteger() >= 2) input(name: 'R0C2', type: 'text', title: bold('Heading 2'), required: false, defaultValue: 'State', submitOnChange: true, width: 2)
if (myColumns.toInteger() >= 3) input(name: 'R0C3', type: 'text', title: bold('Heading 3'), required: false, defaultValue: 'Other 1', submitOnChange: true, width: 2)
if (myColumns.toInteger() >= 4) input(name: 'R0C4', type: 'text', title: bold('Heading 4'), required: false, defaultValue: 'Other 2', submitOnChange: true, width: 2)
if (myColumns.toInteger() >= 5) input(name: 'R0C5', type: 'text', title: bold('Heading 5'), required: false, defaultValue: 'Other 3', submitOnChange: true, width: 2)
input(name: "hts", type: "enum", title: bold("Text Size %"), options: textScale(), required: false, defaultValue: "125", submitOnChange: true, style: "width:10%", newLine: true)
input(name: "hta", type: "enum", title: bold("Alignment"), options: textAlignment(), required: false, defaultValue: 2, submitOnChange: true, style: "width:10%")
input(name: "htc", type: "color", title: bold2("Text Color", htc), required: false, defaultValue: "#000000", submitOnChange: true, style: "width:15%")
input(name: "hto", type: "enum", title: bold("Text Opacity"), options: opacity(), required: false, defaultValue: "1", submitOnChange: true, style: "width:10%")
input(name: "hp", type: "enum", title: bold("Text Padding"), options: elementSize(), required: false, defaultValue: "0", submitOnChange: true, style: "width:10%")
input(name: "hbc", type: "color", title: bold2("Background Color", hbc), required: false, defaultValue: "#90C226", submitOnChange: true, style: "width:15%")
input(name: "hbo", type: "enum", title: bold("Background Opacity"), options: opacity(), required: false, defaultValue: "1", submitOnChange: true, style: "width:10%")
}
if (isCompactDisplay == false) {
paragraph line(1)
paragraph summary("Header Notes", parent.headerNotes())
}
}
//Border Properties
if (activeButton == 4) {
if (isLogAppPerformance) log.info("Start of Border Properties Section: " + (now() - state.refresh) / 1000 + " seconds")
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, style: "width:10%")
if (isBorder == true) {
input(name: "bs", type: "enum", title: bold("Style"), options: borderStyle(), required: false, defaultValue: "Solid", submitOnChange: true, style: "width:10%")
input(name: "bw", type: "enum", title: bold("Width"), options: elementSize(), required: false, defaultValue: 2, submitOnChange: true, style: "width:10%")
input(name: "bc", type: "color", title: bold2("Border Color", bc), required: false, defaultValue: "#000000", submitOnChange: true, style: "width:15%")
input(name: "bo", type: "enum", title: bold("Opacity"), options: opacity(), required: false, defaultValue: "1", submitOnChange: true, style: "width:10%")
input(name: "br", type: "enum", title: bold("Radius"), options: borderRadius(), required: false, defaultValue: "0", submitOnChange: true, style: "width:10%")
input(name: "bp", type: "enum", title: bold("Padding"), options: elementSize(), required: false, defaultValue: "0", submitOnChange: true, style: "width:10%")
}
if (isCompactDisplay == false) {
paragraph line(1)
paragraph summary("Border Notes", parent.borderNotes())
}
}
//Row Properties
if (activeButton == 5) {
if (isLogAppPerformance) log.info("Start of Row Properties Section: " + (now() - state.refresh) / 1000 + " seconds")
if (isCompactDisplay == false) paragraph titleise("Data Row Properties")
input(name: "rts", type: "enum", title: bold("Text Size %"), options: textScale(), required: false, defaultValue: "100", submitOnChange: true, style: "width:10%")
input(name: "rta", type: "enum", title: bold("Alignment"), options: textAlignment(), required: false, defaultValue: 15, submitOnChange: true, style: "width:10%")
input(name: "rtc", type: "color", title: bold2("Text Color", rtc), required: false, defaultValue: "#000000", submitOnChange: true, style: "width:15%")
input(name: "rto", type: "enum", title: bold("Text Opacity"), options: opacity(), required: false, defaultValue: "1", submitOnChange: true, style: "width:10%")
input(name: "rp", type: "enum", title: bold("Text Padding"), options: elementSize(), required: false, defaultValue: "0", submitOnChange: true, style: "width:10%")
input(name: "rbc", type: "color", title: bold2("Background Color", rbc), required: false, defaultValue: "#BFE373", submitOnChange: true, style: "width:15%")
input(name: "rbo", type: "enum", title: bold("Background Opacity"), options: opacity(), required: false, defaultValue: "1", submitOnChange: true, style: "width:10%")
input(name: "isAlternateRows", type: "bool", title: bold("Use Alternate<br>Row Colors?"), required: false, defaultValue: true, submitOnChange: true, style: "width:10%")
if (isAlternateRows == true) {
input(name: "ratc", type: "color", title: bold2("Alternate Text Color", ratc), required: false, defaultValue: "#000000", submitOnChange: true, style: "width:15%", newLine: true)
input(name: "rabc", type: "color", title: bold2("Alternate Background Color", rabc), required: false, defaultValue: "#E9F5CF", submitOnChange: true, style: "width:15%")
}
if (isCompactDisplay == false) {
paragraph line(1)
paragraph summary("Row Notes", parent.rowNotes())
}
}
//Footer Properties
if (activeButton == 6) {
if (isLogAppPerformance) log.info("Start of Footer Properties Section: " + (now() - state.refresh) / 1000 + " seconds")
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, style: "width:10%")
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: textScale(), required: false, defaultValue: "50", submitOnChange: true, style: "width:10%")
input(name: "fa", type: "enum", title: bold("Alignment"), options: textAlignment(), required: false, defaultValue: "Center", submitOnChange: true, style: "width:10%")
input(name: "fc", type: "color", title: bold2("Text Color", fc), required: false, defaultValue: "#000000", submitOnChange: true, style: "width:15%")
}
if (isCompactDisplay == false) {
paragraph line(1)
paragraph summary("Footer Notes", parent.footerNotes())
}
}
//Highlight Properties
if (activeButton == 7) {
if (isLogAppPerformance) log.info("Start of Highlights Section: " + (now() - state.refresh) / 1000 + " seconds")
if (isCompactDisplay == false) paragraph titleise("Highlights")
//Keywords
if (state.show.Keywords == true) {
input(name: 'btnShowKeywords', type: 'button', title: 'Show Keywords ▼', backgroundColor: 'navy', textColor: 'white', submitOnChange: true, width: 2)
//▼ ◀ ▶ ▲
input(name: "myKeywordCount", title: "<b>How Many Keywords?</b>", type: "enum", options: [0, 1, 2, 3, 4, 5], submitOnChange: true, defaultValue: 0, style: "width:12%;margin-top:-15px;margin-left:-5%", newLineAfter: true)
for (int i = 1; i <= 5; i++) {
if (myKeywordCount.toInteger() >= i) {
input(name: "kop${i}", type: "enum", title: bold("Keyword Match Type"), options: ["Value Matches Keyword (Match Case)", "Value Matches Keyword (Ignore Case)", "Value Contains Keyword (Match Case)", "Value Contains Keyword (Ignore Case)"], defaultValue: "Value Contains Keyword (Ignore Case)", submitOnChange: true, newLine: true, style: "width:17.5%")
input(name: "k${i}", type: "text", title: bold("Keyword #${i}"), required: false, displayDuringSetup: true, defaultValue: "?", submitOnChange: true, newLine: false, style: "width:8%")
input(name: "ktr${i}", type: "text", title: bold("Replacement Text #${i}"), required: false, displayDuringSetup: true, defaultValue: "?", submitOnChange: true, style: "width:50%")
input(name: "hc${i}", type: "color", title: bold2(("Color"), settings["hc$i"]), required: false, submitOnChange: true, style: "width:10%")
input(name: "hts${i}", type: "enum", title: bold("Text Scale"), options: textScale(), required: false, submitOnChange: true, defaultValue: "125", newLineAfter: true, style: "width:9%")
}
}
} else input(name: 'btnShowKeywords', type: 'button', title: 'Show Keywords ▶', backgroundColor: 'dodgerBlue', textColor: 'white', submitOnChange: true, width: 2, newLineAfter: true)
//▼ ◀ ▶ ▲
//Thresholds
if (state.show.Thresholds == true) {
input(name: 'btnShowThresholds', type: 'button', title: 'Show Thresholds ▼', backgroundColor: 'navy', textColor: 'white', submitOnChange: true, width: 2, style: "margin-top:20px")
//▼ ◀ ▶ ▲
input(name: "myThresholdCount", title: "<b>How Many Thresholds?</b>", type: "enum", options: [0, 1, 2, 3, 4, 5], submitOnChange: true, width: 3, defaultValue: 0, style: "width:12%;margin-top:10px;margin-left:-5%", newLineAfter: true)
for (int i = 6; i <= 10; i++) {
if (myThresholdCount.toInteger() >= i - 5) {
myColor = settings["hc$i"]
input(name: "top${i}", type: "enum", title: bold("Operator #${i}"), required: false, options: comparators(), displayDuringSetup: true, defaultValue: 0, submitOnChange: true, width: 1, newLine: true)
input(name: "tcv${i}", type: "number", title: bold("Comparison Value #${i}"), required: false, displayDuringSetup: true, defaultValue: "?", submitOnChange: true, width: 2)
input(name: "ttr${i}", type: "text", title: bold("Replacement Text #${i}"), required: false, displayDuringSetup: true, defaultValue: "?", submitOnChange: true, width: 2)
input(name: "hc${i}", type: "color", title: bold2(("Highlight ${i} Color"), settings["hc$i"]), required: false, submitOnChange: true, width: 2)
input(name: "hts${i}", type: "enum", title: bold("Highlight ${i} Text Scale"), options: 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: 2, newLine: true, newLineAfter: true)
//▼ ◀ ▶ ▲
//FormatRules
if (state.show.FormatRules == true) {
input(name: 'btnShowFormatRules', type: 'button', title: 'Show Format Rules ▼', backgroundColor: 'navy', textColor: 'white', submitOnChange: true, width: 3, newLine: true, newLineAfter: true)
//▼ ◀ ▶ ▲
input(name: "fr1", type: "text", title: bold("Format Rule 1"), required: false, displayDuringSetup: true, defaultValue: "?", submitOnChange: true, width: 10, newLine: true)
input(name: "fr2", type: "text", title: bold("Format Rule 2"), required: false, displayDuringSetup: true, defaultValue: "?", submitOnChange: true, width: 10, newLine: true)
input(name: "fr3", type: "text", title: bold("Format Rule 3"), required: false, displayDuringSetup: true, defaultValue: "?", submitOnChange: true, width: 10, newLine: true, newLineAfter: true)
} else input(name: 'btnShowFormatRules', type: 'button', title: 'Show Format Rules ▶', 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: 3, newLine: true, newLineAfter: 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)
//▼ ◀ ▶ ▲
if (isCompactDisplay == false) {
paragraph line(1)
paragraph summary("Highlighting Help", parent.highlightNotes())
}
}
//Styles
if (activeButton == 8) {
if (isLogAppPerformance) log.info("Start of Styles Section: " + (now() - state.refresh) / 1000 + " seconds")
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 style. 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 input.
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 (isLogAppPerformance) log.info("Start of Advanced Section: " + (now() - state.refresh) / 1000 + " seconds")
if (isCompactDisplay == false) paragraph titleise("Advanced Settings")
input(name: "scrubHTMLlevel", type: "enum", title: bold("HTML Scrub Level"), options: 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: 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 (isLogAppPerformance) log.info("Start of Display Table Section: " + (now() - state.refresh) / 1000 + " seconds")
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
def width = (tilePreviewWidth.toInteger() * 200)
def height = (tilePreviewHeight.toInteger() * 190)
myHTML = """<iframe srcdoc="${myHTML}" width="${width}" height="${height}" style="left:calc((80% - ${width}px) / 5);position:relative" scrolling="no"></iframe>"""
paragraph myHTML
//if (state.HTMLsizes == null) state.HTMLsizes = [Comment: 0, Head: 0, Body: 0, Interim: 0, Final: 0]
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}, 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 = 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
}//End of Design Table Section
//Start of Publish Section
section(hideable: true, hidden: state.hidden.Publish, title: buttonLink('btnHidePublish', getSectionTitle("Publish"), 20)) {
if (isLogAppPerformance) log.info("Start of Publishing Section: " + (now() - state.refresh) / 1000 + " seconds")
myText = "Here you will configure where the table will be stored. It will be refreshed at the frequency you specify."
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: 3, 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: true, 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)
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, newLineAfter: true)
if (myTileName) app.updateLabel(myTileName)
myText = "The <b>Tile Name</b> given here will also be used as the name for this Grid. 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 for TB Grid 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).<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>"
paragraph summary("Publishing Controls", myText)
paragraph line(1)
if (state.HTMLsizes.Final < 4096 && settings.myTile != null && myTileName != null) {
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: true, width: 12)
}
//End of Publish Section
//Start of More Section
section {
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: "isLogTrace", type: "bool", title: "<b>Enable Trace logging?</b>", defaultValue: false, submitOnChange: true, width: 3)
input(name: "isLogVariables", type: "bool", title: "<b>Enable Variables logging?</b>", defaultValue: false, submitOnChange: true, width: 3)
input(name: "isLogCleanups", type: "bool", title: "<b>Enable Cleanups logging?</b>", defaultValue: false, submitOnChange: true, width: 3)
input(name: "isLogHighlights", type: "bool", title: "<b>Enable Highlights logging?</b>", defaultValue: false, submitOnChange: true, width: 3)
input(name: "isLogStyles", type: "bool", title: "<b>Enable Style logging?</b>", defaultValue: false, submitOnChange: true, width: 3, newLine: true)
input(name: "isLogHTML", type: "bool", title: "<b>Enable HTML Assembly logging?</b>", defaultValue: false, submitOnChange: true, width: 3)
input(name: "isLogPublish", type: "bool", title: "<b>Enable Publishing logging?</b>", defaultValue: false, submitOnChange: true, width: 3)
input(name: "isLogDateTime", type: "bool", title: "<b>Enable Date\\Time logging?</b>", defaultValue: false, submitOnChange: true, width: 3)
input(name: "isLogDeviceInfo", type: "bool", title: "<b>Enable Device Details logging?</b>", defaultValue: false, submitOnChange: true, width: 3)
input(name: "isLogAppPerformance", type: "bool", title: "<b>Enable App Performance Logging?</b>", defaultValue: false, submitOnChange: true, width: 3)
input(name: "isLogDetails", type: "bool", title: "<b>Add more detail to each type of logging?</b>", defaultValue: false, submitOnChange: true, width: 3)
}
//Now add a footer.
myDocURL = "<a href='https://github.com/GaryMilne/Hubitat-TileBuilder/blob/main/Tile%20Builder%20Grid%20Help.pdf' target=_blank> <i><b>Tile Builder Grid 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 of More Section
refreshUIafter()
}
}
//*******************************************************************************************************************************************************************************************
//**************
//************** Miscellaneous Functions
//**************
//*******************************************************************************************************************************************************************************************
//Generic placeholder for test function.
def test() {}
//Shortens the displayed version of the Device Name
def truncateName(deviceName) {
if (isLogTrace && isLogDetails) log.info("<b>truncateName: Entering with: deviceName $deviceName and truncate length is ${myTruncateLength.toInteger()} </b>")
//Make sure all of the device names meet the minimum length by padding the end with spaces.
shortName = deviceName + " "
//Truncate the name if required
if (myTruncateLength != null && myTruncateLength.toInteger() == 93) shortName = findSpace(shortName, 6)
if (myTruncateLength != null && myTruncateLength.toInteger() == 94) shortName = findSpace(shortName, 5)
if (myTruncateLength != null && myTruncateLength.toInteger() == 95) shortName = findSpace(shortName, 4)
if (myTruncateLength != null && myTruncateLength.toInteger() == 96) shortName = findSpace(shortName, 3)
if (myTruncateLength != null && myTruncateLength.toInteger() == 97) shortName = findSpace(shortName, 2)
if (myTruncateLength != null && myTruncateLength.toInteger() == 98) shortName = findSpace(shortName, 1)
if (myTruncateLength != null && myTruncateLength.toInteger() <= 30) {
if (deviceName.size() > myTruncateLength.toInteger()) {
shortName = shortName.substring(0, myTruncateLength.toInteger())
}
}
return shortName.trim()
}
//Finds all occurrences of a space within a string and returns the substring from the first character to the specified nth occurrence.
def findSpace(String myDevice, int myOccurrence) {
i = 1
n = myDevice.size()
def spaceList = []
if (n > 30) n = 30
while (i < (n - 1)) {
thisChar = myDevice.substring(i, i + 1)
if (thisChar == " ") {
spaceList.add(i)
}
i++
}
cutOff = spaceList.get(myOccurrence - 1)
myShortDevice = myDevice.substring(0, cutOff)
if (isLogDebug) log.debug("myShortDevice ${myShortDevice}")
return myShortDevice
}
//Checks for critical Null values that can be introduced by the user by clicking "No Selection" in an enum dialog.
def checkNulls() {
if (myThresholdCount == null) app.updateSetting("myThresholdCount", [value: "0", type: "enum"])
if (myKeywordCount == null) app.updateSetting("myKeywordCount", [value: "0", type: "enum"])
if (myVariableCount == null) app.updateSetting("myVariableCount", [value: "0", type: "enum"])
if (rows == null) app.updateSetting("rows", [value: "1", type: "enum"])
if (myColumns == null) app.updateSetting("myColumns", [value: "1", type: "enum"])
if (varColumns == null) app.updateSetting("varColumns", [value: "1", type: "enum"])
if (eventTimeout == null) app.updateSetting("eventTimeout", "2000")
}
//Returns a formatted title for a section header based on whether the section is visible or not.
def getSectionTitle(section) {
if (section == "Layout Mode") {
if (state.hidden.LayoutMode == true) return sectionTitle("Layout Mode ▶") else return sectionTitle("Layout Mode ▼")
}
if (section == "Device Group") {
if (state.hidden.DeviceGroup == true) return sectionTitle("Device Group ▶") else return sectionTitle("Device Group ▼")
}
if (section == "Variables") {
if (state.hidden.Variables == true) return sectionTitle("Configure Variables ▶") else return sectionTitle("Configure Variables ▼")
}
if (section == "Grid Layout") {
if (state.hidden.GridLayout == true) return sectionTitle("Grid Layout ▶") else return sectionTitle("Grid Layout ▼")
}
if (section == "Design") {
if (state.hidden.Design == true) return sectionTitle("Design Table ▶") else return sectionTitle("Design Table ▼")
}
if (section == "Publish") {
if (state.hidden.Publish == true) return sectionTitle("Publish Table ▶") else return sectionTitle("Publish Table ▼")
}
}
//Returns a list of attributes which the user has selected in the UI.
def getSelectedAttributes() {
def attributeList = []
for (i = 1; i <= myVariableCount.toInteger(); i++) {
myAttr = settings["myAttribute$i"]
if (myAttr != null) attributeList.add(myAttr)
}
return attributeList
}
//*******************************************************************************************************************************************************************************************
//**************
//************** Free Form Related Functions
//**************
//*******************************************************************************************************************************************************************************************
//Collects and formats the Variable values and stores the derived values in state. Calls CleanupFreeForm() which in turn calls cleanupCommon()
def getVariablesFreeForm() {
if (isLogTrace || isLogVariables) log.trace("<b>getVariablesFreeForm: Entering.</b>")
def varString1 = ""
def varString2 = ""
def varName
//Wipe out the existing settings
state.vars = [:]
//Clear the old device if no longer required
if (settings["variableSource$i"].toString() != "Device Attribute" && settings["myDevice$i"] != null) {
//log.info ("Running Remove Setting")
app.removeSetting("myDevice$i")
}
//Loop through each of the Variables and generate it's content.
for (int i = 1; i <= myVariableCount.toInteger(); i++) {
try {
//Now get the cleaned up version which will be determined by any rules that are applies. The result comes back as a single key & value pair.
resultMap = cleanupFreeForm(i)
if (isLogVariables) log.info("getVariablesFreeForm: received " + resultMap.toString() + "from cleanupFreeForm - varNumber is: $i")
def myValue
varName = settings["name$i"]
//resultMap will only contain one item and value pair.
resultMap.each { itemName, value ->
if (value == null || value == "Null" || value == "null") value = invalidAttribute.toString()
if (isLogVariables) log.info("getVariablesFreeForm: Item Name: $itemName, Value: $value, varName is: $varName")
myValue = highlightValue(value, i)
state.vars."$varName" = (myValue.toString() ?: invalidAttribute.toString())
if (isLogVariables && isLogDetails) log.info("getVariablesFreeForm: state.vars.$varName is: " + myValue.toString() ?: "")
}
}
catch (Exception ignored) { log.error('getVariablesFreeForm: Error getting Device\\Variable info. Has a device or variable been deleted or renamed?') }
}
//Go through each of the vars in state and mark them for display in the vars area.
def sortedMap = state.vars.entrySet().sort { it.key.capitalize() }.collectEntries { entry -> [entry.key, entry.value] }
sortedMap.each { thisVar, value ->
if (value != null && value != "Null") {
varString1 += dodgerBlue(bold("$thisVar: ")) + toHTML(value) + ", "
varString2 += dodgerBlue(bold("$thisVar: ")) + toHTML(value) + " (<mark>" + unHTML(value) + "</mark>), "
}
}
//Decide What we will show
if (isLogVariables && isLogDetails) log.info("getVariablesFreeForm: varString1 is: $varString1")
if (isLogVariables && isLogDetails) log.info("getVariablesFreeForm: varString2 is: $varString2")
if (showVariables == "Show Variables") return varString1
if (showVariables == "Show Variables & HTML") {
varString2 = varString2.replaceAll("(?i)<style>", "<!style!>")
return varString2
}
}
//Get the provided Device Value and apply the specified Cleanups using cleanupCore() and return the final string.
def cleanupFreeForm(i) {
if (isLogTrace || isLogCleanups) log.trace("<b>cleanupFreeForm: Entering with $i.</b>")
def myMap
def myValue
def myName = settings["name$i"]
def dataType
if (isLogCleanups) log.info("<u>cleanupFreeForm: Performing cleanup for: $myName</u>")
if (settings["variableSource$i"] == "Default Device" && settings["defaultDevice"] != null) {
myValue = settings["defaultDevice"]?.currentValue(settings["myAttribute$i"])
if (myValue == null) myValue = invalidAttribute.toString()
dataType = getDataType(myValue)
if (isLogCleanups && isLogDetails) log.info("cleanupFreeForm: Processing Default Device: $myName with index:$i and the myValue is:$myValue with dataType: $dataType")
}
if (settings["variableSource$i"] == "Device Attribute" && settings["myDevice$i"] != null && settings["myAttribute$i"] != null) {
myValue = settings["myDevice$i"]?.currentValue(settings["myAttribute$i"])
if (myValue == null) myValue = invalidAttribute.toString()
dataType = getDataType(myValue)
if (isLogCleanups && isLogDetails) log.info("cleanupFreeForm: Processing Device: $myName with index:$i and the value is:$myValue with dataType: $dataType")
}
if (settings["variableSource$i"] == "Hub Variable" && settings["myHubVariable$i"] != null) {
myMap = getGlobalVar(settings["myHubVariable$i"])
myValue = myMap.value
dataType = getDataType(myValue)
if (isLogCleanups && isLogDetails) log.info("cleanupFreeForm: Processing Hub Variable: $myName with index:$i and the value is:$myValue with dataType: $dataType")
}
if (settings["variableSource$i"] == "Device Detail" && settings["myDevice$i"] != null && settings["myAttribute$i"] != null) {
if (settings["myAttribute$i"].contains("Duration")) {
//User has requested a Duration
myMap = getDurationFreeForm(settings["myAttribute$i"], settings["myDevice$i"])
//log.info ("myMap is: $myMap")
state.vars."$myName" = myMap.value
} else myMap = getDeviceDetail(settings["myAttribute$i"], settings["myDevice$i"], i)
myValue = myMap.value
dataType = myMap.dataType
if (isLogCleanups && isLogDetails) log.info("cleanupFreeForm: Processing Device Detail: $myName with index:$i and the value is:$myValue with dataType: $dataType")