[Release] OpenWeatherMap Multi-API Weather Driver

OpenWeatherMap Multi-API Weather Driver

Thank you for looking at my code!

This driver is shared under HPM and found with a search for Weather, or OpenWeatherMaps.

A direct link - here: https://raw.githubusercontent.com/jshimota01/hubitat/main/Drivers/owm_multi-API_weather/owm_multi-API_weather.groovy

My name is Jim Shimota and I rewrote this older driver to improve its use for myself and have decided to share it.

The last author seemed excited so I'm comfortable giving this a shot! The previous driver, called Weather-Display With OWM-Alerts Forecast Driver had been a valuable tool on my dashboard, but I forked off it a few years ago. It has been around and evolved from 2020!

Acknowledgement found in Readme.md file in the Repo (also found in the driver, and the HPM package json)

I NEED to also acknowledge the work of @thebearmay and @libresun. Both of which built a moon phase tool I’ve used for years now. It is also embedded into this driver as well and I thank them!

I felt it needed a rewrite since I was getting errors with secondary sources, and many issues with Units and Precision. This is the result. Other than an Alternative Icons map, the code is completely new, little if anything was lifted from the original. As you can see by the Title of the previous driver, it was very Alerts centric. I made this more of a full service weather tool.

Another important reason I went down this path is that OWM uses API keys. These keys have evolved themselves over the years. The original Key I had was called 'API 2.5'. Later OWM released a new token counting system for tracking how often you polled, it was called 'One-Call.' So the API key name changed to One-Call 2.5. a few years later, One-Call 3.0 was released, which basically adjusted the polling pricing and free levels. This year OpenWeatherMaps has declared 'One-Call 2.5' obsolete. They also released 'One-Call 4.0' and any new key you obtain is detailed as such. Old keys CURRENTLY are still supported BUT OpenWeatherMaps has warned that the 'One-Call 2.5' support will end any day. Also, you can no longer obtain a One-Call 3.0 if you want, that option is no longer available.
All this said - this driver will accept ANY of the three One-Call versions - so 2.5, 3.0 and 4.0 are supported! I also want to note that One-Call 4.0 API is a radical departure in the polled data returned! I do NOT parse the 4.0 API yet. It is more sophisticated and there are multiple polls required to return Current data and Forecast Data - to name but one major change.

** often you'll see OWM references - it may not be obvious to some but that is OpenWeatherMaps.

Finally, here is a link to some Icons and Images folders - hubitat/Icons-Images at bb40e3b8ec5e9454ae1c2d632e6cf08ec1ed2fd0 · jshimota01/hubitat · GitHub

This folder includes subfolders of Wind Direction images, Moon Phase Images (including SVG components), the original OWM icons, and the HubitatPublic Icons as well. I myself have a local NAS that servers images without leaving my local subnet and my driver allows you to set yourself however you see fit.

Goals:

  1. Support data for my future use of blinds. I wanted sun angles that were accurate and reliable.

  2. Moon phase – At a glance moon phase for fishing.

  3. Control of image paths - Localized icons and images option, fallback to icons

  4. Integrated Twilight and day/night, Solar, Moon feature so one app replaces three I currently use

  5. Improved city/long/lat lookup with reverse city name

  6. Pre-written attributes that have the Unit with the value – ie; 5 mph.

  7. Added barometer, and improved outdoor luminance

Extra features:

  • Tile length debug

  • Huge embedded comments content to assist in the future

  • Optimized SendEvent to minimize database writes

AI Reviews:
ChatGPT - Overall, I'd score v2.4.0 at approximately 9.6/10

It includes:

  • Support for multiple OWM API version keys (2.5, 3.0 and 4.0)

  • Dynamic polling based on sunrise/sunset

  • Extensive unit conversion

  • Extensive precision detail

  • Multiple date/time formats

  • Alternate icon packs

  • Wind direction graphics

  • Moon phase graphics (SVG/PNG/Emoji)

  • Automatic city lookup overrides

  • Weather alerts

  • Solar position calculations

  • Twilight calculations

  • Illuminance estimation

  • Four dashboard tiles

  • Huge number of device attributes

  • Comprehensive logging controls

Gemini - Grade: A+ (9.6 / 10)

This driver is written at a commercial/community-expert level. The code is clean, deeply defensive, and shows a strong understanding of Hubitat’s platform quirks (such as state committing delays and tile string limits).

Updates:

v2.5.9 07/28/26 jshimota Added moon alt and az text to moonPhaseTile
v2.5.8 07/28/26 jshimota Bug check: Cleaned up calcMoonPosition variables, aligned versions, and added text updates for moon angles in calcTextValue
v2.5.7 07/28/26 jshimota Added independent calcMoonPosition routine dispatches for currentMoon attributes
v2.5.6 07/28/26 jshimota Fixed location.timeZone null safety on tile date formats and corrected fallback attribute target in calcMoonPhaseSvgImage
v2.5.5 07/28/26 jshimota Bug check cleanup: fixed null safe checks on generateTiles and convertWindDirectionState
v2.5.4 07/28/26 jshimota Renamed ConditionImageText attributes to ConditionImageName and added .png extension to attribute values
v2.5.3 07/28/26 jshimota Renamed ConditionIcon attributes to ConditionImageText across metadata, logic, and tiles
v2.5.2 07/28/26 jshimota Renamed ConditionAltIcon attributes to ConditionAltImage across metadata, logic, and tiles
v2.5.1 07/28/26 jshimota Renamed generic altitude references across routines/variables to sunAltitude
v2.5.0 07/28/26 jshimota Renamed currentRain/currentSnow attributes to currentRainfall/currentSnowfall (and text variants)
v2.4.9 07/28/26 jshimota Strictly enforce precisionPrecip scaling on zero and default values (0, 0.0, 0.00)
v2.4.8 07/28/26 jshimota Separated hourly vs daily rain/snow mapping structure (daily returns direct number, current uses 1h key)
v2.4.7 07/28/26 jshimota Fixed rain and snow extraction logic for current and forecast data sets
v2.4.6 07/28/26 jshimota Renamed Wind Direction Icon attributes to WindDirectionImage
v2.4.5 07/28/26 jshimota Fix init race condition by evaluating sun position/isDay prior to parsing forecast data
v2.4.4 07/28/26 jshimota Fix race condition on forecast tile. fixed state storage of sun altitude to correct name
v2.4.3 07/28/26 jshimota changed altitude and azimuth to currentSun prefixed, added currentMoon values,
v2.4.2 07/28/26 jshimota changed api log switch to logging section. renamed precisionSunAngles to precisionSunMoonAngles

Here is a screen cap of the tiles from this driver. I use HD+ for android currently. at the bottom of each tile is ‘66%’. that is just a bug/feature of HD+!

Here is the same snap but with the Tile Debug feature enabled showing char length:

Hi Jim,

I just thought I’d install this to have a look.
Through HPM I’m getting this error I’m afraid.

Error Occurred During Installation

An error occurred while installing the package: Failed to install driver https://raw.githubusercontent.com/jshimota01/hubitat/main/Drivers/owm_multi-API_weather/owm_multi-API_weather.groovy. Please notify the package developer..

Thanks.

saw it too! thank you. I added comments and messed it up. takes a sec to fix.

Now installs fine. Looks like lots of weather goodies to play with.

Thanks!

resolved. put // instead of /* for a string comment as I was adding the previous authors notes…

Thanks. Now installing OK.

Time to play. :wink:

Hi Jim.
I’ve installed the driver and it appeared to be working OK.

Unfortunately this error has just appeared in my logs.
I’m not sure if it’s me or something is going awry.

dev:109822026-07-25 20:22:07.090 error 
org.codehaus.groovy.runtime.metaclass.MissingMethodExceptionNoStack: No signature of method: user_driver_jshimota_OpenWeatherMap_Multi_API_Weather_Driver_7983.updateLux() is applicable for argument types: () values: [] Possible solutions: updated() (method updateLux)

EDIT: It appears to be happening every 10 minutes.

somehow we have merged into the old OWM. There was an updateLux routine in the other dev’s driver, but I don’t have that routine. maybe something got merged in?

ah. I think you may replaced the previous driver with mine, and that left the schedules from the old driver in place. Could that be it? It may be best to use the clear States and clear attributes buttons, then hit Initialize. that would clear past scheduled events.

Maybe. I’ll change to device, clear everything and change back.
I’ll let you know how it goes.

You bring up a valid spot I should review, the clear buttons, which I never really intended to stay there, I need a clear Schedules too!

OK, here’s the latest.
Before I changed to device I looked at scheduled jobs and there was a 10min job for lux polling.
Changed to device and cleared scheduled jobs etc.
Changed back.
Re-input the OWM device, initialised, refreshed and polled.
I now only have 2 scheduled jobs.
scheduledPoll
scheduledTextValue
Looks like the issue was as you suspected.

Thanks for the heads up.

EDIT: By the way I did do a device swap to get your OWM into all the rules/pistons that I have using the old OWM.
I guess that was the issue.

i’m tickled! thanks for letting me know. I added a ‘clear schedule’ button. but it too has drawbacks since it kills all jobs, orphaned or otherwise! If someone trips it a new poll has to occur manually. I think I can fix that in my code tho.

Thanks for trying this!

It looks like you may have forgotten to acknowledge the author of the code you forked. Apologies if you did and I missed it.

@Matthew

I discussed with and encouraged the effort to proceed. No issues or concerns from me. Thanks.

I beliieve the readme.md has all the authors listed - its a huge list going way back. It’s also in the driver header for all to see! If you feel more should be noted, say the word - I aim to comply. The fork I made back in 2023 (24?) I maintained the kudo’s even in my fork :slight_smile:

Heck. here!

OpenWeatherMap Weather-Alerts Driver ...

This driver has morphed many, many times, so the genesis is very blurry now. It stated as a WeatherUnderground
driver, then when they restricted their API it morphed into an APIXU driver. When APIXU ceased it became a
Dark Sky driver .... and now that Dark Sky is going away it is morphing into a OpenWeatherMap driver.

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
jebbett (n3rding) · GitHub for new cooler 'Alternative' weather icons with icons courtesy
of https://www.deviantart.com/vclouds/art/VClouds-Weather-Icons-179152045.
- @storageanarchy for his Dark Sky Icon mapping and some new icons to compliment the Vclouds set.
- @nh.schottfam for lots of code clean up and optimizations.

I’m really interested to see if anyone uses the Sun Altitude/Azimuth. I spent extra time on that to get it perfect math wise. For anyone interested, THIS was by far the best site I found for visualizing and learning. I dug into the HA code on blind controls that use the combination of sun with Illuminance (not guessed at, calculated!) and I’m hopeful when I get my blinds in a few months I can get them to work just as I desire!

You may also stumble over an attribute suitable for string compares in Rules - also may come in handy for blind controllers!

image

Try this : (it’s prefilled with my long/lat and a specific time I was using - might wanna put your own in) :slight_smile:

https://www.suncalc.org/#/45.2721,-123.0078,19/2026.06.29/09:30/1/3

True but you removed any mention of @Matthew from that list of prior contributors in your version of the code.

If you guys discussed this, I don’t mean to interfere, it just seemed notable to me.

Its all good @marktheknife! I appreciate you policing me and bringing that up.

Looks like you’re doing a good job finding AI’s 0.4…