Driver for Weather Service JSON API

Hello all,
I'm very nooby, very enthusiastic, member of this community and I'm looking for some examples to build one driver pulling data from some Weather JSON API service.
Source API example:
https://api.ipma.pt/open-data/observation/meteorology/stations/obs-surface.geojson
I'm not a web developer, but I can go my way if pointed in the right direction :slight_smile:
Thank You
Pedro

There are quite a few examples that go back several years. One I created is now both old and obsolete since the origin got bought by Apple. However, the general concepts of how to create a driver that interacts with a cloud resource is still pertinent.

There are a few Weather related community drivers posted in the Device Drivers list:

Another example you could look at (it is in there as well) is my WeatherServicesMonitor. It actually supports multiple weather services to try to give people around the world options (at least that was the intent, I found very few services and have not had much in the way of requests to expand it).

1 Like

I've got a fairly simple driver for the National Weather Service (USA) here.

It does both the detailed forecast and a configurable number of hourly hours worth of forecast.

It aslo grabs the highest and lowest temps for the next 12 hours of houly forecasts, and the maximum percent chance of precipitation.

Code isn't documented, but it's reasonably well written (as much as Groovy can be, since there's basically no support for Groovy in VS Code, so it's like writing in Notepad).

1 Like

@daniel.winks I wanted to use your NWS driver as a model for something I'm working on, so my first step was to load it and see how it worked. You reference an external library
#include dwinks.UtilitiesAndLoggingLibrary

but it fails when I load and try to install.
is there a quick solution you can suggest? It's just so I can learn and model from!

Hi, that's a library where I stuff a bunch of things I use across all my apps and drivers. Logging related stuff. Some common initialization stuff. Etc.

You can copy/paste the library into the driver code, remove the reference at the top of the driver to the library and it should work. You'll want to just copy the library code, not the metadata stuff at the top.

1 Like

one error - resolved - changed:
line 103 in NWSForecast.groovy from:
clearStates()
to:
clearAllStates()
success!