something seems off
the android app shows clear sky yet hubitat shows light rain at condition text
debugging and looking at json response it shows current condition clear sky and light rain for tomorrow forecast
it looks like the driver is pulling the wrong data for my city
the built-in hubitat driver seems to be showing the weather correctly but that's just too basic.
not my app or anything but a devout user of it - check your settings in both your hub long lat and the device itself - there is an 'override hub location' - mine is switched off - my hub long lat are doing the job. you may be getting a discrepancy there.
thanks but it doesn't do the trick, I tried with override and made sure my hub's coordinates are right and still showing light rain when is clear sky while the built-in driver for weather shows the weather correctly but is too basic for my needs...
I have a bit unusual problem. I live so far north that right now we don´t have any sunrise or sunset and it is the same in winter (only then no sun).
So the driver runs into a problem when it should fetch the sunrise (and I assume sunset) at line 327.
Is there a fix for this?
I guess you could test it by overriding the location in the driver and put 70.6626, 23.6829 which is my position. But of course I will test any changes you suggest
from the original code, change lines 325 & 326 and again for lines 1604 & 1605 (be careful as lines will change when you make the first change. The lines you are replacing are the same in both places. You will change this:
Date tsunrise= todaysSunrise
Date tsunset= todaysSunset
to this:
Date tsunrise, tsunset
tsunrise = (!todaysSunrise || todaysSunrise == null) ? Date.parse("yyyy-MM-dd hh:mm:ss", new Date().format('yyyy-MM-dd', TimeZone.getDefault()) + " 00:00:00") : todaysSunrisex ;log.debug "made it to line 329. tsunrise: " + tsunrise
tsunset = ((!todaysSunset || todaysSunset == null) && (new Date() >= Date.parse("yyyy-MM-dd", new Date().format('yyyy', TimeZone.getDefault()) + '-03-21')) && (new Date() < Date.parse("yyyy-MM-dd", new Date().format('yyyy', TimeZone.getDefault()) + '-09-21'))) ? Date.parse("yyyy-MM-dd hh:mm:ss", new Date().format('yyyy-MM-dd', TimeZone.getDefault()) + " 23:59:59") : Date.parse("yyyy-MM-dd hh:mm:ss", new Date().format('yyyy-MM-dd', TimeZone.getDefault()) + " 00:00:01")
if(!(!todaysSunset || todaysSunset == null)) {
tsunset = todaysSunset
}
The intent here to use default values when sunrise or sunset = null. If that happens and it is between March 21 and September 21st then it will set Sunrise at 00:00:00 and Sunset at 23:59:59. If it is between September 21st and March 21st it will set Sunrise at 00:00:00 and Sunset at 00:00:01. I know that will give you one second of night that you don't have in the summer and one second of day that you don't have in winter ..... but that is the best I could think to do. It should eliminate the errors.
Please try the code and let me know if it works and you have no errors. If so, I'll push it into production. Thanks.
Sorry about that. It didn't stop. That was just a debug log to help me figure out what was going on in the code, that I failed to remove. No error there.
Other than that log entry ... is everything else as you would expect? If it is I'll push that out to production.
(I did add one additional piece of code to accommodate the masses of people using this driver that have similar (but opposite) situation in the southern pole regions.)
I have been working on a HubiThings driver using the SmartThings API for its data set. After watching this thread, this was something that is working for Utqiagvik, AK with Weather Channel data. Just posting if it might help you (or if you see fault).
Boolean is_day = false
if(weatherMap?.sunriseTimeLocal && weatherMap?.sunsetTimeLocal) {
String timeZoneId = device.currentValue("timeZoneId").toString()
BigDecimal latitude = device.currentValue("latitude").toBigDecimal()
TimeZone tz = TimeZone.getTimeZone(timeZoneId) // figure out the local timezone of the Hub. Might be different than Hubitat hub.
Date sunriseTime = Date.parse("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", weatherMap.sunriseTimeLocal.value, TimeZone.getTimeZone("UTC"))
Date sunsetTime = Date.parse("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", weatherMap.sunsetTimeLocal.value, TimeZone.getTimeZone("UTC"))
if(sunriseTime == sunsetTime) {
Date midnightSun = Date.parse("yyyy-MM-dd", (latitude>0 ? (new Date().format('yyyy', tz) + '-03-21') : (new Date().format('yyyy', tz) + '-09-21')), tz)
Date polarNight = Date.parse("yyyy-MM-dd", (latitude<0 ? (new Date().format('yyyy', tz) + '-03-21') : (new Date().format('yyyy', tz) + '-09-21')), tz)
is_day = ((new Date()).after(midnightSun) && (new Date()).before(polarNight))
logDebug "midnightSun: $midnightSun, polarNight: $polarNight, is_day: $is_day"
}
else {
is_day = ((new Date()).after(sunriseTime) && (new Date()).before(sunsetTime))
}
sendEvent(name: "localSunrise", value: sunriseTime.format('h:mm a', tz).toString())
sendEvent(name: "localSunset", value: sunsetTime.format('h:mm a', tz).toString())
}
Thanks! The code I have written (but not pushed to production, yet) does similar things. This driver uses the hub's reported sunrise and sunset time, which may be null in these instances (as opposed to "sunriseTime == sunsetTime"). The code I am proposing accommodates those null values.