/
meteobridge-weather-station.groovy
3047 lines (2938 loc) · 198 KB
/
meteobridge-weather-station.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
/**
* Copyright 2015 SmartThings
* Copyright 2019 Barry A. Burke
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Meteobridge Weather Station
*
* Author: SmartThings
*
*
* VClouds Weather Icons©
* Created and copyrighted© by VClouds - http://vclouds.deviantart.com/
*
* The icons are free to use for Non-Commercial use, but If you use want to use it with your art please credit me
* and put a link leading back to the icons DA page - http://vclouds.deviantart.com/gallery/#/d2ynulp
*
* *** Not to be used for commercial use without permission!
* if you want to buy the icons for commercial use please send me a note - http://vclouds.deviantart.com/ ***
*
* Date: 2018-07-04
*
* Updates by Barry A. Burke (storageanarchy@gmail.com)
* Date: 2017 - 2019
*
* 1.0.00 - Initial Release
8 <snip>
* 1.1.01 - Now supports both SmartThings & Hubitat (automagically)
* 1.1.02 - Corrected contentType for hubAction call
* 1.1.03 - Removed wunderGround support (deprecated by SmartThings)
* 1.1.04 - Fixed ST/HE autodetect logic
* 1.1.05 - Cleaned up another ST/HE quirk
* 1.1.06 - Added Breezy and Foggy, cleaned up hubResponse returns
* 1.1.07 - Cleaned up isST()/isHE()
* 1.1.08 - Yet more fixes for application/json handling
* 1.1.10 - Initial general release of SmartThings+Hubitat version
* 1.1.11 - Added 'Possible Light Snow and Breezy/Windy', optimized icon calculations
* 1.1.12 - Added Air Quality, indoor Temperature, Humidity and Dewpoint attributes (not displayed yet)
* 1.1.13a- New SmartThings/Hubitat Portability Library
* 1.1.14 - Fully utilize SHPL
* 1.1.15 - Fixed cloud cover calculation
* 1.1.16 - Fixed TWC error (isHE)
* 1.1.17 - Major bug fixes, new icons, Hubitat myTile support
* 1.1.18 - Relocated iconStore
* 1.1.19 - More bug fixes & optimizations
* 1.1.20 - Improved handling of non-existent sensors (solar, UV, rain, wind)
* 1.1.21 - Added city/state/country on ST - PREFERS MeteoBridge Location!!!
* 1.1.22 - Minor bug fixes & improved error handling
* 1.1.23 - Major overhaul of MeteoBridge template generation & handling
* 1.1.24 - Warning message cleanup, expanded "windy/breezy and ..." icons
* 1.1.25 - Added preferences option to use averaged data pver the last update frequency period
* 1.1.26 - Cosmetic additional debug traces
* 1.1.27 - Fixed timestamp/timeGet, reduced chars in myTile
* 1.1.28 - Added wind speed attributes for small HE Dashboard tile, fixed day/night transition icons
* 1.1.29 - Added hubAction timeout, optionally skip creating tile on HE, misc weatherIcons cleanup
* 1.1.30 - Reschedule if MB server tells us it is busy/overloaded
* 1.1.31 - Changed all logging to use 'debugOn' preference
* 1.1.32 - Fixed current weather icon parsing (darkSky.currently.summary errors)
*
*/
import groovy.json.*
import java.text.SimpleDateFormat
import groovy.transform.Field
private getVersionNum() { return "1.1.32" }
private getVersionLabel() { return "Meteobridge Weather Station, version ${versionNum}" }
private getDebug() { false }
private getFahrenheit() { true } // Set to false for Celsius color scale
private getCelsius() { !fahrenheit }
private getSummaryText() { true }
// private getShortStats() { true }
// **************************************************************************************************************************
// SmartThings/Hubitat Portability Library (SHPL)
// Copyright (c) 2019, Barry A. Burke (storageanarchy@gmail.com)
//
// The following 3 calls are safe to use anywhere within a Device Handler or Application
// - these can be called (e.g., if (getPlatform() == 'SmartThings'), or referenced (i.e., if (platform == 'Hubitat') )
// - performance of the non-native platform is horrendous, so it is best to use these only in the metadata{} section of a
// Device Handler or Application
//
private getPlatform() { (physicalgraph?.device?.HubAction ? 'SmartThings' : 'Hubitat') } // if (platform == 'SmartThings') ...
private getIsST() { (physicalgraph?.device?.HubAction ? true : false) } // if (isST) ...
private getIsHE() { (hubitat?.device?.HubAction ? true : false) } // if (isHE) ...
//
// The following 3 calls are ONLY for use within the Device Handler or Application runtime
// - they will throw an error at compile time if used within metadata, usually complaining that "state" is not defined
// - getHubPlatform() ***MUST*** be called from the installed() method, then use "state.hubPlatform" elsewhere
// - "if (state.isST)" is more efficient than "if (isSTHub)"
//
/* private String getHubPlatform() {
if (state?.hubPlatform == null) {
state.hubPlatform = getPlatform() // if (hubPlatform == 'Hubitat') ... or if (state.hubPlatform == 'SmartThings')...
state.isST = state.hubPlatform.startsWith('S') // if (state.isST) ...
state.isHE = state.hubPlatform.startsWith('H') // if (state.isHE) ...
}
return state.hubPlatform
} */
private String getHubPlatform() {
def pf = getPlatform()
state?.hubPlatform = pf // if (state.hubPlatform == 'Hubitat') ...
// or if (state.hubPlatform == 'SmartThings')...
state?.isST = pf.startsWith('S') // if (state.isST) ...
state?.isHE = pf.startsWith('H') // if (state.isHE) ...
return pf
}
private getIsSTHub() { (state.isST) } // if (isSTHub) ...
private getIsHEHub() { (state.isHE) } // if (isHEHub) ...
//
// **************************************************************************************************************************
metadata {
definition (name: "Meteobridge Weather Station", namespace: "sandood", author: "sandood",
importUrl: "https://raw.githubusercontent.com/SANdood/MeteoWeather/master/devicetypes/sandood/meteobridge-weather-station.src/meteobridge-weather-station.groovy")
{
capability "Temperature Measurement"
capability "Relative Humidity Measurement"
capability "Ultraviolet Index"
capability "Illuminance Measurement"
if (isST) capability "Air Quality Sensor"
capability "Water Sensor"
capability "Sensor"
capability "Refresh"
if (isHE) attribute "airQuality", "number"
attribute "airQualityIndex", "number"
attribute "aqi", "number"
attribute "attribution", "string"
attribute "avgHumForecast", "number"
attribute "avgHumTomorrow", "number"
attribute "city", "string"
attribute "country", "string"
attribute "currentDate", "string"
attribute "currentTime", "string"
if (debug) attribute "darkSkyWeather", "string" // For debugging only
attribute "dayHours", "string"
attribute "dayMinutes", "number"
attribute "dewpoint", "number"
if (debug) attribute "etDisplay", "string"
attribute "evapotranspiration", "number"
attribute "forecast", "string"
attribute "forecastCode", "string"
attribute "heatIndex", "number"
if (debug) attribute "heatIndexDisplay", "string"
attribute "highHumYesterday", "number"
attribute "highHumidity", "number"
attribute "highTemp", "number"
attribute "highTempForecast", "number"
attribute "highTempTomorrow", "number"
attribute "highTempYesterday", "number"
if (debug) attribute "hubAction", "string" // For debugging only
if (debug) attribute "iconErr", "string" // For debugging only
attribute "indoorDewpoint", "number"
attribute "indoorHumidity", "number"
attribute "indoorTemperature", "number"
attribute "isDay", "number"
attribute "isNight", "number"
attribute "lastSTupdate", "string"
attribute "last_observation_Forecast", "string"
attribute "last_observation_Station", "string"
attribute "last_poll_Forecast", "string"
attribute "last_poll_Station", "string"
attribute "latitude", "number"
attribute "localMoonrise", "string"
attribute "localMoonset", "string"
attribute "localSunrise", "string"
attribute "localSunset", "string"
attribute "location", "string"
attribute "locationName", "string"
attribute "longitude", "number"
attribute "lowHumYesterday", "number"
attribute "lowHumidity", "number"
attribute "lowTemp", "number"
attribute "lowTempForecast", "number"
attribute "lowTempTomorrow", "number"
attribute "lowTempYesterday", "number"
attribute "lunarAge", "number"
attribute "lunarPercent", "number"
attribute "lunarSegment", "number"
if (debug) attribute "meteoTemplate", "string" // For debugging only
if (debug) attribute "meteoWeather", "string" // For debugging only
attribute "moonAge", "number"
if (debug) attribute "moonDisplay", "string"
attribute "moonIllumination", "number"
if (debug) attribute "moonInfo", "string"
attribute "moonPhase", "string"
if (debug) attribute "moonPercent", "number"
attribute "moonrise", "string"
attribute "moonriseAPM", "string"
attribute "moonriseEpoch", "number"
attribute "moonset", "string"
attribute "moonsetAPM", "string"
attribute "moonsetEpoch", "number"
attribute "myTile", "string"
attribute "pop", "number" // Probability of Precipitation (in %)
if (debug) attribute "popDisplay", "string"
if (debug) attribute "popFcstDisplay", "string"
attribute "popForecast", "number"
if (debug) attribute "popTomDisplay", "string"
attribute "popTomorrow", "number"
if (debug) attribute "precipFcstDisplay", "string"
attribute "precipForecast", "number"
if (debug) attribute "precipLastHourDisplay", "string"
attribute "precipLastHour", "number"
attribute "precipRate", "number"
if (debug) attribute "precipRateDisplay", "string"
attribute "precipToday", "number"
if (debug) attribute "precipTodayDisplay", "string"
if (debug) attribute "precipTomDisplay", "string"
attribute "precipTomorrow", "number"
attribute "precipYesterday", "number"
if (debug) attribute "precipYesterdayDisplay", "string"
attribute "pressure", "number"
if (debug) attribute "pressureDisplay", "string"
attribute "pressureTrend", "string"
if (debug) attribute "purpleAir", "string" // For debugging only
attribute "respAvg", "number"
attribute "respTime", "number"
attribute "solarRadiation", "number"
attribute "state", "string"
if (summaryText) attribute "summaryList", "string"
if (summaryText) attribute "summaryMap", "string"
attribute "sunrise", "string"
attribute "sunriseAPM", "string"
attribute "sunriseEpoch", "number"
attribute "sunset", "string"
attribute "sunsetAPM", "string"
attribute "sunsetEpoch", "number"
attribute "timestamp", "string"
attribute "timezone", "string"
if (debug) attribute "twcConditions", "string" // For debugging only
if (debug) attribute "twcForecast", "string" // For debugging only
attribute "tz_id", "string"
attribute "uvIndex", "number" // Also 'ultravioletIndex' per ST capabilities 07/19/2018
attribute "water", "string"
attribute "weather", "string"
attribute "weatherIcon", "string"
attribute "weatherIcons", "string" // OpenWeatherMap icon
attribute "wind", "number"
attribute "windChill", "number"
if (debug) attribute "windChillDisplay", "string"
attribute "windDirection", "string"
attribute "windDirectionText", "string"
if (debug) attribute "windinfo", "string"
attribute "windGust", "number"
attribute "windSpeed", "number"
attribute "wind_degree", "string"
attribute "wind_dir", "string"
attribute "wind_direction", "string"
attribute "wind_gust", "number"
attribute "wind_speed", "number"
attribute "wind_string", "string"
attribute "wundergroundObs", "string" // For debugging only
attribute 'feelsLike', 'number'
command "refresh", []
// command "getWeatherReport"
}
preferences {
input(name: 'updateMins', type: 'enum', description: "Select the update frequency",
title: "${getVersionLabel()}\n\nUpdate frequency (minutes)", displayDuringSetup: true, defaultValue: '5', options: ['1', '2', '3', '5','10','15','30'], required: true)
input(name: 'avgUpdates', type: 'bool', title: 'Use averaged updates?', defaultValue: false, displayDuringSetup: true, required: true)
// input(name: "zipCode", type: "text", title: "Zip Code or PWS (optional)", required: false, displayDuringSetup: true, description: 'Specify Weather Underground ZipCode or pws:')
input(name: "twcLoc", type: "text", title: "TWC Location code (optional)\n(US ZipCode or Lat,Lon)", required: false, displayDuringSetup: true, description: "Leave blank for MeteoBridge's location")
if (isST) { input (description: "Setup Meteobridge access", title: "Meteobridge Setup", displayDuringSetup: true, type: 'paragraph', element: 'MeteoBridge') }
input "meteoIP", "string", title:"Meteobridge IP Address", description: "Enter your Meteobridge's IP Address", required: true, displayDuringSetup: true
input "meteoPort", "string", title:"Meteobridge Port", description: "Enter your Meteobridge's Port", defaultValue: 80 , required: true, displayDuringSetup: true
input "meteoUser", "string", title:"Meteobridge User", description: "Enter your Meteobridge's username", required: true, defaultValue: 'meteobridge', displayDuringSetup: true
input "meteoPassword", "password", title:"Meteobridge Password", description: "Enter your Meteobridge's password", required: true, displayDuringSetup: true
input "shortStats", "bool", title:"Use optimized MeteoBridge requests?", required: true, defaultValue: false, displayDuringSetup: true
input ("purpleID", "string", title: 'Purple Air Sensor ID (optional)', description: 'Enter your PurpleAir Sensor ID', required: false, displayDuringSetup: true)
input ("darkSkyKey", "string", title: 'DarkSky Secret Key (optional)', description: 'Enter your DarkSky key (from darksky.net)', defaultValue: '', required: false,
displayDuringSetup: true, submitOnChange: true)
input ("fcstSource", "enum", title: 'Select weather forecast source', description: "Select the source for your weather forecast (default=Meteobridge)", required: false, displayDuringSetup: true,
options: ['darksky':'Dark Sky', 'meteo': 'Meteobridge', 'twc': 'The Weather Company'])
input ("pres_units", "enum", title: "Barometric Pressure units (optional)", required: false, displayDuringSetup: true, description: "Select desired units:",
options: [
"press_in":"Inches",
"press_mb":"milli bars"
])
input ("dist_units", "enum", title: "Distance units (optional)", required: false, displayDuringSetup: true, description: "Select desired units:",
options: [
"dist_mi":"Miles",
"dist_km":"Kilometers"
])
input("height_units", "enum", title: "Height units (optional)", required: false, displayDuringSetup: true, description: "Select desired units:",
options: [
"height_in":"Inches",
"height_mm":"Millimeters"
])
input("speed_units", "enum", title: "Speed units (optional)", required: false, displayDuringSetup: true, description: "Select desire units:",
options: [
"speed_mph":"Miles per Hour",
"speed_kph":"Kilometers per Hour"
])
input("lux_scale", "enum", title: "Lux Scale (optional)", required: false, displayDuringSetup: true, description: "Select desired scale:",
options: [
"default":"0-1000 (Aeon)",
"std":"0-10,000 (ST)",
"real":"0-100,000 (actual)"
])
if (isHE) { input "skipMyTile", "bool", title: "Skip generation of myTile weather page HTML?", required: true, defaultValue: false, displayDuringSetup: true }
input(name: 'debugOn', type: 'bool', title: 'Enable debug logging?', defaultValue: false, displayDuringSetup: true)
// input "weather", "device.smartweatherStationTile", title: "Weather...", multiple: true, required: false
}
tiles(scale: 2) {
multiAttributeTile(name:"temperatureDisplay", type:"generic", width:6, height:4, canChangeIcon: false) {
tileAttribute("device.temperatureDisplay", key: "PRIMARY_CONTROL") {
attributeState("temperatureDisplay", label:'${currentValue}°', defaultState: true,
backgroundColors: (temperatureColors)
)
}
tileAttribute("device.weatherIcon", key: "SECONDARY_CONTROL") {
//attributeState 'default', label: '${currentValue}', defaultState: true
attributeState "chanceflurries", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/41.png", label: " Chance of Flurries"
attributeState "chancelightsnow", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/41.png", label: " Possible Light Snow"
attributeState "chancelightsnowbreezy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/41b.png", label: " Possible Light Snow and Breezy"
attributeState "chancelightsnowwindy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/41b.png", label: " Possible Light Snow and Windy"
attributeState "chancerain", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/39.png", label: " Chance of Rain"
attributeState "chancedrizzle", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/39.png", label: " Chance of Drizzle"
attributeState "chancelightrain", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/39.png", label: " Chance of Light Rain"
attributeState "chancesleet", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/41.png", label: " Chance of Sleet"
attributeState "chancesnow", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/41.png", label: " Chance of Snow"
attributeState "chancetstorms", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/38.png", label: " Chance of Thunderstorms"
attributeState "clear", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/32.png", label: " Clear"
attributeState "humid", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/36.png", label: " Humid"
attributeState "sunny", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/36.png", label: " Sunny"
attributeState "clear-day", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/32.png", label: " Clear"
attributeState "cloudy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/26.png", label: " Overcast"
attributeState "humid-cloudy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/26.png", label: " Humid and Overcast"
attributeState "flurries", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/13.png", label: " Snow Flurries"
attributeState "scattered-flurries", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/41.png", label: " Scattered Snow Flurries"
attributeState "scattered-snow", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/41.png", label: " Scattered Snow Showers"
attributeState "lightsnow", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/14.png", label: " Light Snow"
attributeState "frigid-ice", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/10.png", label: " Frigid / Ice Crystals"
attributeState "fog", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/20.png", label: " Foggy"
attributeState "hazy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/21.png", label: " Hazy"
attributeState "smoke", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/22.png", label: " Smoke"
attributeState "mostlycloudy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/28.png", label: " Mostly Cloudy"
attributeState "mostly-cloudy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/28.png", label: " Mostly Cloudy"
attributeState "mostly-cloudy-day", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/28.png", label: " Mostly Cloudy"
attributeState "humid-mostly-cloudy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/28.png", label: " Humid and Mostly Cloudy"
attributeState "humid-mostly-cloudy-day", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/28.png", label: " Humid and Mostly Cloudy"
attributeState "mostlysunny", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/34.png", label: " Mostly Sunny"
attributeState "partlycloudy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/30.png", label: " Partly Cloudy"
attributeState "partly-cloudy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/30.png", label: " Partly Cloudy"
attributeState "partly-cloudy-day", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/30.png", label: " Partly Cloudy"
attributeState "humid-partly-cloudy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/30.png", label: " Humid and Partly Cloudy"
attributeState "humid-partly-cloudy-day", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/30.png", label: " Humid and Partly Cloudy"
attributeState "partlysunny", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/28.png", label: " Partly Sunny"
attributeState "rain", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/12.png", label: " Rain"
attributeState "rain-breezy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/1.png", label: " Rain and Breezy"
attributeState "rain-windy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/1.png", label: " Rain and Windy"
attributeState "rain-windy!", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/1.png", label: " Rain and Dangerously Windy"
attributeState "heavyrain", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/12.png", label: " Heavy Rain"
attributeState "heavyrain-breezy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/1.png", label: " Heavy Rain and Breezy"
attributeState "heavyrain-windy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/1.png", label: " Heavy Rain and Windy"
attributeState "heavyrain-windy!", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/1.png", label: " Heavy Rain and Dangerously Windy"
attributeState "drizzle", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/9.png", label: " Drizzle"
attributeState "lightdrizzle", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/9.png", label: " Light Drizzle"
attributeState "heavydrizzle", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/9.png", label: " Heavy Drizzle"
attributeState "lightrain", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/11.png", label: " Light Rain"
attributeState "scattered-showers", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/39.png", label: " Scattered Showers"
attributeState "lightrain-breezy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/2.png", label: " Light Rain and Breezy"
attributeState "lightrain-windy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/2.png", label: " Light Rain and Windy"
attributeState "lightrain-windy!", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/2.png", label: " Light Rain and Dangerously Windy"
attributeState "sleet", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/10.png", label: " Sleet"
attributeState "lightsleet", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/8.png", label: " Light Sleet"
attributeState "heavysleet", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/10.png", label: " Heavy Sleet"
attributeState "rain-sleet", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/6.png", label: " Rain and Sleet"
attributeState "winter-mix", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/7.png", label: " Wintery Mix of Snow and Sleet"
attributeState "freezing-drizzle", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/8.png", label: " Freezing Drizzle"
attributeState "freezing-rain", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/10.png", label: " Freezing Rain"
attributeState "snow", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/15.png", label: " Snow"
attributeState "heavysnow", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/16.png", label: " Heavy Snow"
attributeState "blizzard", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/42.png", label: " Blizzard"
attributeState "rain-snow", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/7.png", label: " Rain to Snow Showers"
attributeState "tstorms", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/0.png", label: " Thunderstorms"
attributeState "tstorms-iso", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/37.png", label: " Isolated Thunderstorms"
attributeState "thunderstorm", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/0.png", label: " Thunderstorm"
attributeState "windy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/23.png", label: " Windy"
attributeState "wind", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/23.png", label: " Windy"
attributeState "sandstorm", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/19b.png", label: " Blowing Dust / Sandstorm"
attributeState "blowing-spray", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/23.png", label: " Windy / Blowing Spray"
attributeState "wind!", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/23.png", label: " Dangerously Windy"
attributeState "wind-foggy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/23.png", label: " Windy and Foggy"
attributeState "wind-overcast", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/24c.png", label: " Windy and Overcast"
attributeState "wind-overcast!", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/24c.png", label: " Dangerously Windy and Overcast"
attributeState "wind-partlycloudy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/30b.png", label: " Windy and Partly Cloudy"
attributeState "wind-partlycloudy!", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/30b.png", label: " Dangerously Windy and Partly Cloudy"
attributeState "wind-mostlycloudy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/28b.png", label: " Windy and Mostly Cloudy"
attributeState "wind-mostlycloudy!", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/28b.png", label: " Dangerously Windy and Mostly Cloudy"
attributeState "breezy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/23.png", label: " Breezy"
attributeState "breezy-overcast", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/24b.png", label: " Breezy and Overcast"
attributeState "breezy-partlycloudy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/30b.png", label: " Breezy and Partly Cloudy"
attributeState "breezy-mostlycloudy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/28b.png", label: " Breezy and Mostly Cloudy"
attributeState "breezy-foggy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/20b.png", label: " Breezy and Foggy"
attributeState "tornado", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/to.png", label: " Tornado"
attributeState "hail", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/18.png", label: " Hail Storm"
attributeState "thunder-hail", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/1.png", label: " Thunder and Hail Storm"
attributeState "rain-hail", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/7.png", label: " Mixed Rain and Hail"
attributeState "nt_chanceflurries", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/41.png", label: " Chance of Flurries"
attributeState "chancelightsnow-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/46.png", label: " Possible Light Snow"
attributeState "chancelightsnowbz-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/46b.png", label: " Possible Light Snow and Breezy"
attributeState "chancelightsnowy-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/46b.png", label: " Possible Light Snow and Windy"
attributeState "nt_chancerain", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/39.png", label: " Chance of Rain"
attributeState "chancerain-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/39.png", label: " Chance of Rain"
attributeState "chancelightrain-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/45.png", label: " Chance of Light Rain"
attributeState "nt_chancesleet", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/46.png", label: " Chance of Sleet"
attributeState "chancesleet-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/46.png", label: " Chance of Sleet"
attributeState "nt_chancesnow", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/46.png", label: " Chance of Snow"
attributeState "chancesnow-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/46.png", label: " Chance of Snow"
attributeState "nt_chancetstorms", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/47.png", label: " Chance of Thunderstorms"
attributeState "chancetstorms-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/47.png", label: " Chance of Thunderstorms"
attributeState "nt_clear", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/31.png", label: " Clear"
attributeState "clear-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/31.png", label: " Clear"
attributeState "humid-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/33.png", label: " Humid"
attributeState "nt_sunny", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/31.png", label: " Clear"
attributeState "nt_cloudy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/26.png", label: " Overcast"
attributeState "cloudy-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/26.png", label: " Overcast"
attributeState "humid-cloudy-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/26.png", label: " Humid and Overcast"
attributeState "nt_fog", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/31b.png", label: " Foggy"
attributeState "fog-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/31b.png", label: " Foggy"
attributeState "nt_hazy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/31b.png", label: " Hazy"
attributeState "nt_mostlycloudy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/27.png", label: " Mostly Cloudy"
attributeState "mostly-cloudy-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/27.png", label: " Mostly Cloudy"
attributeState "humid-mostly-cloudy-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/27.png", label: " Humid and Mostly Cloudy"
attributeState "nt_mostlysunny", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/33.png", label: " Mostly Clear"
attributeState "nt_partlycloudy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/29.png", label: " Partly Cloudy"
attributeState "partly-cloudy-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/29.png", label: " Partly Cloudy"
attributeState "humid-partly-cloudy-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/29.png", label: " Humid and Partly Cloudy"
attributeState "nt_partlysunny", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/27.png", label: " Partly Clear"
attributeState "nt_scattered-flurries", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/13.png", label: " Flurries"
attributeState "nt_flurries", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/41.png", label: " Scattered Flurries"
attributeState "flurries-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/13.png", label: " Flurries"
attributeState "lightsnow-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/14.png", label: " Light Snow"
attributeState "nt_rain", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/11.png", label: " Rain"
attributeState "rain-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/11.png", label: " Rain"
attributeState "rain-breezy-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/2.png", label: " Rain and Breezy"
attributeState "rain-windy-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/2.png", label: " Rain and Windy"
attributeState "rain-windy-night!", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/2.png", label: " Rain and Dangerously Windy"
attributeState "heavyrain-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/12.png", label: " Heavy Rain"
attributeState "heavyrain-breezy-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/1.png", label: " Heavy Rain and Breezy"
attributeState "heavyrain-windy-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/1.png", label: " Heavy Rain and Windy"
attributeState "heavyrain-windy-night!", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/1.png", label: " Heavy Rain and Dangerously Windy"
attributeState "nt_drizzle", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/9.png", label: " Drizzle"
attributeState "drizzle-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/9.png", label: " Drizzle"
attributeState "nt_lightrain", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/11.png", label: " Light Rain"
attributeState "lightrain-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/11.png", label: " Light Rain"
attributeState "nt_scattered-rain", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/39.png", label: " Scattered Showers"
attributeState "lightrain-breezy-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/2.png", label: " Light Rain and Breezy"
attributeState "lightrain-windy-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/2.png", label: " Light Rain and Windy"
attributeState "lightrain-windy-night!", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/2.png", label: " Light Rain and Dangerously Windy"
attributeState "nt_sleet", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/46.png", label: " Sleet"
attributeState "sleet-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/46.png", label: " Sleet"
attributeState "lightsleet-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/46.png", label: " Sleet"
attributeState "nt_rain-sleet", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/46.png", label: " Rain and Sleet"
attributeState "nt_thunder-hail", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/47.png", label: " Thunder and Hail Storm"
attributeState "nt_winter-mix", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/7.png", label: " Winter Mix of Sleet and Snow"
attributeState "nt_freezing-drizzle", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/8.png", label: " Freezing Drizzle"
attributeState "nt_freezing-rain", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/8.png", label: " Freezing Rain"
attributeState "nt_snow", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/46.png,", label: " Snow"
attributeState "nt_rain-snow", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/46.png,", label: " Rain and Snow Showers"
attributeState "snow-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/46.png,", label: " Snow"
attributeState "nt_heavysnow", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/42.png,", label: " Heavy Snow"
attributeState "nt_heavysnow", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/42.png,", label: " Heavy Snow"
attributeState "nt_tstorms", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/47.png", label: " Thunderstorms"
attributeState "nt_blizzard", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/42.png", label: " Blizzard"
attributeState "nt_thunderstorm", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/0.png", label: " Thunderstorm"
attributeState "thunderstorm-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/0.png", label: " Thunderstorm"
attributeState "nt_windy", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/23.png", label: " Windy"
attributeState "windy-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/23.png", label: " Windy"
attributeState "wind-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/23.png", label: " Windy"
attributeState "wind-night!", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/23.png", label: " Dangerously Windy"
attributeState "wind-foggy-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/20b.png", label: " Windy and Foggy"
attributeState "wind-overcast-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/24b.png", label: " Windy and Overcast"
attributeState "wind-overcast-night!", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/24b.png", label: " Dangerously Windy and Overcast"
attributeState "wind-partlycloudy-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/29b.png", label: " Windy and Partly Cloudy"
attributeState "wind-partlycloudy-night!", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/29b.png", label: " Dangerously Windy and Partly Cloudy"
attributeState "wind-mostlycloudy-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/27b.png", label: " Windy and Mostly Cloudy"
attributeState "wind-mostly-cloudy-night!", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/27b.png", label: " Dangerously Windy and Mostly Cloudy"
attributeState "breezy-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/23.png", label: " Breezy"
attributeState "breezy-overcast-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/24b.png", label: " Breezy and Overcast"
attributeState "breezy-partlycloudy-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/29b.png", label: " Breezy and Partly Cloudy"
attributeState "breezy-mostlycloudy-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/27b.png", label: " Breezy and Mostly Cloudy"
attributeState "breezy-foggy-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/20b.png", label: " Breezy and Foggy"
attributeState "nt_tornado", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/to.png", label: " Tornado"
attributeState "tornado-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/to.png", label: " Tornado"
attributeState "nt_hail", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/46b.png", label: " Hail"
attributeState "hail-night", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/46b.png", label: " Hail"
attributeState "na", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/na.png", label: " Not Available"
attributeState "unknown", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/na.png", label: " Unknown"
attributeState "hurricane", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/hc.png", label: " Hurricane"
attributeState "tropical-storm", icon:"https://raw.githubusercontent.com/SANdood/Icons/master/Weather/38.png", label: " Tropical Storm"
}
}
standardTile('moonPhase', 'device.moonPhase', decoration: 'flat', inactiveLabel: false, width: 1, height: 1) {
state "New", label: '', icon: "https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Lunar0.png"
state "Waxing Crescent", label: '', icon: "https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Lunar1.png"
state "First Quarter", label: '', icon: "https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Lunar2.png"
state "Waxing Gibbous", label: '', icon: "https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Lunar3.png"
state "Full", label: '', icon: "https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Lunar4.png"
state "Waning Gibbous", label: '', icon: "https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Lunar5.png"
state "Third Quarter", label: '', icon: "https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Lunar6.png"
state "Waning Crescent", label: '', icon: "https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Lunar7.png"
}
standardTile('moonDisplay', 'device.moonDisplay', decoration: 'flat', inactiveLabel: false, width: 1, height: 1) {
state 'Moon-waning-000', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waning-000.png'
state 'Moon-waning-005', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waning-005.png'
state 'Moon-waning-010', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waning-010.png'
state 'Moon-waning-015', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waning-015.png'
state 'Moon-waning-020', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waning-020.png'
state 'Moon-waning-025', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waning-025.png'
state 'Moon-waning-030', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waning-030.png'
state 'Moon-waning-035', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waning-035.png'
state 'Moon-waning-040', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waning-040.png'
state 'Moon-waning-045', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waning-045.png'
state 'Moon-waning-050', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waning-050.png'
state 'Moon-waning-055', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waning-055.png'
state 'Moon-waning-060', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waning-060.png'
state 'Moon-waning-065', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waning-065.png'
state 'Moon-waning-070', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waning-070.png'
state 'Moon-waning-075', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waning-075.png'
state 'Moon-waning-080', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waning-080.png'
state 'Moon-waning-085', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waning-085.png'
state 'Moon-waning-090', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waning-090.png'
state 'Moon-waning-095', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waning-095.png'
state 'Moon-waning-100', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waning-100.png'
state 'Moon-waxing-000', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waxing-000.png'
state 'Moon-waxing-005', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waxing-005.png'
state 'Moon-waxing-010', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waxing-010.png'
state 'Moon-waxing-015', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waxing-015.png'
state 'Moon-waxing-020', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waxing-020.png'
state 'Moon-waxing-025', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waxing-025.png'
state 'Moon-waxing-030', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waxing-030.png'
state 'Moon-waxing-035', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waxing-035.png'
state 'Moon-waxing-040', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waxing-040.png'
state 'Moon-waxing-045', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waxing-045.png'
state 'Moon-waxing-050', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waxing-050.png'
state 'Moon-waxing-055', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waxing-055.png'
state 'Moon-waxing-060', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waxing-060.png'
state 'Moon-waxing-065', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waxing-065.png'
state 'Moon-waxing-070', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waxing-070.png'
state 'Moon-waxing-075', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waxing-075.png'
state 'Moon-waxing-080', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waxing-080.png'
state 'Moon-waxing-085', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waxing-085.png'
state 'Moon-waxing-090', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waxing-090.png'
state 'Moon-waxing-095', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waxing-095.png'
state 'Moon-waxing-100', label: '', icon: 'https://raw.githubusercontent.com/SANdood/Icons/master/Moon/Moon-waxing-100.png'
}
valueTile("mooninfo", "device.moonInfo", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label: '${currentValue}'
}
valueTile("lastSTupdate", "device.lastSTupdate", inactiveLabel: false, width: 3, height: 1, decoration: "flat", wordWrap: true) {
state("default", label: 'Updated\nat ${currentValue}')
}
valueTile("attribution", "device.attribution", inactiveLabel: false, width: 3, height: 1, decoration: "flat", wordWrap: true) {
state("default", label: 'Powered by: ${currentValue}')
}
valueTile("heatIndex", "device.heatIndexDisplay", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label:'Heat\nIndex\n${currentValue}'
}
valueTile("windChill", "device.windChillDisplay", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label:'Wind\nChill\n${currentValue}'
}
valueTile("weather", "device.weather", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label:'${currentValue}'
}
valueTile("todayTile", "device.locationName", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label:'TDY\n(act)'
}
valueTile("todayFcstTile", "device.locationName", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label:'TDY\n(fcst)'
}
valueTile("yesterdayTile", "device.locationName", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label:'YDA\n(act)'
}
valueTile("tomorrowTile", "device.locationName", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label:'TMW\n(fcst)'
}
valueTile("precipYesterday", "device.precipYesterdayDisplay", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label:'Precip\nYDA\n${currentValue}'
}
valueTile("precipToday", "device.precipTodayDisplay", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label:'Precip\nTDY\n${currentValue}'
}
valueTile("precipFcst", "device.precipFcstDisplay", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label:'Precip\nTDY\n~${currentValue}'
}
valueTile("precipTom", "device.precipTomDisplay", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label:'Precip\nTMW\n~${currentValue}'
}
valueTile("precipLastHour", "device.precipLastHourDisplay", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label:'Precip\nlast hr\n${currentValue}'
}
valueTile("precipRate", "device.precipRateDisplay", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label:'Precip\nper hr\n${currentValue}'
}
standardTile("refresh", "device.weather", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label: "", action: "refresh", icon:"st.secondary.refresh"
}
valueTile("forecast", "device.forecast", inactiveLabel: false, width: 5, height: 1, decoration: "flat", wordWrap: true) {
state "default", label:'${currentValue}'
}
valueTile("sunrise", "device.sunriseAPM", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label:'Sun\nRises\n${currentValue}'
}
valueTile("sunset", "device.sunsetAPM", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label:'Sun\nSets\n${currentValue}'
}
valueTile("moonrise", "device.moonriseAPM", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label:'Moon\nRises\n${currentValue}'
}
valueTile("moonset", "device.moonsetAPM", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label:'Moon\nSets\n${currentValue}'
}
valueTile("daylight", "device.dayHours", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label:'Daylight\nHours\n${currentValue}'
}
valueTile("light", "device.illuminance", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label:'Illum\n${currentValue}\nlux'
}
valueTile("pop", "device.popDisplay", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label:'${currentValue}'
}
valueTile("popFcst", "device.popFcstDisplay", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label:'${currentValue}'
}
valueTile("popTom", "device.popTomDisplay", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label:'${currentValue}'
}
valueTile("evo", "device.etDisplay", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label:'ET\nlast hr\n${currentValue}'
}
valueTile("uvIndex", "device.uvIndex", inactiveLabel: false, decoration: "flat") {
state "uvIndex", label: 'UV\nIndex\n${currentValue}'
}
standardTile("water", "device.water", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label: 'updating...', icon: "st.unknown.unknown.unknown"
state "wet", label: 'wet', icon: "st.alarm.water.wet", backgroundColor:"#00A0DC"
state "dry", label: 'dry', icon: "st.alarm.water.dry", backgroundColor:"#FFFFFF"
}
valueTile("dewpoint", "device.dewpoint", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label:'Dew\nPoint\n${currentValue}°'
}
valueTile("pressure", "device.pressureDisplay", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "default", label: '${currentValue}'
}
valueTile("solarRadiation", "device.solarRadiation", inactiveLabel: false, width: 1, height: 1, decoration: "flat", wordWrap: true) {
state "solarRadiation", label: 'SolRad\n${currentValue}\nW/m²'
}
valueTile("windinfo", "device.windinfo", inactiveLabel: false, width: 2, height: 1, decoration: "flat", wordWrap: true) {
state "windinfo", label: '${currentValue}'
}
valueTile('aqi', 'device.airQualityIndex', inactiveLabel: false, width: 1, height: 1, decoration: 'flat', wordWrap: true) {
state 'default', label: 'AQI\n${currentValue}',
backgroundColors: [
[value: 0, color: '#44b621'], // Green - Good
[value: 50, color: '#44b621'],
[value: 51, color: '#f1d801'], // Yellow - Moderate
[value: 100, color: '#f1d801'],
[value: 101, color: '#d04e00'], // Orange - Unhealthy for Sensitive groups
[value: 150, color: '#d04e00'],
[value: 151, color: '#bc2323'], // Red - Unhealthy
[value: 200, color: '#bc2323'],
[value: 201, color: '#800080'], // Purple - Very Unhealthy
[value: 300, color: '#800080'],
[value: 301, color: '#800000'] // Maroon - Hazardous
]
}
valueTile("temperature2", "device.temperature", width: 1, height: 1, canChangeIcon: true) {
state "temperature", label: '${currentValue}°', icon: 'st.Weather.weather2',
backgroundColors: (temperatureColors)
}
valueTile("highTempYday", "device.highTempYesterday", width: 1, height: 1, canChangeIcon: true) {
state "temperature", label: '${currentValue}°',
backgroundColors: (temperatureColors)
}
valueTile("lowTempYday", "device.lowTempYesterday", width: 1, height: 1, canChangeIcon: true) {
state "temperature", label: '${currentValue}°',
backgroundColors: (temperatureColors)
}
valueTile("highTemp", "device.highTemp", width: 1, height: 1, canChangeIcon: true) {
state "temperature", label: '${currentValue}°',
backgroundColors: (temperatureColors)
}
valueTile("lowTemp", "device.lowTemp", width: 1, height: 1, canChangeIcon: true) {
state "temperature", label: '${currentValue}°',
backgroundColors: (temperatureColors)
}
valueTile("highTempFcst", "device.highTempForecast", width: 1, height: 1, canChangeIcon: true) {
state "temperature", label: '${currentValue}°',
backgroundColors: (temperatureColors)
}
valueTile("lowTempFcst", "device.lowTempForecast", width: 1, height: 1, canChangeIcon: true) {
state "temperature", label: '${currentValue}°',
backgroundColors: (temperatureColors)
}
valueTile("highTempTom", "device.highTempTomorrow", width: 1, height: 1, canChangeIcon: true) {
state "temperature", label: '${currentValue}°',
backgroundColors: (temperatureColors)
}
valueTile("lowTempTom", "device.lowTempTomorrow", width: 1, height: 1, canChangeIcon: true) {
state "temperature", label: '${currentValue}°',
backgroundColors: (temperatureColors)
}
valueTile("humidity", "device.humidity", decoration: "flat", width: 1, height: 1) {
state("default", label: '${currentValue}%', unit: "%", defaultState: true, backgroundColors: [ //#d28de0")
[value: 10, color: "#00BFFF"],
[value: 100, color: "#ff66ff"]
] )
}
valueTile("lowHumYday", "device.lowHumYesterday", decoration: "flat", width: 1, height: 1) {
state("default", label: '${currentValue}%', unit: "%", defaultState: true, backgroundColors: [ //#d28de0")
[value: 10, color: "#00BFFF"],
[value: 100, color: "#ff66ff"]
] )
}
valueTile("highHumYday", "device.highHumYesterday", decoration: "flat", width: 1, height: 1) {
state("default", label: '${currentValue}%', unit: "%", defaultState: true, backgroundColors: [ //#d28de0")
[value: 10, color: "#00BFFF"],
[value: 100, color: "#ff66ff"]
] )
}
valueTile("lowHumidity", "device.lowHumidity", decoration: "flat", width: 1, height: 1) {
state("default", label: '${currentValue}%', unit: "%", defaultState: true, backgroundColors: [ //#d28de0")
[value: 10, color: "#00BFFF"],
[value: 100, color: "#ff66ff"]
] )
}
valueTile("highHumidity", "device.highHumidity", decoration: "flat", width: 1, height: 1) {
state("default", label: '${currentValue}%', unit: "%", defaultState: true, backgroundColors: [ //#d28de0")
[value: 10, color: "#00BFFF"],
[value: 100, color: "#ff66ff"]
] )
}
valueTile("avgHumFcst", "device.avgHumForecast", decoration: "flat", width: 1, height: 1) {
state("default", label: '${currentValue}%', unit: "%", defaultState: true, backgroundColors: [ //#d28de0")
[value: 10, color: "#00BFFF"],
[value: 100, color: "#ff66ff"]
] )
}
valueTile("avgHumTom", "device.avgHumTomorrow", decoration: "flat", width: 1, height: 1) {
state("default", label: '${currentValue}%', unit: "%", defaultState: true, backgroundColors: [ //#d28de0")
[value: 10, color: "#00BFFF"],
[value: 100, color: "#ff66ff"]
] )
}
valueTile("respTime", "device.respTime", inactiveLabel: false, width: 2, height: 1, decoration: "flat", wordWrap: true) {
state "default", label: 'Response Time\n${currentValue} seconds'
}
valueTile("respAvg", "device.respAvg", inactiveLabel: false, width: 2, height: 1, decoration: "flat", wordWrap: true) {
state "default", label: 'Avg Resp Time\n${currentValue} seconds'
}
standardTile('oneByTwo', 'device.logo', width: 1, height: 2, decoration: 'flat') {
state "default", defaultState: true
}
standardTile('oneByOne', 'device.logo', width: 1, height: 1, decoration: 'flat') {
state "default", defaultState: true
}
main([/* "temperature2", */'temperatureDisplay'])
details([ "temperatureDisplay",
'aqi', "heatIndex", "dewpoint", 'windChill', "pressure", 'humidity',
"moonDisplay", "mooninfo", "windinfo", "evo", "water",
"solarRadiation", "light", "uvIndex", "precipToday", "precipRate", "precipLastHour",
"forecast", 'pop',
"sunrise", "sunset", "daylight", "moonrise", "moonset", 'refresh',
'yesterdayTile', 'lowTempYday', 'highTempYday', 'lowHumYday', 'highHumYday', "precipYesterday",
"todayTile", 'lowTemp', 'highTemp', 'lowHumidity', 'highHumidity', 'precipToday',
'todayFcstTile', 'lowTempFcst', 'highTempFcst', 'avgHumFcst', 'popFcst', 'precipFcst',
'tomorrowTile', 'lowTempTom', 'highTempTom', 'avgHumTom', 'popTom', 'precipTom',
'lastSTupdate', 'attribution',
'respTime', 'respAvg'
])
}
}
def noOp() {}
// ****************************************************************************************************
// Initialization, Setup and Operation
// ***********************************
def parse(String description) {
if (debugOn) log.debug "Parsing '${description}'"
}
def installed() {
if (!state.hubPlatform) log.info "Installing on ${getHubPlatform()}"
state.meteoWeather = [:]
state.darkSkyWeather = [:]
state.twcConditions = [:]
state.twcForecast = [:]
initialize()
}
def uninstalled() {
unschedule()
}
def updated() {
log.info "Updated, settings: ${settings}"
state.hubPlatform = null; getHubPlatform(); // Force hub update if we are updated...just in case
state.meteoWeatherVersion = getVersionLabel()
unschedule()
initialize()
}
def rescheduleMeteoWeather() {
unschedule(getMeteoWeather)
def t = settings.updateMins ?: '5'
if (t == '1') {
log.info "Rescheduling for every minute"
runEvery1Minute(getMeteoWeather)
} else {
log.info "Rcheduling for every ${t} minutes"
"runEvery${t}Minutes"(getMeteoWeather)
}
}
def initialize() {
log.info getVersionLabel() + " on ${state.hubPlatform} Initializing..."
def poweredBy = "MeteoBridge"
if (settings.shortStats) log.info "Using optimized MeteoBridge template"
def endBy = ''
state.respTotal = 0
state.respCount = 0
// Create the template using the latest preferences values (components defined at the bottom)
send(name:'hubAction', value: null, displayed: false)
send(name:'purpleAir', value: null, displayed: false)
send(name:'darkSkyWeather', value: null, displayed: false)
state.meteoTemplate = ((fcstSource && (fcstSource == 'meteo'))? forecastTemplate : '') + currentTemplate
state.templateReload = true
if (debugOn) log.debug "initial meteoTemplate: " + state.meteoTemplate
if (debugOn) send(name: 'meteoTemplate', value: state.meteoTemplate, displayed: false, isStateChange: true)
// state.iconStore = "https://raw.githubusercontent.com/SANdood/Icons/master/Weather/"
state.iconStore = "https://github.com/SANdood/Icons/blob/master/Weather/"
def userpassascii = meteoUser + ':' + meteoPassword
if (state.isST) {
state.userpass = "Basic " + userpassascii.encodeAsBase64().toString()
} else {
state.userpass = "Basic " + userpassascii.bytes.encodeBase64().toString()
}
// Schedule the updates
state.today = null
runIn(5,getMeteoWeather) // Have to wait to let the state changes settle
def t = settings.updateMins ?: '5'
if (t == '1') {
log.info "scheduling for every minute"
runEvery1Minute(getMeteoWeather)
} else {
log.info "scheduling for every ${t} minutes"
"runEvery${t}Minutes"(getMeteoWeather)
}
state.twcForTomorrow = false
state.wunderForTomorrow = false
if ((fcstSource && (fcstSource != 'darksky')) || (darkSkyKey == null)){
if (fcstSource && (fcstSource == 'wunder')) {
state.wunderForTomorrow = false // (fcstSource && (fcstSource == 'meteo')) ? true : false
//runEvery10Minutes(updateWundergroundTiles) // This doesn't change all that frequently
//updateWundergroundTiles()
send(name: 'twcConditions', value: null, displayed: false)
send(name: 'twcForecast', value: null, displayed: false)
send(name: 'wundergroundObs', value: null, displayed: false)
log.error "WeatherUnderground (getWeatherFeature) has been dreprecated by SmartThings and is no longer supported!"
// endBy= ' and Weather Underground'
} else if ((fcstSource && ((fcstSource == 'twc') || (fcstSource == 'meteo'))) || (darkSkyKey == null)) {
state.twcForTomorrow = (fcstSource && (fcstSource == 'meteo')) // ? true : false
runEvery10Minutes(updateTwcTiles)
updateTwcTiles()
send(name: 'wundergroundObs', value: null, displayed: false)
endBy += ' and The Weather Company'
}
}
if (fcstSource && (fcstSource == 'darksky') && (darkSkyKey != null)) {
endBy = (endBy == '') ? ' and Dark Sky' : ', Dark Sky' + endBy
runEvery15Minutes(getDarkSkyWeather) // Async Dark Sky current & forecast weather
send(name: 'twcConditions', value: null, displayed: false)
send(name: 'twcForecast', value: null, displayed: false)
send(name: 'wundergroundObs', value: null, displayed: false)
log.info "Using DarkSky"
getDarkSkyWeather()
}
if (purpleID) {
endBy = (endBy == '') ? ' and PurpleAir' : ', PurpleAir' + endBy
runEvery3Minutes(getPurpleAirAQI) // Async Air Quality
// getPurpleAirAQI()
}
poweredBy += endBy
send(name: 'attribution', value: poweredBy, displayed: false, isStateChange: true)
log.info "Initialization complete..."
}
def runEvery2Minutes(handler) {
Random rand = new Random()
//log.debug "Random2: ${rand}"
int randomSeconds = rand.nextInt(59)
schedule("${randomSeconds} 0/2 * * * ?", handler)
}
def runEvery3Minutes(handler) {
Random rand = new Random()
//log.debug "Random3: ${rand}"
int randomSeconds = rand.nextInt(59)
schedule("${randomSeconds} 0/3 * * * ?", handler)
}
def poll() { refresh() }
def refresh() {
state.today = null
getMeteoWeather( false )
if (darkSkyKey != null) {
getDarkSkyWeather()
}
if (fcstSource) {
if (state.twcForTomorrow || (fcstSource == 'twc')) updateTwcTiles()
}
getPurpleAirAQI()
}
// def getWeatherReport() { return state.meteoWeather }
def configure() { updated() }
// ***********************************************************************************************************************
// Weather Data Handlers
// *********************
def getMeteoWeather( yesterday = false) {
log.info "Polling..."
if (debugOn) log.trace "getMeteoWeather( yesterday = ${yesterday} )"
if (!state.meteoWeatherVersion || (state.meteoWeatherVersion != getVersionLabel())) {
// if the version level of the code changes, silently run updated() and initialize()
log.info 'Version changed, updating...'
runIn(2, updated, [overwrite: true])
//updated()
return
}
if (device.currentValue('highTempYesterday') == null) { log.info 'Forcing yesterday'; yesterday = true; }
// Create the hubAction request based on updated preferences
def hubAction
if (state.isST) {
hubAction = physicalgraph.device.HubAction.newInstance(
method: 'GET',
path: '/cgi-bin/template.cgi',
headers: [ HOST: "${settings.meteoIP}:${settings.meteoPort}", 'Authorization': state.userpass ],
query: ['template': "{\"timeGet\":${now()}," + MBSystemTemplate + (yesterday ? yesterdayTemplate : state.meteoTemplate ), 'contenttype': 'application/json' ],
null,
[callback: meteoWeatherCallback]
)
} else {
hubAction = hubitat.device.HubAction.newInstance(
method: 'GET',
path: '/cgi-bin/template.cgi',
headers: [ HOST: "${settings.meteoIP}:${settings.meteoPort}", 'Authorization': state.userpass ],
query: ['template': "{\"timeGet\":${now()}," + MBSystemTemplate + (yesterday ? yesterdayTemplate : state.meteoTemplate), 'contenttype': 'application/json' ],
null,
[callback: meteoWeatherCallback, timeout: 20]
)
}
if (debugOn) send(name: 'hubAction', value: hubAction, displayed: false, isStateChange: true)
if (debugOn) log.debug "hubAction (${hubAction.toString().size()}): ${hubAction.toString()}"
// log.debug "query (raw): ${hubAction}"
try {
state.callStart = yesterday ? null : now()
sendHubCommand(hubAction)
} catch (Exception e) {
log.error "getMeteoWeather() sendHubCommand Exception ${e} on ${hubAction}"
}
if (debugOn) log.info 'getMeteoWeather() update request sent'
}
def meteoWeatherCallback(hubResponse) {
if (state.callStart) state.callEnd = now()
if (debugOn) log.trace "meteoWeatherCallback() response recieved: " + hubResponse.status
if (debugOn) log.debug "meteoWeatherCallback() headers: " + hubResponse.headers
if (hubResponse.status == 200) {
if (debugOn) log.debug "hubResponse.body: ${hubResponse.body}"
if (hubResponse.json) {
state.meteoWeather = hubResponse.json
if (debugOn) send(name: 'meteoWeather', value: hubResponse.json, displayed: false, isStateChange: true)
} else if (hubResponse.body) {
// Hubitat doesn't do the json conversion for us
log.warn "Only got hubResponse.body (isHE: ${state.isHE})"
state.meteoWeather = new JsonSlurper().parseText(hubResponse.body)