[PROJECT] Weather Service Monitor 4 Hubitat Driver

@theDaithiMac: I apologize that I somehow missed your posting here for so long. That is really unacceptable on my part. Please see below.

All UK Met Office Users
All, please do not use the migrated UK Met Office API yet if possible. While I am working on it and it is possible to add your API Key into the code there are some issues I am reaching out to Hubitat about (first and foremost that device Preference fields appear to have a 255 character limit and the API Key I got is >1600).

That said... if you cannot wait and really need this... Here is a link to a... let's call it "Alpha" version that will replace the driver on your system. I am NOT going to replace the main published version at this time with it until this can be worked out better than having you hard code your API Key into the driver (as is currently necessary). The instructions you need to follow are:

  1. Open the driver code on your Hubitat (Drivers Code - WSM4Hubitat).
  2. Go to line 404 within the driver code window.
  3. Replace the ENTER_UK_API_KEY_HERE with the API Key you have for your Met Office account.
  4. Save the drivers code.
  5. Go to the device.
  6. Make sure the "Service to Query" Preference is set to "United Kingdom Met Office" (if you change it, you should Save Preferences).

This should now allow it to query the new API. The received data structure has not appeared to have changed, it worked just fine on my system (faking my location as being in Uxbridge).

I apologize for the hassle here. I am trying to figure out a method to make the driver work properly and be convenient again before I replace the main version.

Updated Version(s):

  • WSM4Hubitat.groovy = 0.9.7
  • WeatherSensorChild.groovy = 0.8.14

Change(s):

  • The UK Met Office workaround is now required. "Hard code" your API Key on line 412 (due to changes so far). I am still trying to work with Hubitat on alternatives.
  • Driver-specific attributes that had spaces in their names (Driver Name, Driver Version, and Driver Status) have been replaced with versions that do not have spaces. They will be removed the next time you Save Preferences.
  • Correction was made to the ProcessEvent function.

Just found this project while looking around for alternatives to OpenWeatherMap (their API is changing).

Everything installed great, but it appears that I'm getting an incorrect value for temperature. It looks to me like 'temperature' matches Today_Temperature. I'm using NWS and the NWS website shows my current temp quite a bit cooler than the WSM device. I've observed this before as well, but hadn't had a chance to play around with it.

I queried https://api.weather.gov/stations/KDET/observations/latest in my browser and it shows 22.2C (72F), which is correct. temperature in the device shows 77F as does the info returned in the trace log.

Thoughts?

This project is meant to provide just a daily snapshot and possibly some forecasting (if the service queried provides it). It does not provide the "current" weather (for example, temperature) and was never designed for that because there were other options (such as OpenWeatherMap) when I originally wrote it.

With the NWS service where does it get the location data from? Mine shows GridY and GridX automatically however it's over 60 miles away from my actual location. Is there anyway way to change it?

It uses the hub's latitude (location.latitude) and longitude (location.longitude) sent to the US NWS to get the grid points for that location. Those are saved as the State Variables gridX and gridY, which are used from then on to query the NWS based on the grid points.

The way to change it would be changing the location the hub thinks it is (or correcting it if it is wrong). I did not make a method to override it directly in the driver itself... That is something I could look into as a device Preference if it turns out to be necessary.

Updated to the latest version today and am now getting

image

The last change to the parent driver was in March, so nothing recent has changed that would cause a difference. Did you change the refresh interval? The main "workarounds" are to reduce the refresh rate or (and my recommendation) up the number of events allowed before providing a warning.

WARNING: Bit of a rant...
Some drivers generate a large number of events because they parse in a LOT of data points when they run and need to provide all those data points. But they are not REALLY impacting the system as much because it is all happening in a block of data (it is not a contact sensor constantly sending communications as new changes happen over and over, it is one communication causing 50+ events). A number of my drivers operate the same way with massive numbers of events coming from a single query... but there is no way for Hubitat to really know what is causing all those events to happen, it just sees a device "generating" tons of events which could be a problem for/from some. I generally recommend (if you see these alerts for any device) checking the Device Stats table, looking at the overall system's busy % and the device listing to see if the system is truly busy and if particular devices are causing it. Here is an example... My WeatherFlow parent device has a bit over 3800 events on the stats page (and it is starting to shade that red) over the course of ~78 hours but that is only ~53 events and hour. The "scary" part is that it is making up 46% of the busy time on my main Hubitat! But what is the overall Hubitat's usage/load? 0.7% So a whole lot of nothing.

3 Likes

^^This^^

1 Like

Hi

Probably doing something dumb here. Want to use the UK Met Office service. Have created a Met Office DataPoint account and got my api key. Have added that to line 412 as instructed. Have turned on trace logging and it is saying "Weather Info - Invalid API credentials provided" The key I have is only 35 digits.

I tested the key via the example link on their website and it worked returning XML output (see limited screenshot below).

Any advice?

It looks to me like you are accessing their "Met Office DataPoint" that WAS supposed to be retired (it still is, but it looks like the date is moved back to March 2025 now).

This driver uses the Met Office Weather Datahub which is the successor to the previous system the driver connected to (and what I originally designed it all around). Datahub has a different login and such from DataPoint if I recall correctly.

AHH! That makes sense.

Finally found how to subscribe to the free service and got the massive API key. Inserted this into line 412, but every time I connect I get an error (see below).

image

I'm new to Hubitat, and added your driver and created a device with OpenWeatherMap.
I added the same API key as the built-in OWM device uses successfully.

However, it keeps telling me (with logs set to Trace):
OWM forecasts - Invalid APIKey provided

What am I missing?

OpenAPI 2.5 was deprecated and terminated as of June 2025.
OpenAPI 3.0 is currently the only available API to use.

I will test whether simply changing the URLs in the code is sufficient. (Probably not, but I will update once I know!)

Changing 2.5 to 3.0 in the URLs in the code seems to work just fine...

Yes all new API keys are now for OpenWeather 3.0
We just need to change the url to https://api.openweathermap.org/data/3.0/onecall instead of https://api.openweathermap.org/data/2.5/onecall
And it works

Updated Version(s):

  • HSM4Hubitat.groovy = 0.9.8

Change(s):

  • OpenWeatherMap has been changed to 3.0 from 2.5. I knew this was coming... But totally forgot about it. Sorry about that folks. Thanks to @francesco for bringing it up.
  • "Data as of" attribute has been replaced by "DataAsOf" to eliminate one more of the visual oddity of attributes/events with spaces in their name, but you will need to Save Preferences to remove the existing one (it will not harm anything, but it will still be sitting there at the last value it showed).
  • Changes (and the version log) have resulted in the UK API Key spot now being located on line 417.

Are you still getting a 403 error after trying the new API? You have your Preferences set for "United Kingdom Met Office" not the "Legacy United Kingdom Met Office", correct?

I tried using my key (and replacing the location data with a known point covered by the Met Office) and was able to get data successfully, so overall it works. Just need to figure out the problem here...

I get this on my Weather flow when lightning is detected. While I get the alert nothing seems to bog down the hub...

Preferences are set "United Kingdom Met Office". Just updated the drive to 0.9.8 but no change. Is there a way I can test this outside the code?