[PROJECT] Weather Service Monitor 4 Hubitat Driver

Just installed this device but I need some help. when using the United States National Weather Service as the one to query, I don't think I am getting the forecast for my location.
Is there a way to specify which city I want the forecast from? Can I show forecast from multiple locations?

When it is using the US NWS it will automatically use the latitude and longitude provided by the Hubitat to query NWS for the CWA, GridX, & GridY values they require (they will be saved in the device as State Variables). Then the next time it polls it will send those values instead.

As a result, it cannot show multiple locations even if multiple virtual devices were used because they would all show for the same location that the Hubitat is set for.

If this is really something needed... I could probably build an "override" mechanism into the Preferences so someone can enter different coordinates.

Oh okay. I don't seem to be able to find the attribute for current temperature though. It is only returning today's high in Today_Temperature and Temperature.

This driver is meant to provide the forecast/days data, not current values. So the Today_Temperature and temperature are the same, and what the API returns as "today's temperature".

When I wrote it there were a number of other weather-service drivers focused on the current information but a lack of forecast data (and I also did some additional services beyond the US). I did not want to take away from any of the existing drivers that did current weather. Plus, Hubitat comes with a built-in driver for OpenWeatherMap.

I also have drivers for a couple types of weather stations, and those DO provide current data.

I am fairly new to Hubitat so I wasn't aware of the other weather drivers or even the built in driver for openweathermap. I will look into those. Thank you for pointing me in their direction.

Happy to help! Another spot to look for drivers would be the Custom Device Drivers Wiki.

I found your driver because I was looking for current cloud cover in the UK to decide what my blinds should be doing. Openweathermap gets it completely wrong, but the UK Met office data is correct.

I noticed two things:

  1. Sadly your driver isn't the one I'm looking for because I need the hourly data, not daily.
  2. The driver is hard coded to return the data for Uxbridge, not for the location set for the hub.

The Met Office sign up is much simpler now. You just enter your details, get the client ID and secret and yoi're done.

Thank you for the work on this. I'm going to take a look to see what I can do with the hourly API.

1 Like

@guy2: Ah! I had Uxbridge in while testing (since I am not in the UK I could not leave it location-based) and I must have not removed it and nobody until now mentioned it. I will correct that and get a new version released for my time tonight.

As for the rest, yes... unfortunately I made this to be an overall "day" or couple day forecast because I did not want to take over for anyone else's weather drivers (or the built-in one). It would be possible to make one though... since the data is there in their API. I suppose I could look into that tonight as well.

I pulled the hourly data to take a look at it and it seems to have what I want. I think I'm going to need to combine the weather code and the UV index in some way. The hourly data says when it was generated then you get a set of time slots so it's just a matter of picking the current one.

Thank you for looking into it, I know it's not the primary purpose of your driver.

The timeslots look like this:

..."modelRunDate": "2023-05-24T13:00Z",
"timeSeries": [
{
"time": "2023-05-24T13:00Z",
"screenTemperature": 18.3,
"maxScreenAirTemp": 18.34,
"minScreenAirTemp": 17.69,
"screenDewPointTemperature": 7.81,
"feelsLikeTemperature": 16.73,
"windSpeed10m": 3.14,
"windDirectionFrom10m": 11,
"windGustSpeed10m": 4.63,
"max10mWindGust": 4.72,
"visibility": 24306,
"screenRelativeHumidity": 49.69,
"mslp": 102480,
"uvIndex": 6,
"significantWeatherCode": 1,
"precipitationRate": 0,
"totalPrecipAmount": 0,
"totalSnowAmount": 0,
"probOfPrecipitation": 0
},
{
"time": "2023-05-24T14:00Z",
"...

There's an extended list of weather codes here:

Updated Version(s):

  • HSM4Hubitat.groovy = 0.9.3

Change(s):

  • UK is no longer fixed to Uxbridge, it is now based on Hubitat's latitude & longitude for that weather service (this did not affect other services). This was an error on my part in my testing so long ago as it was an easy place for me to recognize and ask people about the weather there for confirmation, but I forgot to switch it back before posting it. Thanks to @guy2 for pointing this out.
  • Changes to ProcessEvent and driver update checking portions. Nothing really significant, just making them more in line with my "current" standards for my drivers since this one had apparently not seen any updates at all last year.

Can you please provide links to the supported services? Specifically, what is "Weather API (WA)?"

Ah, that sounds reasonable. I will go edit the original post with links, but for Weather API specifically:

Thanks. I'm not understanding how the NWS integration pulls weather data without an API key or at least a zip code:

Is OpenWeather supposed to display today's forecasted high and low temps:

Also, getting errors from one of the driver instances but not sure which because I've since renamed it:

1 Like

Attempts at answers:

  1. The driver uses the location reported by the Hubitat settings to request weather, so entering a zip code is not necessary.
  2. OW should report Today_MinTemp and Today_MaxTemp for the min and max but for some reason it is not (it IS in the data still, I checked on mine).
  3. The 1h error is because they used to have a "rain" item that had a "1h" sub-element that then returned the amount of rain (in mm). However, they appear to have removed that so it is failing (OR it is not reported when there is no rain currently, not sure which because it still shows in the API reference but does not get returned for my device anymore).

UPDATE:
Making a major rework of the section (Forecasting WAS handled but just differently than I would do it now). Maybe not my best idea, but doing it anyways. Should handle #2 & #3 once I post it.

UPDATE #2:
Major rework cancelled... I started it, but then realized that the 1h is what was causing all the forecasting to break. It was not that it was "bad" just the code stops on an error so everything after that does not get handled. I fixed that piece (it checks if rain exists now and THEN for the 1h piece). Updated version should be published in a few minutes.

Updated Version(s):

  • WSM4Hubitat.groovy = 0.9.4

Change(s):

  • A check is now performed to see if there is any data for rain returned from the OpenWeather (OW) API before it checks to see if the 1h field is returned. Apparently a change was made and rain may no longer be provided (maybe if it is not raining, not sure). But in any case, because this was not provided the test for a sub-field to it "rain.1h" of course failed with an error, which prevented all further data processing from occurring. This made it so all the further expected data was not provided for OW calls nor any of the forecasting children being populated. Thanks to @Busthead for pointing out that an error was reported so this could be resolved.

Awesome! Errors are gone and everything appears to be working well. Thank you!

1 Like

Good to hear. I rarely touch most of my drivers once they are basically working unless someone lets me know of a problem, feature request, etc... so if you run into anything or think there might be a good addition, let me know.

Looks like the NWS driver isn't exposing Today_MinTemp or Today_MaxTemp. Is that expected?

That is correct. The NWS forecast used does not provide a value that was "meant" for that so I do not have an output for it. It only provides one temperature per time period in it's forecast.