-
Notifications
You must be signed in to change notification settings - Fork 7
/
Weather-Display With DarkSky.net Forecast Driver.groovy
1089 lines (1026 loc) · 72 KB
/
Weather-Display With DarkSky.net Forecast Driver.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
/*
Weather-Display With DarkSky.net Forecast Driver
Import URL: https://raw.githubusercontent.com/Scottma61/Hubitat/master/Weather-Display%20With%20DarkSky.net%20Forecast%20Driver.groovy
Copyright 2019 @Matthew (Scottma61)
Many people contributed to the creation of this driver. Significant contributors include:
- @Cobra who adapted it from @mattw01's work and I thank them for that!
- @bangali for his original APIXU.COM base code that much of the early versions of this driver was
adapted from.
- @bangali for his the Sunrise-Sunset.org code used to calculate illuminance/lux and the more
recent adaptations of that code from @csteele in his continuation driver 'wx-ApiXU'.
- @csteele (and prior versions from @bangali) for the attribute selection code.
- @csteele for his examples on how to convert to asyncHttp calls to reduce Hub resource utilization.
- @bangali also contributed the icon work from
https://github.com/jebbett for new cooler 'Alternative' weather icons with icons courtesy
of https://www.deviantart.com/vclouds/art/VClouds-Weather-Icons-179152045.
- 'waynedgrant' for his json webservice that make the weather station data available to the driver.
In addition to all the cloned code from the Hubitat community, I have heavily modified/created new
code myself @Matthew (Scottma61) with lots of help from the Hubitat community. If you believe you
should have been acknowledged or received attribution for a code contribution, I will happily do so.
While I compiled and orchestrated the driver, very little is actually original work of mine.
This driver is free to use. I do not accept donations. Please feel free to contribute to those
mentioned here if you like this work, as it would not have been possible without them.
*********************************************************************************************************
* REQUIREMENTS: You MUST have a Personal Weather Station (PWS) and use Weather-Display software to *
* capture that weather data from your network or a web server. If you do not meet this requirement *
* then this driver will not work for you. This uses the Weather-Display data files from a webserver *
* you specify in the driver preferences. I used waynedgrant's work to make those data files available *
* in JSON format (https://github.com/waynedgrant/json-webservice-wdlive). *
*********************************************************************************************************
This driver is intended to pull data from data files on a web server created by Weather-Display software
(http://www.weather-display.com). It will also supplement forecast data from Dark Sky (DS)
(http://darksky.net). You will need your DarkSky API key to use the forecast from that sites,
but the driver it will work without an external forecast source.
The driver uses the Weather-Display data as the primary current weather dataset. There are a few options you can select
from like using your forecast source for illuminance/solar radiation/lux if you do not have those sensors.
You can also select to use a base set of condition icons from the forecast source, or an 'alternative'
(fancier) set. The base 'Standard' icon set will be from WeatherUnderground. You may choose the
fancier 'Alternative' icon set if you use the Dark Sky.
*** PLEASE NOTE: You should download and store these 'Alternative' icons on your own server and
change the reference to that location in the driver. There is no assurance that those icon files will
remain in my github repository. ***
The driver exposes both metric and imperial measurements for you to select from.
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.
Last Update 09/14/2019
{ Left room below to document version changes...}
V4.1.6 Another optional attribute bug fix. - 09/15/2019
V4.1.5 Tweaking and bug fixes. - 09/14/2019
V4.1.4 Added 'weatherIcons' used for OWM icons/dashboard - 09/14/2019
V4.1.3 Added windSpeed and windDirection, required for some dashboards. - 09/14/2019
V4.1.2 Attribute now dislplayed for dashboards ** Read caution below ** - 09/14/2019
V4.1.1 - bug fixes - 09/13/2019
V4.1.0 - Initial release of driver with ApiXU.com completely removed. - 09/12/2019
----------------------------------------------------------------------------------------------------------
V4.0.0 - Complete re-write: asyncHttp calls, selectable attributes, many corrections - 09/09/2019
V3.0.4 - Further myTile character reduction. - 03/24/2019
V3.0.3 - Altered myTile to attempt to remain under to 1024 charater limit for Dashboard 2.0- 03/20/2019
V3.0.2 - Instruction clarificatons and log improvements - 03/19/2019
V3.0.1 - Code tweaks and corrections. - 03/16/2019
V3.0.0 - Major code optimization/reorganization - Removed WU option - 02/16/2019
V2.1.6 - Format cleanup; improved Dark Sky condition mapping - 01/21/2019
V2.1.5 - myTile redo - added icons, Pressure, Chance of rain, Precipitation - 01/12/2019
V2.1.4 - Bug fix for Dark Sky condition_code/text/icon values; Added alerts to myTile - 01/06/2019
V2.1.3 - Code cleanup/correction - no functionality changes - 01/05/2019
V2.1.2 - Added DarkSky as an external forecast source - 01/04/2019
V2.1.1 - Added Apparent temp ('Feels Like') to myTile - 12/31/2018
V2.1.0 - Tweaked myTile attribute. Removed "isStateChange:true" from sendEvents - 12/30/2018
V2.0.9 - Added a variation of @arnb's myTile attribute - 12/9/2018
V2.0.8 - Declared attributes: alert, twilight_begin, twilight_end, weatherSummary - 11/3/2018
V2.0.7 - Changed sunrise-sunset.org api from https: to http: - 9/21/2018
V2.0.6 - More cleanup of table lookups/translations. - 9/03/2018
V2.0.5 - Consolidated table lookups (transform.field), cleaned up forecast translations - 8/20/2016
V2.0.4 - Translated forecastIcon for APIXU to WU equivalent - 8/16/2018
V2.0.3 - Added forecastIcon attribute for SharpTools.io, various code cleanups. - 8/16/2018
V2.0.2 - Added hemisphere selectors for correct Lon/Lat on station. Removed '?raw=true' - 8/12/2018
suffix from alternative icon file location if not on 'github.com'.
V2.0.1 - Code cleanup; Added 'Observation' times; Changed 'Update' time to 'Poll' time - 8/11/2018
corrected display of some options variables (Illuminance/UV/FeelsLike) when no forecast source selected.
V2.0.0 - New version completely rebuilt 08/10/2018
- Made changes to Attributes. Attributes should now be available for dashboards. *CAUTION - READ BELOW*
**ATTRIBUTES CAUTION**
The way the 'optional' attributes work:
- Initially, only the optional attributes selected will show under 'Current States' and will be available in
dashboards.
- Once an attribute has been selected it too will show under 'Current States' and be available in dashboards.
<*** HOWEVER ***> If you ever de-select the optional attribute, it will still show under 'Current States'
and will still show as an attribute for dashboards **BUT IT'S DATA WILL NO LONGER BE REFRESHED WITH DATA
POLLS**. This means what is shown on the 'Current States' and dashboard tiles for de-selected attributes
may not be current valid data.
- To my knowledge, the only way to remove the de-selected attribute from 'Current States' and not show it as
available in the dashboard is to delete the virtual device and create a new one AND DO NOT SELECT the
attribute you do not want to show.
*/
import groovy.transform.Field
metadata {
definition (name: "Weather-Display With DarkSky.net Forecast Driver", namespace: "Matthew", author: "Scottma61", importUrl: "https://raw.githubusercontent.com/Scottma61/Hubitat/master/Weather-Display%20With%20DarkSky.net%20Forecast%20Driver.groovy") {
capability "Actuator"
capability "Sensor"
capability "Temperature Measurement"
capability "Illuminance Measurement"
capability "Relative Humidity Measurement"
capability "Pressure Measurement"
capability "Ultraviolet Index"
attributesMap.each
{
// k, v -> if (("${k}Publish") == true && v.typeof) attribute "${k}", "${v.typeof}"
k, v -> if (v.typeof) attribute "${k}", "${v.typeof}"
}
// The following attributes may be needed for dashboards that require these attributes,
// so they are listed here and shown by default.
attribute "city", "string" //SharpTool.io SmartTiles
attribute "feelsLike", "number" //SharpTool.io SmartTiles
attribute "forecastIcon", "string" //SharpTool.io
attribute "localSunrise", "string" //SharpTool.io SmartTiles
attribute "localSunset", "string" //SharpTool.io SmartTiles
attribute "percentPrecip", "number" //SharpTool.io SmartTiles
attribute "weather", "string" //SharpTool.io SmartTiles
attribute "weatherIcon", "string" //SharpTool.io SmartTiles
attribute "weatherIcons", "string" //Hubitat OpenWeather
attribute "wind", "number" //SharpTool.io
attribute "windDirection", "number" //Hubitat OpenWeather
attribute "windSpeed", "number" //Hubitat OpenWeather
command "pollData"
}
def settingDescr = settingEnable ? "<br><i>Hide many of the Preferences to reduce the clutter, if needed, by turning OFF this toggle.</i><br>" : "<br><i>Many Preferences are available to you, if needed, by turning ON this toggle.</i><br>"
preferences() {
section("Query Inputs"){
input "extSource", "enum", title: "Select Forecast Source", required:true, defaultValue: 1, options: [1:"Weather-Display", 2:"DarkSky"]
input "pollIntervalStation", "enum", title: "Station Poll Interval", required: true, defaultValue: "3 Hours", options: ["Manual Poll Only", "1 Minute", "5 Minutes", "10 Minutes", "15 Minutes", "30 Minutes", "1 Hour", "3 Hours"]
input "pollLocationStation", "text", required: true, title: "Station Data File Location:", defaultValue: "http://"
input "apiKey", "text", required: true, defaultValue: "Type DarkSky.net API Key Here", title: "API Key"
input "pollIntervalForecast", "enum", title: "External Source Poll Interval", required: true, defaultValue: "3 Hours", options: ["Manual Poll Only", "5 Minutes", "10 Minutes", "15 Minutes", "30 Minutes", "1 Hour", "3 Hours"]
input "sourceImg", "bool", required: true, defaultValue: false, title: "Icons from: On = Standard - Off = Alternative"
input "iconLocation", "text", required: true, defaultValue: "https://raw.githubusercontent.com/Scottma61/WeatherIcons/master/", title: "Alternative Icon Location:"
input "iconType", "bool", title: "Condition Icon: On = Current - Off = Forecast", required: true, defaultValue: false
input "tempFormat", "enum", required: true, defaultValue: "Fahrenheit (°F)", title: "Display Unit - Temperature: Fahrenheit (°F) or Celsius (°C)", options: ["Fahrenheit (°F)", "Celsius (°C)"]
input "datetimeFormat", "enum", required: true, defaultValue: "m/d/yyyy 12 hour (am|pm)", title: "Display Unit - Date-Time Format", options: [1:"m/d/yyyy 12 hour (am|pm)", 2:"m/d/yyyy 24 hour", 3:"mm/dd/yyyy 12 hour (am|pm)", 4:"mm/dd/yyyy 24 hour", 5:"d/m/yyyy 12 hour (am|pm)", 6:"d/m/yyyy 24 hour", 7:"dd/mm/yyyy 12 hour (am|pm)", 8:"dd/mm/yyyy 24 hour", 9:"yyyy/mm/dd 24 hour"]
input "distanceFormat", "enum", required: true, defaultValue: "Miles (mph)", title: "Display Unit - Distance/Speed: Miles or Kilometres", options: ["Miles (mph)", "Kilometers (kph)"]
input "pressureFormat", "enum", required: true, defaultValue: "Inches", title: "Display Unit - Pressure: Inches or Millibar", options: ["Inches", "Millibar"]
input "rainFormat", "enum", required: true, defaultValue: "Inches", title: "Display Unit - Precipitation: Inches or Millimetres", options: ["Inches", "Millimetres"]
input "summaryType", "bool", title: "Full Weather Summary", required: true, defaultValue: false
input "logSet", "bool", title: "Create extended Logging", required: true, defaultValue: false
input "sourcefeelsLike", "bool", required: true, title: "Feelslike from Weather-Display?", defaultValue: false
input "sourceIllumination", "bool", required: true, title: "Illuminance from Weather-Display?", defaultValue: true
input "sourceUV", "bool", required: true, title: "UV from Weather-Display?", defaultValue: true
input "settingEnable", "bool", title: "<b>Display All Preferences</b>", description: "$settingDescr", defaultValue: true
// build a Selector for each mapped Attribute or group of attributes
attributesMap.each
{
keyname, attribute ->
if (settingEnable) input "${keyname}Publish", "bool", title: "${attribute.title}", required: true, defaultValue: "${attribute.default}", description: "<br>${attribute.descr}<br>"
}
}
}
}
// <<<<<<<<<< Begin Sunrise-Sunset Poll Routines >>>>>>>>>>
def pollSunRiseSet() {
currDate = new Date().format("yyyy-MM-dd", TimeZone.getDefault())
log.info("Weather-Display Driver - INFO: Polling Sunrise-Sunset.org")
def requestParams = [ uri: "https://api.sunrise-sunset.org/json?lat=" + location.latitude + "&lng=" + location.longitude + "&formatted=0" ]
if (currDate) {requestParams = [ uri: "https://api.sunrise-sunset.org/json?lat=" + location.latitude + "&lng=" + location.longitude + "&formatted=0&date=$currDate" ]}
LOGINFO("Poll Sunrise-Sunset: $requestParams")
asynchttpGet("sunRiseSetHandler", requestParams)
return
}
def sunRiseSetHandler(resp, data) {
if(resp.getStatus() == 200 || resp.getStatus() == 207) {
sunRiseSet = resp.getJson().results
updateDataValue("sunRiseSet", resp.data)
LOGINFO("Sunrise-Sunset Data: $sunRiseSet")
setDateTimeFormats(datetimeFormat)
updateDataValue("currDate", new Date().format("yyyy-MM-dd", TimeZone.getDefault()))
updateDataValue("currTime", new Date().format("HH:mm", TimeZone.getDefault()))
updateDataValue("riseTime", new Date().parse("yyyy-MM-dd'T'HH:mm:ssXXX", sunRiseSet.sunrise).format("HH:mm", TimeZone.getDefault()))
updateDataValue("noonTime", new Date().parse("yyyy-MM-dd'T'HH:mm:ssXXX", sunRiseSet.solar_noon).format("HH:mm", TimeZone.getDefault()))
updateDataValue("setTime", new Date().parse("yyyy-MM-dd'T'HH:mm:ssXXX", sunRiseSet.sunset).format("HH:mm", TimeZone.getDefault()))
updateDataValue("tw_begin", new Date().parse("yyyy-MM-dd'T'HH:mm:ssXXX", sunRiseSet.civil_twilight_begin).format("HH:mm", TimeZone.getDefault()))
updateDataValue("tw_end", new Date().parse("yyyy-MM-dd'T'HH:mm:ssXXX", sunRiseSet.civil_twilight_end).format("HH:mm", TimeZone.getDefault()))
updateDataValue("localSunset",new Date().parse("yyyy-MM-dd'T'HH:mm:ssXXX", sunRiseSet.sunset).format(timeFormat, TimeZone.getDefault()))
updateDataValue("localSunrise", new Date().parse("yyyy-MM-dd'T'HH:mm:ssXXX", sunRiseSet.sunrise).format(timeFormat, TimeZone.getDefault()))
if(getDataValue("riseTime") <= getDataValue("currTime") && getDataValue("setTime") >= getDataValue("currTime")) {
updateDataValue("is_day", "1")
} else {
updateDataValue("is_day", "0")
}
} else {
log.warn "Sunrise-Sunset api did not return data"
}
return
}
// >>>>>>>>>> End Sunrise-Sunset Poll Routines <<<<<<<<<<
// <<<<<<<<<< Begin Weather-Display Poll Routines >>>>>>>>>>
def pollWD() {
log.info("Weather-Display Driver - INFO: Polling Weather-Display")
def ParamsWD = [ uri: "${pollLocationStation}everything.php" ]
LOGINFO("Poll Weather-Display: $ParamsWD")
asynchttpGet("pollWDHandler", ParamsWD)
return
}
def pollWDHandler(resp, data) {
if(resp.getStatus() == 200 || resp.getStatus() == 207) {
wd = parseJson(resp.data)
LOGINFO("Weather-Display Data: $wd")
doPollWD() // parse the data returned by ApiXU
} else {
log.error "Weather-Display weather api did not return data"
}
return
}
def doPollWD() {
// <<<<<<<<<< Begin Setup Global Variables >>>>>>>>>>
setDateTimeFormats(datetimeFormat)
setMeasurementMetrics(distanceFormat, pressureFormat, rainFormat, tempFormat)
updateDataValue("currDate", new Date().format("yyyy-MM-dd", TimeZone.getDefault()))
updateDataValue("currTime", new Date().format("HH:mm", TimeZone.getDefault()))
if(getDataValue("riseTime") <= getDataValue("currTime") && getDataValue("setTime") >= getDataValue("currTime")) {
updateDataValue("is_day", "1")
} else {
updateDataValue("is_day", "0")
}
// >>>>>>>>>> End Setup Global Variables <<<<<<<<<<
// <<<<<<<<<< Begin Setup Station Variables >>>>>>>>>>
sotime = new Date().parse("HH:mm dd/MM/yyyy", wd.time.time_date, TimeZone.getDefault())
updateDataValue("sotime", sotime.toString())
sutime = new Date().parse("HH:mm dd/MM/yyyy", wd.time.time_date, TimeZone.getDefault())
updateDataValue("sutime", sutime.toString())
// >>>>>>>>>> End Setup Station Variables <<<<<<<<<<
// <<<<<<<<<< Begin Process Only If No External Forcast Is Selected >>>>>>>>>>
if(extSource.toInteger() == 1){
fotime = new Date().parse("HH:mm d/M/yyyy", wd.time.time_date, TimeZone.getDefault())
futime = new Date().parse("HH:mm d/M/yyyy", wd.time.time_date, TimeZone.getDefault())
if(!wd.everything.weather.solar.percentage){
cloud = 1
} else {
if(wd.everything.weather.solar.percentage.toInteger() == 100){
updateDataValue("cloud", "1")
} else {
updateDataValue("cloud",(100 - wd.everything.weather.solar.percentage.toInteger()).toString())
}
}
c_code = (getDataValue("is_day")=="1" ? '' : 'nt_')
switch(!wd.everything.forecast.icon.code ? 99 : wd.everything.forecast.icon.code.toInteger()) {
case 0: c_code += 'sunny'; break;
case 1: c_code += 'clear'; break;
case 2: c_code += 'partlycloudy'; break;
case 3: c_code += 'clear'; break;
case 4: c_code += 'cloudy'; break;
case 5: c_code += 'clear'; break;
case 6: c_code += 'fog'; break;
case 7: c_code += 'hazy'; break;
case 8: c_code += 'rain'; break;
case 9: c_code += 'clear'; break;
case 10: c_code += 'hazy'; break;
case 11: c_code += 'fog'; break;
case 12: c_code += 'rain'; break;
case 13: c_code += 'mostlycloudy'; break;
case 14: c_code += 'rain'; break;
case 15: c_code += 'rain'; break;
case 16: c_code += 'snow'; break;
case 17: c_code += 'tstorms'; break;
case 18: c_code += 'mostlycloudy'; break;
case 19: c_code += 'mostlycloudy'; break;
case 20: c_code += 'rain'; break;
case 21: c_code += 'rain'; break;
case 22: c_code += 'rain'; break;
case 23: c_code += 'sleet'; break;
case 24: c_code += 'sleet'; break;
case 25: c_code += 'snow'; break;
case 26: c_code += 'snow'; break;
case 27: c_code += 'snow'; break;
case 28: c_code += 'sunny'; break;
case 29: c_code += 'tstorms'; break;
case 30: c_code += 'tstorms'; break;
case 31: c_code += 'tstorms'; break;
case 32: c_code += 'tstorms'; break;
case 33: c_code += 'breezy'; break;
case 34: c_code += 'partlycloudy'; break;
case 35: c_code += 'rain'; break;
default: c_code += 'unknown'; break;
}
updateDataValue("condition_code", c_code)
updateDataValue("condition_text", wd.everything.forecast.icon.text)
def (holdlux, bwn) = estimateLux(getDataValue("condition_code"), getDataValue("cloud")) //condition_code, cloud)
updateDataValue("bwn", bwn)
// <<<<<<<<<< Begin Icon processing >>>>>>>>>>
if(sourceImg==false){ // 'Alternative' Icons selected
imgName = getImgName(getDataValue("condition_code"))
sendEventPublisg(name: "condition_icon", value: '<img src=' + imgName + '>')
sendEventPublish(name: "condition_iconWithText", value: "<img src=" + imgName + "><br>" + getDataValue("condition_text"))
sendEventPublish(name: "condition_icon_url", value: imgName)
updateDataValue("condition_icon_url", imgName)
sendEventPublish(name: "condition_icon_only", value: imgName.split("/")[-1].replaceFirst("\\?raw=true",""))
} else if(sourceImg==true) { // 'Standard' icons selected
sendEventPublish(name: "condition_icon", value: '<img src=https://icons.wxug.com/i/c/a/' + getDataValue("condition_code") + '.gif>')
sendEventPublish(name: "condition_iconWithText", value: '<img src=https://icons.wxug.com/i/c/a/' + getDataValue("condition_code") + '.gif><br>' + getDataValue("condition_text"))
sendEventPublish(name: "condition_icon_url", value: 'https://icons.wxug.com/i/c/a/' + getDataValue("condition_code") +'.gif')
updateDataValue("condition_icon_url", 'https://icons.wxug.com/i/c/a/' + getDataValue("condition_code") +'.gif')
sendEventPublish(name: "condition_icon_only", value: getDataValue("condition_code") +'.gif')
}
// >>>>>>>>>> End Icon Processing <<<<<<<<<<
Summary_forecastTemp = ". "
Summary_vis = ""
}
// >>>>>>>>>> End Process Only If No External Forcast Is Selected <<<<<<<<<<
// <<<<<<<<<< Begin Process Standard Weather-Station Variables (Regardless of Forecast Selection) >>>>>>>>>>
updateDataValue("dewpoint", (isFahrenheit ? wd.everything.weather.dew_point.current.f.toBigDecimal() : wd.everything.weather.dew_point.current.c.toBigDecimal()).toString())
updateDataValue("humidity", wd.everything.weather.humidity.current.toBigDecimal().toString())
updateDataValue("precip_today", (isRainMetric ? wd.everything.weather.rainfall.daily.mm.toBigDecimal() : wd.everything.weather.rainfall.daily.in.toBigDecimal()).toString())
updateDataValue("pressure", (isPressureMetric ? wd.everything.weather.pressure.current.mb.toBigDecimal() : wd.everything.weather.pressure.current.inhg.toBigDecimal()).toString())
updateDataValue("temperature", (isFahrenheit ? wd.everything.weather.temperature.current.f.toBigDecimal() : wd.everything.weather.temperature.current.c.toBigDecimal()).toString())
updateDataValue("wind_bft_icon", 'wb' + wd.everything.weather.wind.avg_speed.bft.toInteger().toString() + '.png')
switch(wd.everything.weather.wind.avg_speed.bft.toInteger()){
case 0: w_string_bft = "Calm"; break;
case 1: w_string_bft = "Light air"; break;
case 2: w_string_bft = "Light breeze"; break;
case 3: w_string_bft = "Gentle breeze"; break;
case 4: w_string_bft = "Moderate breeze"; break;
case 5: w_string_bft = "Fresh breeze"; break;
case 6: w_string_bft = "Strong breeze"; break;
case 7: w_string_bft = "High wind, moderate gale, near gale"; break;
case 8: w_string_bft = "Gale, fresh gale"; break;
case 9: w_string_bft = "Strong/severe gale"; break;
case 10: w_string_bft = "Storm, whole gale"; break;
case 11: w_string_bft = "Violent storm"; break;
case 12: w_string_bft = "Hurricane force"; break;
default: w_string_bft = "Calm"; break;
}
updateDataValue("wind", (isDistanceMetric ? wd.everything.weather.wind.avg_speed.kmh.toBigDecimal() : wd.everything.weather.wind.avg_speed.mph.toBigDecimal()).toString())
updateDataValue("wind_gust", (isDistanceMetric ? wd.everything.weather.wind.gust_speed.kmh.toBigDecimal() : wd.everything.weather.wind.gust_speed.mph.toBigDecimal()).toString())
updateDataValue("wind_degree", wd.everything.weather.wind.direction.degrees.toInteger().toString())
switch(wd.everything.weather.wind.direction.cardinal.toUpperCase()){
case 'N': w_direction = 'North'; break;
case 'NNE': w_direction = 'North-Northeast'; break;
case 'NE': w_direction = 'Northeast'; break;
case 'ENE': w_direction = 'East-Northeast'; break;
case 'E': w_direction = 'East'; break;
case 'ESE': w_direction = 'East-Southeast'; break;
case 'SE': w_direction = 'Southeast'; break;
case 'SSE': w_direction = 'South-Southeast'; break;
case 'S': w_direction = 'South'; break;
case 'SSW': w_direction = 'South-Southwest'; break;
case 'SW': w_direction = 'Southwest'; break;
case 'WSW': w_direction = 'West-Southwest'; break;
case 'W': w_direction = 'West'; break;
case 'WNW': w_direction = 'West-Northwest'; break;
case 'NW': w_direction = 'Northwest'; break;
case 'NNW': w_direction = 'North-Northwest'; break;
default: w_direction = 'Unknown'; break;
}
updateDataValue("wind_direction", w_direction)
updateDataValue("wind_string", w_string_bft + " from the " + getDataValue("wind_direction") + (getDataValue("wind").toBigDecimal() < 1.0 ? '': " at " + getDataValue("wind") + (isDistanceMetric ? " KPH" : " MPH")))
updateDataValue("city", wd.station.name.split(/ /)[0])
updateDataValue("state", wd.station.name.split(/ /)[1])
updateDataValue("country", wd.station.name.split(/ /)[2])
updateDataValue("moonAge", wd.everything.astronomy.moon.moon_age.toBigDecimal().toString())
if(moonPhasePublish){
if (wd.everything.astronomy.moon.moon_age.toBigDecimal() >= 0 && wd.everything.astronomy.moon.moon_age.toBigDecimal() < 4) {mPhase = "New Moon"}
if (wd.everything.astronomy.moon.moon_age.toBigDecimal() >= 4 && wd.everything.astronomy.moon.moon_age.toBigDecimal() < 7) {mPhase = "Waxing Crescent"}
if (wd.everything.astronomy.moon.moon_age.toBigDecimal() >= 7 && wd.everything.astronomy.moon.moon_age.toBigDecimal() < 10) {mPhase = "First Quarter"}
if (wd.everything.astronomy.moon.moon_age.toBigDecimal() >= 10 && wd.everything.astronomy.moon.moon_age.toBigDecimal() < 14) {mPhase = "Waxing Gibbous"}
if (wd.everything.astronomy.moon.moon_age.toBigDecimal() >= 14 && wd.everything.astronomy.moon.moon_age.toBigDecimal() < 18) {mPhase = "Full Moon"}
if (wd.everything.astronomy.moon.moon_age.toBigDecimal() >= 18 && wd.everything.astronomy.moon.moon_age.toBigDecimal() < 22) {mPhase = "Waning Gibbous"}
if (wd.everything.astronomy.moon.moon_age.toBigDecimal() >= 22 && wd.everything.astronomy.moon.moon_age.toBigDecimal() < 26) {mPhase = "Last Quarter"}
if (wd.everything.astronomy.moon.moon_age.toBigDecimal() >= 26) {mPhase = "Waxing Gibbous"}
updateDataValue("moonPhase", mPhase)
}
if(solarradiationPublish){
if(!wd.everything.weather.solar.irradiance.wm2){
updateDataValue("solarradiation", "This station does not send Solar Radiation data.")
} else {
updateDataValue("solarradiation", wd.everything.weather.solar.irradiance.wm2.toInteger().toString())
}
}
// >>>>>>>>>> End Process Standard Weather-Station Variables (Regardless of Forecast Selection) <<<<<<<<<<
// <<<<<<<<<< Begin Process Only If Illumination from WD Is Selected >>>>>>>>>>
if(sourceIllumination == true){
if (!wd.everything.weather.solar.irradiance.wm2){
updateDataValue("illuminance", "This station does not send illuminance data.")
updateDataValue("illuminated", "This station does not send illuminance data.")
} else {
updateDataValue("illuminance", wd.everything.weather.solar.irradiance.wm2.toInteger().toString())
updateDataValue("illuminated", String.format("%,4d", wd.everything.weather.solar.irradiance.wm2.toInteger()).toString())
}
}
// >>>>>>>>>> End Process Only If Illumination from WD Is Selected <<<<<<<<<<
// <<<<<<<<<< Begin Process Only If Ultraviolet Index from WD Is Selected >>>>>>>>>>
if(sourceUV==true){
if(!wd.everything.weather.uv.uvi){
updateDataValue("ultravioletIndex", "This station does not send ultravoilet index data.")
} else {
updateDataValue("ultravioletIndex", wd.everything.weather.uv.uvi.toBigDecimal().toString())
}
}
// >>>>>>>>>> End Process Only If UV from WD Is Selected <<<<<<<<<<
// <<<<<<<<<< Begin Process Only If feelsLike from WD Is Selected >>>>>>>>>>
if(sourcefeelsLike==true){
updateDataValue("feelsLike", (isFahrenheit ? wd.everything.weather.apparent_temperature.current.f.toBigDecimal() : wd.everything.weather.apparent_temperature.current.c.toBigDecimal()).toString())
}
// >>>>>>>>>> End Process Only If feelsLike from WD Is Selected <<<<<<<<<<
if(getDataValue("forecastPoll") == "false"){
if(extSource.toInteger() == 2){ pollDS() }
}
PostPoll()
}
// >>>>>>>>>> End Weather-Display routines <<<<<<<<<<
// <<<<<<<<<< Begin DarkSky Poll Routines >>>>>>>>>>
def pollDS() {
def ParamsDS = [ uri: "https://api.darksky.net/forecast/${apiKey}/" + location.latitude + ',' + location.longitude + "?units=us&exclude=minutely,hourly,flags" ]
LOGINFO("Poll DarkSky: $ParamsDS")
asynchttpGet("pollDSHandler", ParamsDS)
return
}
def pollDSHandler(resp, data) {
log.info "Weather-Display Driver - INFO: Polling DarkSky.net"
if(resp.getStatus() == 200 || resp.getStatus() == 207) {
ds = parseJson(resp.data)
LOGINFO("DarkSky Data: $ds")
doPollDS() // parse the data returned by DarkSky
} else {
log.error "DarkSky weather api did not return data"
}
}
def doPollDS() {
// <<<<<<<<<< Begin Setup Global Variables >>>>>>>>>>
setDateTimeFormats(datetimeFormat)
setMeasurementMetrics(distanceFormat, pressureFormat, rainFormat, tempFormat)
updateDataValue("currDate", new Date().format("yyyy-MM-dd", TimeZone.getDefault()))
updateDataValue("currTime", new Date().format("HH:mm", TimeZone.getDefault()))
if(getDataValue("riseTime") <= getDataValue("currTime") && getDataValue("setTime") >= getDataValue("currTime")) {
updateDataValue("is_day", "1")
} else {
updateDataValue("is_day", "0")
}
// >>>>>>>>>> End Setup Global Variables <<<<<<<<<<
// <<<<<<<<<< Begin Setup Forecast Variables >>>>>>>>>>
fotime = new Date(ds.currently.time * 1000L)
updateDataValue("fotime", fotime.toString())
futime = new Date(ds.currently.time * 1000L)
updateDataValue("futime", futime.toString())
if (!ds.currently.cloudCover) {
cloudCover = 1
} else {
cloudCover = (ds.currently.cloudCover.toBigDecimal() <= 0.01) ? 1 : ds.currently.cloudCover.toBigDecimal() * 100
}
updateDataValue("cloud", cloudCover.toInteger().toString())
if (!ds.alerts){
updateDataValue("alert", "No current weather alerts for this area")
updateDataValue("possAlert", "false")
} else {
updateDataValue("alert", ds.alerts.title.toString().replaceAll("[{}\\[\\]]", "").split(/,/)[0])
updateDataValue("possAlert", "true")
}
updateDataValue("vis", (isDistanceMetric ? ds.currently.visibility.toBigDecimal() * 1.60934 : ds.currently.visibility.toBigDecimal()).toString())
updateDataValue("percentPrecip", (ds.daily.data[0].precipProbability.toBigDecimal() * 100).toInteger().toString())
switch(ds.currently.icon) {
case "clear-day": c_code = "sunny"; break;
case "clear-night": c_code = "nt_clear"; break;
case "rain": c_code = (getDataValue("is_day")=="1" ? "rain" : "nt_rain"); break;
case "wind": c_code = (getDataValue("is_day")=="1" ? "breezy" : "nt_breezy"); break;
case "snow": c_code = (getDataValue("is_day")=="1" ? "snow" : "nt_snow"); break;
case "sleet": c_code = (getDataValue("is_day")=="1" ? "sleet" : "nt_sleet"); break;
case "fog": c_code = (getDataValue("is_day")=="1" ? "fog" : "nt_fog"); break;
case "cloudy": c_code = (getDataValue("is_day")=="1" ? "cloudy" : "nt_cloudy"); break;
case "partly-cloudy-day": c_code = "partlycloudy"; break;
case "partly-cloudy-night": c_code = "nt_partlycloudy"; break;
default: c_code = "unknown"; break;
}
updateDataValue("condition_code", c_code)
updateDataValue("condition_text", ds.currently.summary)
switch(ds.daily.data[0].icon){
case "clear-day": f_code = "sunny"; break;
case "clear-night": f_code = "nt_clear"; break;
case "rain": f_code = (getDataValue("is_day")=="1" ? "rain" : "nt_rain"); break;
case "wind": f_code = (getDataValue("is_day")=="1" ? "breezy" : "nt_breezy"); break;
case "snow": f_code = (getDataValue("is_day")=="1" ? "snow" : "nt_snow"); break;
case "sleet": f_code = (getDataValue("is_day")=="1" ? "sleet" : "nt_sleet"); break;
case "fog": f_code = (getDataValue("is_day")=="1" ? "fog" : "nt_fog"); break;
case "cloudy": f_code = (getDataValue("is_day")=="1" ? "cloudy" : "nt_cloudy"); break;
case "partly-cloudy-day": f_code = "partlycloudy"; break;
case "partly-cloudy-night": f_code = "nt_partlycloudy"; break;
default: f_code = "unknown"; break;
}
updateDataValue("forecast_code", f_code)
updateDataValue("forecast_text", ds.daily.data[0].summary)
updateDataValue("forecastHigh", (isFahrenheit ? (Math.round(ds.daily.data[0].temperatureHigh.toBigDecimal() * 10) / 10) : (Math.round((ds.daily.data[0].temperatureHigh.toBigDecimal() - 32) / 1.8 * 10) / 10)).toString())
updateDataValue("forecastLow", (isFahrenheit ? (Math.round(ds.daily.data[0].temperatureLow.toBigDecimal() * 10) / 10) : (Math.round((ds.daily.data[0].temperatureLow.toBigDecimal() - 32) / 1.8 * 10) / 10)).toString())
if(precipExtendedPublish){
updateDataValue("rainTomorrow", (ds.daily.data[1].precipProbability.toBigDecimal() * 100).toInteger().toString())
updateDataValue("rainDayAfterTomorrow", (ds.daily.data[2].precipProbability.toBigDecimal() * 100).toInteger().toString())
}
if(nearestStormPublish) {
if(!ds.currently.nearestStormBearing){
updateDataValue("nearestStormBearing", "360")
s_cardinal = 'U'
s_direction = 'Unknown'
}else{
updateDataValue("nearestStormBearing", (Math.round(ds.currently.nearestStormBearing * 10) / 10).toString())
if(ds.currently.nearestStormBearing.toInteger() < 11.25) {
s_cardinal = 'N'; s_direction = 'North'
}else if(ds.currently.nearestStormBearing.toBigDecimal() < 33.75) {
s_cardinal = 'NNE'; s_direction = 'North-Northeast'
}else if(ds.currently.nearestStormBearing.toBigDecimal() < 56.25) {
s_cardinal = 'NE'; s_direction = 'Northeast'
}else if(ds.currently.nearestStormBearing.toBigDecimal() < 78.75) {
s_cardinal = 'ENE'; s_direction = 'East-Northeast'
}else if(ds.currently.nearestStormBearing.toBigDecimal() < 101.25) {
s_cardinal = 'E'; s_direction = 'East'
}else if(ds.currently.nearestStormBearing.toBigDecimal() < 123.75) {
s_cardinal = 'ESE'; s_direction = 'East-Southeast'
}else if(ds.currently.nearestStormBearing.toBigDecimal() < 146.25) {
s_cardinal = 'SE'; s_direction = 'Southeast'
}else if(ds.currently.nearestStormBearing.toBigDecimal() < 168.75) {
s_cardinal = 'SSE'; s_direction = 'South-Southeast'
}else if(ds.currently.nearestStormBearing.toBigDecimal() < 191.25) {
s_cardinal = 'S'; s_direction = 'South'
}else if(ds.currently.nearestStormBearing.toBigDecimal() < 213.75) {
s_cardinal = 'SSW'; s_direction = 'South-Southwest'
}else if(ds.currently.nearestStormBearing.toBigDecimal() < 236.25) {
s_cardinal = 'SW'; s_direction = 'Southwest'
}else if(ds.currently.nearestStormBearing.toBigDecimal() < 258.75) {
s_cardinal = 'WSW'; s_direction = 'West-Southwest'
}else if(ds.currently.nearestStormBearing.toBigDecimal() < 281.25) {
s_cardinal = 'W'; s_direction = 'West'
}else if(ds.currently.nearestStormBearing.toBigDecimal() < 303.75) {
s_cardinal = 'WNW'; s_direction = 'West-Northwest'
}else if(ds.currently.nearestStormBearing.toBigDecimal() < 326.26) {
s_cardinal = 'NW'; s_direction = 'Northwest'
}else if(ds.currently.nearestStormBearing.toBigDecimal() < 348.75) {
s_cardinal = 'NNW'; s_direction = 'North-Northwest'
}else if(ds.currently.nearestStormBearing.toBigDecimal() >= 348.75) {
s_cardinal = 'N'; s_direction = 'North'
}
}
updateDataValue("nearestStormCardinal", s_cardinal)
updateDataValue("nearestStormDirection", s_direction)
updateDataValue("nearestStormDistance", (!ds.currently.nearestStormDistance ? "9999.9" : (isDistanceMetric ? (Math.round(ds.currently.nearestStormDistance.toBigDecimal() * 1.609344 * 10) / 10) : (Math.round(ds.currently.nearestStormDistance.toBigDecimal() * 10) / 10)).toString()))
}
updateDataValue("ozone", (Math.round(ds.currently.ozone.toBigDecimal() * 10 ) / 10).toString())
// >>>>>>>>>> End Setup Forecast Variables <<<<<<<<<<
// <<<<<<<<<< Begin Process Only If Illumination from WD Is NOT Selected >>>>>>>>>>
if(sourceIllumination==false) {
def (lux, bwn) = estimateLux(getDataValue("condition_code"), getDataValue("cloud"))
updateDataValue("bwn", bwn)
updateDataValue("illuminance", lux.toString())
updateDataValue("illuminated", String.format("%,4d", lux).toString())
}
// >>>>>>>>>> End Process Only If Illumination from WD Is NOT Selected <<<<<<<<<<
// <<<<<<<<<< Begin Process Only If Ultraviolet Index from WD Is NOT Selected >>>>>>>>>>
if(sourceUV==false){
updateDataValue("ultravioletIndex", value: ds.currently.uvIndex.toBigDecimal().toString())
}
// >>>>>>>>>> End Process Only If Ultraviolet Index from WD Is NOT Selected <<<<<<<<<<
// <<<<<<<<<< Begin Process Only If feelsLike Index from WD Is NOT Selected >>>>>>>>>>
if(sourcefeelsLike==false){
updateDataValue("feelsLike", (isFahrenheit ? (Math.round(ds.currently.apparentTemperature.toBigDecimal() * 10) / 10) : (Math.round((ds.currently.apparentTemperature.toBigDecimal() - 32) / 1.8 * 10) / 10)).toString())
}
// >>>>>>>>>> End Process Only If feelsLike from WD Is NOT Selected <<<<<<<<<<
// <<<<<<<<<< Begin Icon Processing >>>>>>>>>>
if(sourceImg==false){ // 'Alternative' Icons selected
imgName = (getDataValue("iconType")== 'true' ? getImgName(getDataValue("condition_code")) : getImgName(getDataValue("forecast_code")))
sendEventPublish(name: "condition_icon", value: '<img src=' + imgName + '>')
sendEventPublish(name: "condition_iconWithText", value: "<img src=" + imgName + "><br>" + (getDataValue("iconType")== 'true' ? getDataValue("condition_text") : getDataValue("forecast_text")))
sendEventPublish(name: "condition_icon_url", value: imgName)
updateDataValue("condition_icon_url", imgName)
sendEventPublish(name: "condition_icon_only", value: imgName.split("/")[-1].replaceFirst("\\?raw=true",""))
} else if(sourceImg==true) { // 'Standard Icons selected
sendEventPublish(name: "condition_icon", value: '<img src=https://icons.wxug.com/i/c/a/' + (getDataValue("iconType")== 'true' ? getDataValue("condition_code") : getDataValue("forecast_code")) + '.gif>')
sendEventPublish(name: "condition_iconWithText", value: '<img src=https://icons.wxug.com/i/c/a/' + (getDataValue("iconType")== 'true' ? getDataValue("condition_code") : getDataValue("forecast_code")) + '.gif><br>' + (getDataValue("iconType")== 'true' ? getDataValue("condition_text") : getDataValue("forecast_text")))
sendEventPublish(name: "condition_icon_url", value: 'https://icons.wxug.com/i/c/a/' + (getDataValue("iconType")== 'true' ? getDataValue("condition_code") : getDataValue("forecast_code")) +'.gif')
updateDataValue("condition_icon_url", 'https://icons.wxug.com/i/c/a/' + (getDataValue("iconType")== 'true' ? getDataValue("condition_code") : getDataValue("forecast_code")) +'.gif')
sendEventPublish(name: "condition_icon_only", value: (getDataValue("iconType")== 'true' ? getDataValue("condition_code") : getDataValue("forecast_code")) +'.gif')
}
// >>>>>>>>>> End Icon Processing <<<<<<<<<<
if(getDataValue("forecastPoll") == "false"){
updateDataValue("forecastPoll", "true")
}
PostPoll()
}
// >>>>>>>>>> End DarkSky Poll Routines <<<<<<<<<<
// <<<<<<<<<< Begin Post-Poll Routines >>>>>>>>>>
def PostPoll() {
def sunRiseSet = parseJson(getDataValue("sunRiseSet")).results
setDateTimeFormats(datetimeFormat)
setMeasurementMetrics(distanceFormat, pressureFormat, rainFormat, tempFormat)
/* SunriseSunset Data Eements */
if(localSunrisePublish){ // don't bother setting these values if it's not enabled
sendEvent(name: "tw_begin", value: new Date().parse("yyyy-MM-dd'T'HH:mm:ssXXX", sunRiseSet.civil_twilight_begin).format(timeFormat, TimeZone.getDefault()))
sendEvent(name: "sunriseTime", value: new Date().parse("yyyy-MM-dd'T'HH:mm:ssXXX", sunRiseSet.sunrise).format(timeFormat, TimeZone.getDefault()))
sendEvent(name: "noonTime", value: new Date().parse("yyyy-MM-dd'T'HH:mm:ssXXX", sunRiseSet.solar_noon).format(timeFormat, TimeZone.getDefault()))
sendEvent(name: "sunsetTime", value: new Date().parse("yyyy-MM-dd'T'HH:mm:ssXXX", sunRiseSet.sunset).format(timeFormat, TimeZone.getDefault()))
sendEvent(name: "tw_end", value: new Date().parse("yyyy-MM-dd'T'HH:mm:ssXXX", sunRiseSet.civil_twilight_end).format(timeFormat, TimeZone.getDefault()))
}
sendEvent(name: "localSunset", value: new Date().parse("yyyy-MM-dd'T'HH:mm:ssXXX", sunRiseSet.sunset).format(timeFormat, TimeZone.getDefault())) // only needed for certain dashboards
sendEvent(name: "localSunrise", value: new Date().parse("yyyy-MM-dd'T'HH:mm:ssXXX", sunRiseSet.sunrise).format(timeFormat, TimeZone.getDefault())) // only needed for certain dashboards
/* Weather-Display & 'Required for Dashboards' Data Elements */
sendEvent(name: "humidity", value: getDataValue("humidity").toBigDecimal(), unit: '%')
sendEvent(name: "illuminance", value: getDataValue("illuminance").toInteger(), unit: 'lx')
sendEvent(name: "pressure", value: String.format("%,4.1f", getDataValue("pressure").toBigDecimal()), unit: (isPressureMetric ? 'mbar' : 'inHg'))
sendEvent(name: "temperature", value: String.format("%3.1f", getDataValue("temperature").toBigDecimal()), unit: (isFahrenheit ? '°F' : '°C'))
sendEvent(name: "ultravioletIndex", value: getDataValue("ultravioletIndex").toBigDecimal(), unit: 'uvi')
sendEvent(name: "city", value: getDataValue("city"))
sendEvent(name: "feelsLike", value: getDataValue("feelsLike").toBigDecimal(), unit: (isFahrenheit ? '°F' : '°C'))
sendEvent(name: "forecastIcon", value: getDataValue("condition_code"))
sendEvent(name: "percentPrecip", value: getDataValue("percentPrecip"))
sendEvent(name: "weather", value: getDataValue("condition_text"))
sendEvent(name: "weatherIcon", value: getDataValue("condition_code"))
sendEvent(name: "weatherIcons", value: getowmImgName(getDataValue("condition_code")))
sendEvent(name: "wind", value: getDataValue("wind").toBigDecimal(), unit: (isDistanceMetric ? 'KPH' : 'MPH'))
sendEvent(name: "windSpeed", value: getDataValue("wind").toBigDecimal(), unit: (isDistanceMetric ? 'KPH' : 'MPH'))
sendEvent(name: "windDirection", value: getDataValue("wind_degree").toInteger(), unit: "DEGREE")
/* Selected optional Data Elements */
sendEventPublish(name: "alert", value: getDataValue("alert"))
sendEventPublish(name: "betwixt", value: getDataValue("bwn"))
sendEventPublish(name: "cloud", value: getDataValue("cloud").toInteger(), unit: '%')
sendEventPublish(name: "condition_code", value: getDataValue("condition_code"))
sendEventPublish(name: "condition_text", value: getDataValue("condition_text"))
sendEventPublish(name: "country", value: getDataValue("country"))
sendEventPublish(name: "dewpoint", value: getDataValue("dewpoint").toBigDecimal(), unit: (isFahrenheit ? '°F' : '°C'))
sendEventPublish(name: "forecast_code", value: getDataValue("forecast_code"))
sendEventPublish(name: "forecast_text", value: getDataValue("forecast_text"))
if(fcstHighLowPublish && extSource.toInteger() == 2){ // don't bother setting these values if it's not enabled
sendEvent(name: "forecastHigh", value: String.format("%3.1f", getDataValue("forecastHigh").toBigDecimal()), unit: (isFahrenheit ? '°F' : '°C'))
sendEvent(name: "forecastLow", value: String.format("%3.1f", getDataValue("forecastLow").toBigDecimal()), unit: (isFahrenheit ? '°F' : '°C'))
}
sendEventPublish(name: "illuminated", value: getDataValue("illuminated") + ' lx')
sendEventPublish(name: "is_day", value: getDataValue("is_day"))
sendEventPublish(name: "moonPhase", value: getDataValue("moonPhase"))
if(obspollPublish){ // don't bother setting these values if it's not enabled
sendEvent(name: "last_observation_Station", value: new Date().parse("EEE MMM dd HH:mm:ss z yyyy", getDataValue("sotime")).format(dateFormat, TimeZone.getDefault()) + ", " + new Date().parse("EEE MMM dd HH:mm:ss z yyyy", getDataValue("sotime")).format(timeFormat, TimeZone.getDefault()))
sendEvent(name: "last_poll_Station", value: new Date().parse("EEE MMM dd HH:mm:ss z yyyy", getDataValue("sutime")).format(dateFormat, TimeZone.getDefault()) + ", " + new Date().parse("EEE MMM dd HH:mm:ss z yyyy", getDataValue("sutime")).format(timeFormat, TimeZone.getDefault()))
sendEvent(name: "last_poll_Forecast", value: new Date().parse("EEE MMM dd HH:mm:ss z yyyy", getDataValue("futime")).format(dateFormat, TimeZone.getDefault()) + ", " + new Date().parse("EEE MMM dd HH:mm:ss z yyyy", getDataValue("futime")).format(timeFormat, TimeZone.getDefault()))
sendEvent(name: "last_observation_Forecast", value: new Date().parse("EEE MMM dd HH:mm:ss z yyyy", getDataValue("fotime")).format(dateFormat, TimeZone.getDefault()) + ", " + new Date().parse("EEE MMM dd HH:mm:ss z yyyy", getDataValue("fotime")).format(timeFormat, TimeZone.getDefault()))
}
sendEventPublish(name: "ozone", value: Math.round(getDataValue("ozone").toBigDecimal() * 10) / 10)
sendEventPublish(name: "precip_today", value: getDataValue("precip_today").toBigDecimal(), unit: (isRainMetric ? 'mm' : 'inches'))
if(precipExtendedPublish && extSource.toInteger() == 2){ // don't bother setting these values if it's not enabled
sendEvent(name: "rainDayAfterTomorrow", value: getDataValue("rainDayAfterTomorrow").toBigDecimal(), unit: '%')
sendEvent(name: "rainTomorrow", value: getDataValue("rainTomorrow").toBigDecimal(), unit: '%')
}
sendEventPublish(name: "solarradiation", value: getDataValue("solarradiation"))
sendEventPublish(name: "state", value: getDataValue("state"))
if(extSource.toInteger()==1){
sendEventPublish(name: "vis", value: getDataValue("vis"))
}else{
sendEventPublish(name: "vis", value: Math.round(getDataValue("vis").toBigDecimal() * 10) / 10, unit: (isDistanceMetric ? "kilometers" : "miles"))
}
sendEventPublish(name: "wind_degree", value: getDataValue("wind_degree").toInteger(), unit: "DEGREE")
sendEventPublish(name: "wind_direction", value: getDataValue("wind_direction"))
sendEventPublish(name: "wind_gust", value: getDataValue("wind_gust").toBigDecimal(), unit: (isDistanceMetric ? 'KPH' : 'MPH'))
sendEventPublish(name: "wind_string", value: getDataValue("wind_string"))
if(nearestStormPublish) {
sendEvent(name: "nearestStormBearing", value: getDataValue("nearestStormBearing"), unit: "DEGREE")
sendEvent(name: "nearestStormCardinal", value: getDataValue("nearestStormCardinal"))
sendEvent(name: "nearestStormDirection", value: getDataValue("nearestStormDirection"))
sendEvent(name: "nearestStormDistance", value: String.format("%,5.1f", getDataValue("nearestStormDistance").toBigDecimal()), unit: (isDistanceMetric ? "kilometers" : "miles"))
}
// <<<<<<<<<< Begin Built Weather Summary text >>>>>>>>>>
Summary_last_poll_time = (sutime > futime ? new Date().parse("EEE MMM dd HH:mm:ss z yyyy", "${sutime}").format(timeFormat, TimeZone.getDefault()) : new Date().parse("EEE MMM dd HH:mm:ss z yyyy", "${futime}").format(timeFormat, TimeZone.getDefault()))
Summary_last_poll_date = (sutime > futime ? new Date().parse("EEE MMM dd HH:mm:ss z yyyy", "${sutime}").format(dateFormat, TimeZone.getDefault()) : new Date().parse("EEE MMM dd HH:mm:ss z yyyy", "${futime}").format(dateFormat, TimeZone.getDefault()))
if(weatherSummaryPublish){ // don't bother setting these values if it's not enabled
if(extSource.toInteger() == 2){
Summary_forecastTemp = " with a high of " + String.format("%3.1f", getDataValue("forecastHigh").toBigDecimal()) + (isFahrenheit ? '°F' : '°C') + " and a low of " + String.format("%3.1f", getDataValue("forecastLow").toBigDecimal()) + (isFahrenheit ? '°F. ' : '°C. ')
Summary_precip = "There is a " + getDataValue("percentPrecip") + "% chance of precipitation. "
mtprecip = getDataValue("percentPrecip") + '%'
Summary_vis = "Visibility is around " + String.format("%3.1f", getDataValue("vis").toBigDecimal()) + (isDistanceMetric ? " kilometers." : " miles. ")
}else{
Summary_forecastTemp = ""
Summary_precip = ""
mtprecip = 'N/A'
Summary_vis = ""
}
SummaryMessage(summaryType, Summary_last_poll_date, Summary_last_poll_time, Summary_forecastTemp, Summary_precip, Summary_vis)
}
// >>>>>>>>>> End Built Weather Summary text <<<<<<<<<<
// <<<<<<<<<< Begin Built mytext >>>>>>>>>>
if(myTilePublish){ // don't bother setting these values if it's not enabled
iconClose = (((getDataValue("iconLocation").toLowerCase().contains('://github.com/')) && (getDataValue("iconLocation").toLowerCase().contains('/blob/master/'))) ? "?raw=true" : "")
alertStyleOpen = ((!getDataValue("possAlert") || getDataValue("possAlert")=="" || getDataValue("possAlert")=="false") ? '' : '<span style=\"font-size:0.75em;line-height=75%;\">')
alertStyleClose = ((!getDataValue("possAlert") || getDataValue("possAlert")=="" || getDataValue("possAlert")=="false") ? '' : ' | <span style=\"font-style:italic;\">' + getDataValue("alert") + "</span></span>" )
if(getDataValue("wind_gust").toBigDecimal() < 1.0 ) {
wgust = 0.0g
} else {
wgust = getDataValue("wind_gust").toBigDecimal()
}
mytext = '<div style=\"text-align:center;display:inline;margin-top:0em;margin-bottom:0em;\">' + getDataValue("city") + ", " + getDataValue("state") + '</div><br>'
mytext+= alertStyleOpen + getDataValue("condition_text") + alertStyleClose + '<br>'
mytext+= getDataValue("temperature") + (isFahrenheit ? '°F ' : '°C ') + '<img style=\"height:2.0em\" src=' + getDataValue("condition_icon_url") + '>' + '<span style= \"font-size:.75em;\"> Feels like ' + getDataValue("feelsLike") + (isFahrenheit ? '°F' : '°C') + '</span><br>'
mytext+= '<div style=\"font-size:0.75em;line-height=50%;\">' + '<img src=' + getDataValue("iconLocation") + getDataValue("wind_bft_icon") + iconClose + '>' + getDataValue("wind_direction") + " "
mytext+= getDataValue("wind").toBigDecimal() < 1.0 ? 'calm' : "@ " + getDataValue("wind") + (isDistanceMetric ? ' KPH' : ' MPH')
mytext+= ', gusts ' + ((wgust < 1.0) ? 'calm' : "@ " + wgust.toString() + (isDistanceMetric ? ' KPH' : ' MPH')) + '<br>'
mytext+= '<img src=' + getDataValue("iconLocation") + 'wb.png' + iconClose + '>' + String.format("%,4.1f", getDataValue("pressure").toBigDecimal()) + (isPressureMetric ? ' mbar' : ' inHg') + ' <img src=' + getDataValue("iconLocation") + 'wh.png' + iconClose + '>'
mytext+= getDataValue("humidity") + '% ' + '<img src=' + getDataValue("iconLocation") + 'wu.png' + iconClose + '>' + getDataValue("percentPrecip") + '%'
mytext+= (getDataValue("precip_today").toBigDecimal() > 0.0 ? ' <img src=' + getDataValue("iconLocation") + 'wr.png' + iconClose + '>' + getDataValue("precip_today") + (isRainMetric ? ' mm' : ' inches') : '') + '<br>'
mytext+= '<img src=' + getDataValue("iconLocation") + 'wsr.png' + iconClose + '>' + getDataValue("localSunrise") + ' <img src=' + getDataValue("iconLocation") + 'wss.png' + iconClose + '>' + getDataValue("localSunset") + ' Updated: ' + Summary_last_poll_time + '</div>'
LOGINFO("mytext: ${mytext}")
sendEvent(name: "myTile", value: mytext)
}
// >>>>>>>>>> End Built mytext <<<<<<<<<<
}
// >>>>>>>>>> End Post-Poll Routines <<<<<<<<<<
def updated() {
initialize() // includes an unsubscribe()
updateDataValue("forecastPoll", "false")
if (settingEnable) runIn(2100,settingsOff) // "roll up" (hide) the condition selectors after 35 min
runIn(5, pollWD)
}
def initialize() {
state.clear()
unschedule()
state.driverName = "Weather-Display With DarkSky.net Forecast Driver"
state.driverVersion = "4.1.6" // ************************* Update as required *************************************
state.driverNameSpace = "Matthew"
logSet = (settings?.logSet ?: false)
extSource = (settings?.extSource ?: 2).toInteger()
pollIntervalStation = (settings?.pollIntervalStation ?: "3 Hours")
pollLocationStation = (settings?.pollLocationStation ?: "http://")
pollIntervalForecast = (settings?.pollIntervalForecast ?: "3 Hours")
datetimeFormat = (settings?.datetimeFormat ?: 1).toInteger()
distanceFormat = (settings?.distanceFormat ?: "Miles (mph)")
pressureFormat = (settings?.pressureFormat ?: "Inches")
rainFormat = (settings?.rainFormat ?: "Inches")
tempFormat = (settings?.tempFormat ?: "Fahrenheit (°F)")
iconType = (settings?.iconType ?: false)
updateDataValue("iconType", iconType ? 'true' : 'false')
sourcefeelsLike = (settings?.sourcefeelsLike ?: false)
sourceIllumination = (settings?.sourceIllumination ?: false)
sourceImg = (settings?.sourceImg ?: false)
sourceUV = (settings?.sourceUV ?: false)
summaryType = (settings?.summaryType ?: false)
iconLocation = (settings?.iconLocation ?: "https://raw.githubusercontent.com/Scottma61/WeatherIcons/master/")
updateDataValue("iconLocation", iconLocation)
setDateTimeFormats(datetimeFormat)
setMeasurementMetrics(distanceFormat, pressureFormat, rainFormat, tempFormat)
pollSunRiseSet()
schedule("11 20 0/8 ? * * *", pollSunRiseSet)
if(pollIntervalStation == "Manual Poll Only"){
LOGINFO("MANUAL STATION POLLING ONLY")
} else {
pollIntervalStation = (settings?.pollIntervalStation ?: "3 Hours").replace(" ", "")
if(pollIntervalStation != pollIntervalForecast){
"runEvery${pollIntervalStation}"(pollWD)
LOGINFO("pollIntervalStation: $pollIntervalStation")
}
}
if(pollIntervalForecast == "Manual Poll Only"){
LOGINFO("MANUAL FORECAST POLLING ONLY")
} else {
pollIntervalForecast = (settings?.pollIntervalForecast ?: "3 Hours").replace(" ", "")
if (extSource.toInteger() == 1) {
"runEvery${pollIntervalForecast}"(pollWD)
} else if (extSource.toInteger() == 2) {
"runEvery${pollIntervalForecast}"(pollDS)
}
}
return
}
def pollData() {
pollWD()
if (extSource.toInteger() == 2) { pollDS() }
return
}
// ************************************************************************************************
public setDateTimeFormats(formatselector){
switch(formatselector) {
case 1: DTFormat = "M/d/yyyy h:mm a"; dateFormat = "M/d/yyyy"; timeFormat = "h:mm a"; break;
case 2: DTFormat = "M/d/yyyy HH:mm"; dateFormat = "M/d/yyyy"; timeFormat = "HH:mm"; break;
case 3: DTFormat = "MM/dd/yyyy h:mm a"; dateFormat = "MM/dd/yyyy"; timeFormat = "h:mm a"; break;
case 4: DTFormat = "MM/dd/yyyy HH:mm"; dateFormat = "MM/dd/yyyy"; timeFormat = "HH:mm"; break;
case 5: DTFormat = "d/M/yyyy h:mm a"; dateFormat = "d/M/yyyy"; timeFormat = "h:mm a"; break;
case 6: DTFormat = "d/M/yyyy HH:mm"; dateFormat = "d/M/yyyy"; timeFormat = "HH:mm"; break;
case 7: DTFormat = "dd/MM/yyyy h:mm a"; dateFormat = "dd/MM/yyyy"; timeFormat = "h:mm a"; break;
case 8: DTFormat = "dd/MM/yyyy HH:mm"; dateFormat = "dd/MM/yyyy"; timeFormat = "HH:mm"; break;
case 9: DTFormat = "yyyy/MM/dd HH:mm"; dateFormat = "yyyy/MM/dd"; timeFormat = "HH:mm"; break;
default: DTFormat = "M/d/yyyy h:mm a"; dateFormat = "M/d/yyyy"; timeFormat = "h:mm a"; break;
}
return
}
public setMeasurementMetrics(distFormat, pressFormat, precipFormat, temptFormat){
isDistanceMetric = (distFormat == "Kilometers (kph)") ? true : false
isPressureMetric = (pressFormat == "Millibar") ? true : false
isRainMetric = (precipFormat == "Millimetres") ? true : false
isFahrenheit = (temptFormat == "Fahrenheit (°F)") ? true : false
return
}
def estimateLux(condition_code, cloud) {
def lux = 0l
def aFCC = true
def l
def bwn
def sunRiseSet = parseJson(getDataValue("sunRiseSet")).results
def tZ = TimeZone.getDefault() //TimeZone.getTimeZone(tz_id)
def lT = new Date().format("yyyy-MM-dd'T'HH:mm:ssXXX", tZ)
def localeMillis = getEpoch(lT)
def twilight_beginMillis = getEpoch(sunRiseSet.civil_twilight_begin)
def sunriseTimeMillis = getEpoch(sunRiseSet.sunrise)
def noonTimeMillis = getEpoch(sunRiseSet.solar_noon)
def sunsetTimeMillis = getEpoch(sunRiseSet.sunset)
def twilight_endMillis = getEpoch(sunRiseSet.civil_twilight_end)
def twiStartNextMillis = twilight_beginMillis + 86400000 // = 24*60*60*1000 --> one day in milliseconds
def sunriseNextMillis = sunriseTimeMillis + 86400000
def noonTimeNextMillis = noonTimeMillis + 86400000
def sunsetNextMillis = sunsetTimeMillis + 86400000
def twiEndNextMillis = twilight_endMillis + 86400000
switch(localeMillis) {
case { it < twilight_beginMillis}:
bwn = "Fully Night Time"
lux = 5l
break
case { it < sunriseTimeMillis}:
bwn = "between twilight and sunrise"
l = (((localeMillis - twilight_beginMillis) * 50f) / (sunriseTimeMillis - twilight_beginMillis))
lux = (l < 10f ? 10l : l.trunc(0) as long)
break
case { it < noonTimeMillis}:
bwn = "between sunrise and noon"
l = (((localeMillis - sunriseTimeMillis) * 10000f) / (noonTimeMillis - sunriseTimeMillis))
lux = (l < 50f ? 50l : l.trunc(0) as long)
break
case { it < sunsetTimeMillis}:
bwn = "between noon and sunset"
l = (((sunsetTimeMillis - localeMillis) * 10000f) / (sunsetTimeMillis - noonTimeMillis))
lux = (l < 50f ? 50l : l.trunc(0) as long)
break
case { it < twilight_endMillis}:
bwn = "between sunset and twilight"
l = (((twilight_endMillis - localeMillis) * 50f) / (twilight_endMillis - sunsetTimeMillis))
lux = (l < 10f ? 10l : l.trunc(0) as long)
break
case { it < twiStartNextMillis}:
bwn = "Fully Night Time"
lux = 5l
break
case { it < sunriseNextMillis}:
bwn = "between twilight and sunrise"
l = (((localeMillis - twiStartNextMillis) * 50f) / (sunriseNextMillis - twiStartNextMillis))
lux = (l < 10f ? 10l : l.trunc(0) as long)
break
case { it < noonTimeNextMillis}:
bwn = "between sunrise and noon"
l = (((localeMillis - sunriseNextMillis) * 10000f) / (noonTimeNextMillis - sunriseNextMillis))
lux = (l < 50f ? 50l : l.trunc(0) as long)
break
case { it < sunsetNextMillis}:
bwn = "between noon and sunset"
l = (((sunsetNextMillis - localeMillis) * 10000f) / (sunsetNextMillis - noonTimeNextMillis))
lux = (l < 50f ? 50l : l.trunc(0) as long)
break
case { it < twiEndNextMillis}:
bwn = "between sunset and twilight"
l = (((twiEndNextMillis - localeMillis) * 50f) / (twiEndNextMillis - sunsetNextMillis))
lux = (l < 10f ? 10l : l.trunc(0) as long)
break
default:
bwn = "Fully Night Time"
lux = 5l
aFCC = false
break
}
def cC = condition_code
def cCF = (!cloud || cloud=="") ? 0.998d : ((100 - (cloud.toInteger() / 3d)) / 100)
if(aFCC){
if(extSource.toInteger() == 1 && cloud !="" && cloud != null){
cCF = ((100 - (cloud.toInteger() / 3d)) / 100)
cCT = 'using cloud cover'
} else if(extSource.toInteger() == 2 && cloud !="" && cloud != null){
LUitem = LUTable.find{ it.wucode == condition_code && it.day == 1 }
if (LUitem && (condition_code != "unknown")) {
cCF = (LUitem ? LUitem.luxpercent : 0)
cCT = (LUitem ? LUitem.wuphrase : 'unknown') + ' using cloud cover.'
} else {
cCF = 1.0
cCT = 'cloud not available now.'
}
} else {
cCF = 1.0
cCT = 'cloud not available now.'
}
}
lux = (lux * cCF) as long
LOGDEBUG("condition: $cC | condition factor: $cCF | condition text: $cCT| lux: $lux")
return [lux, bwn]
}
def getEpoch (aTime) {
def tZ = TimeZone.getDefault() //TimeZone.getTimeZone(tz_id)
def localeTime = new Date().parse("yyyy-MM-dd'T'HH:mm:ssXXX", aTime, tZ)
long localeMillis = localeTime.getTime()
return (localeMillis)
}
public SummaryMessage(SType, Slast_poll_date, Slast_poll_time, SforecastTemp, Sprecip, Svis){
if(getDataValue("wind_gust") == "" || getDataValue("wind_gust").toBigDecimal() < 1.0 || getDataValue("wind_gust")==null) {
wgust = 0.00g
} else {
wgust = getDataValue("wind_gust").toBigDecimal()
}
if(SType == true){
wSum = "Weather summary for " + getDataValue("city") + ", " + getDataValue("state") + " updated at ${Slast_poll_time} on ${Slast_poll_date}. "
wSum+= getDataValue("condition_text")
wSum+= (!SforecastTemp || SforecastTemp=="") ? ". " : "${SforecastTemp}"
wSum+= "Humidity is " + getDataValue("humidity") + "% and the temperature is " + String.format("%3.1f", getDataValue("temperature").toBigDecimal()) + (isFahrenheit ? '°F. ' : '°C. ')
wSum+= "The temperature feels like it is " + String.format("%3.1f", getDataValue("feelsLike").toBigDecimal()) + (isFahrenheit ? '°F. ' : '°C. ')
wSum+= "Wind: " + getDataValue("wind_string") + ", gusts: " + ((wgust < 1.00) ? "calm. " : "up to " + wgust.toString() + (isDistanceMetric ? ' KPH. ' : ' MPH. '))
wSum+= Sprecip
wSum+= Svis
wSum+= (!getDataValue("alert") || getDataValue("alert")==null) ? "" : getDataValue("alert") + '.'
sendEvent(name: "weatherSummary", value: wSum)
} else {
wSum = getDataValue("condition_text") + " "
wSum+= ((!SforecastTemp || SforecastTemp=="") ? ". " : "${SforecastTemp}")
wSum+= " Humidity: " + getDataValue("humidity") + "%. Temperature: " + String.format("%3.1f", getDataValue("temperature").toBigDecimal()) + (isFahrenheit ? '°F. ' : '°C. ')
wSum+= getDataValue("wind_string") + ", gusts: " + ((wgust == 0.00) ? "calm. " : "up to " + wgust + (isDistanceMetric ? ' KPH. ' : ' MPH. '))
sendEvent(name: "weatherSummary", value: wSum)
}
return
}
public getImgName(wCode){
LOGINFO("getImgName Input: wCode: " + wCode + " state.is_day: " + getDataValue("is_day") + " iconLocation: " + getDataValue("iconLocation"))
LUitem = LUTable.find{ it.wucode == wCode } //&& it.day.toString() == getDataValue("is_day") }
LOGINFO("getImgName Result: image url: " + getDataValue("iconLocation") + (LUitem ? LUitem.img : 'na.png') + "?raw=true")
return (getDataValue("iconLocation") + (LUitem ? LUitem.img : 'na.png') + (((getDataValue("iconLocation").toLowerCase().contains('://github.com/')) && (getDataValue("iconLocation").toLowerCase().contains('/blob/master/'))) ? "?raw=true" : ""))
}
public getowmImgName(wCode){
LOGINFO("getImgName Input: wCode: " + wCode + " state.is_day: " + getDataValue("is_day") + " iconLocation: " + getDataValue("iconLocation"))
LUitem = LUTable.find{ it.wucode == wCode } // && it.day.toString() == getDataValue("is_day") }
LOGINFO("getImgName Result: image url: " + getDataValue("iconLocation") + (LUitem ? LUitem.img : 'na.png') + "?raw=true")
return (LUitem ? LUitem.owm : '')
}
def logCheck(){
if(logSet == true){
log.info "Weather-Display Driver - INFO: All Logging Enabled"
} else {
log.info "Weather-Display Driver - INFO: Further Logging Disabled"
}
return
}
def LOGDEBUG(txt){
try {
if(logSet == true){ log.debug("Weather-Display Driver - DEBUG: ${txt}") }
} catch(ex) {