Have some updates on the subject of displaying weather forecasts:
After looking around and giving it some thought, I think that the idea of a common schema for forecast data may be a losing proposition. That’s mostly because there’s a wide variation in the data available between different sources and producing a schema that doesn’t omit data from more full-featured forecasts (like WeatherFlow’s) would result in quite a bit of complexity. It’s a shame, but the primary downside is that each widget would need to be customized; something you’d probably want to do anyhow.
I do think that weather flow’s data format would be a strong contender for the common schema, as it’s well thought out and includes all of the data you’d want. ![]()
Now for something you can actually play around with…
I’ve uploaded a new version of the smart weather binding that includes a new thing type: Better Forecast. Create one of these things and configure it with your station ID and an authorization token and you’ll get access to an automatically updated forecast based on your location. The Better Forecast thing also has features for trimming the number of forecasts in order to improve performance. By default, the forecast includes 10 daily and 220+(!) hourly forecasts, so you can cut a lot of data transfer if you don’t need that amount of data. It also “enriches” the forecast and current conditions with some extra fields that make building widgets a bit easier. This includes things like icons for the various conditions (a work in progress) as well as sunrise/sunset calculations.
Once you’ve set a forecast thing up, you can link an item to the enriched forecast data and use this widget to display it in your OpenHAB UI:
This is based on the WeatherCard widget by @RGroll, discussed here:
And it looks like this:
In addition to the weather card widget file that you’ll use to create a new widget in the OpenHAB UI, you will need to add an empty file called “dummy.js” in your config/html directory, but that’s a one-time thing.
The widget does some “magic” that gets around forcing you to create a million items by parsing the JSON data before the widget fills things in. That, plus some of the extra fields the enrichment process contributes made the resulting widget code a lot simpler. Just be careful not to mess with the “onload” line in the widget. I’ve got some additional things I’d like to do (I want to add an option to use WeatherFlow’s weather icons, for example), so I will try to follow up when I have more to report.
As always, comments and suggestions are welcome!
Bill
