Weather Tile - Open Weather - Current and Forecast

In theory, this custom tile could be edited to display any data from Open Weather. If you decide to take a stab at it, feel free to share your changes here so other community members can benefit from it.

Alternatively, some community members have been doing this with the HTTP Action in SharpTools rules so they can grab specific things from Open Weather and store them in variables either for display on their dashboards or for use within rules:

2 Likes

I’d like to adjust the openweather custom tile in the first post but am having some trouble with the html code. Would anyone be willing to provide some guidance?

I want the Right image to look like the left image.
image

I can get the entire value to move but cannot seem to isolate moving the icon left and down

I’ve just pushed an update to better support the new and old Open Weather API keys.

This introduces a new ‘API Preference’ option which allows you to choose from:

image

  • 2-5multi - the new default as it’s the most compatible with old and new API keys
  • 2-5onecall - if you have an old OpenWeather API key, this gets you 2 more days of forecast
  • 3-0onecall - if you’ve explicitly subscribed to the ‘One Call by Call’ subscription plan in Open Weather, this gets you 2 more days of forecast

You can use the steps here to update to the latest code to get the new API Preference option.

There’s also a significant difference in the current day’s High/Low value between multi and onecall API preferences. For the onecall API, it’s the low and high for the day… whereas with the multi it’s the regional high/low for that point in time. I’m tempted to drop the H/L value from the current day when not using the ‘OneCall’ endpoint as I think the indicator could be confusing – thoughts?

If today’s high/low value is significant to you, feel free to sign up for the OneCall subscription and use that it includes a ‘daily’ forecast value which is otherwise unavailable on the free tier.


OneCall API top, Multi API bottom

Another minor difference is the forecast icons - since the multi API Preference aggregates data from the ‘every 3 hour’ forecast, it picks the icon that occurs most often in the 3 hour forecasts for that day. I’m open to suggestions for alternative logic if someone has a better idea. :slight_smile:

3 Likes

As a OneCall 3.0 user, thank you! This is a terrific update. It’s much more complete, as well as more accurate.

5 posts were merged into an existing topic: Rules to query the Open Weather API

6 posts were merged into an existing topic: Rules to query the Open Weather API

Set this up the other day and its working great. I have it on a 2x2 tile and have realized that the future days forecast is too small on my tablet and would prefer to just see the current temp in large font, the day’s forecasted high/low, rain % and wind speed on a 2x2 tile so that the current temp could be seen from 4’ to 6’ away on my 7" tablet and the other details visible as walking out the door to know if we need to grab a coat for the day or an umbrella. Simlar sizing to the 2x2 date/time tile. Would also prefer it to follow my dashboard theme for a cohesive design. Does anyone have the code for this already? I tried looking at the code for this tile and immediately knew it was gonna be an excessive number of manhours for me fumbling through trying to modify it.

This is great. Works well.

Just out of curiosity, do we know what the “2” in a mustard color box next to “Feels Like” Means?

It’s air quality index.

1 Like

Yes, it’s AQI. And the Air Quality Index only shows up if you check the box for it in the tile’s settings, so you can uncheck it if you don’t want to see.it.

1 Like

Doh! Thanks. Had that turned on. Now that I know what it is, I will keepit.

1 Like

How often does the Weather Tile update? The current temperature is often not current. If I go to another dashboard and come back, it updates.

Every 3 hours by default.

You could modify the number set at the very top of your Custom Tile code if you wanted a faster refresh. Just keep in mind that a faster refresh could put you over your API limits.

image

Doing a quick “back of the napkin” math, even with the lower 1000 free API calls for the 3.0 version of the Open Weather API, if you had it set to every 10 minutes, that would be 144 calls per displayed tile in a day

(24 × 60) ÷ 10 = 144

So if you had a single weather tile on 5 different displays, that would be 720 API calls to the One Weather API each day.

Of course, that assumes you aren’t using the API key elsewhere (like in a Hubitat driver) that would be increasing the API call, but you get the idea.

Edit: And if you enable AQI in the tile settings, that requires a separate API call, so it would double the number of API calls.

Thank you for the quick reply.

I only have the weather on my main display so I decided to try 5 minute updates. Which should work out to 288 calls (24*60/5) with no air quality display. So, at line 12, REFRESH_INTERVAL =5*60*1000; //5 minute in ms

I’ll let you know if I have any issues.

Thanks again.

Don’t know what happened with the formatting. That should be 288 calls (24x60/5) and refresh of 5x60x1000.

1 Like

I edited the post for you to fix the formatting. Wrapping text in single asterisks turns it into italics.

If you want to format text as raw/code, you can highlight it and then tap the </> button on the editor toolbar to format it accordingly.

I see you were responding via email, you you can also do it by wrapping your formatted string in backticks:

`your * formula * or code`

Becomes :point_down:

your * formula * or code

Okay, thanks for all that.
In a previous post you stated I’m tempted to drop the H/L value from the current day when not using the ‘OneCall’ endpoint as I think the indicator could be confusing – thoughts?
Don’t think you had any responses to that, however, I agree it is confusing. Is there a way to drop that?

I just pushed an update to the tile to address this. Try updating your custom tile and let me know if it works better:

There’s a few changes in this release:

  • Current Day High/Low Improvements:
    I’ve added in a fallback to Open Meteo which is another free weather source which has a ‘forecast’ for the current day. (Only applies when using the “2.5 Multi” setting)
  • Configurable Refresh Interval
    There’s now a configurable refresh interval setting in the tile rather than you having to edit the interval manually
  • Fixed High/Low “2.5 Multi” Forecast Issues
    This was impacting both the ‘today’ forecast as well as the weekly forecast wherein values over 100 were causing the high/low values to be invalid

Current Day High/Low Improvements:
This appears to work. I see different values depending on what weather service provider I look at for the forecast, but the tile numbers appear to be in the range. Will monitor and let you know if there are any issues.
Configurable Refresh Interval:
This is a nice feature. I entered a refresh rate of 5 minutes which I think is reasonable for my application (see previous discussion above), however I got a warning banner (refresh interval faster than 10 minutes is not recommended) coming up. It continues to come up every time that dashboard is loaded which is annoying, so I put it to 10 minutes. I can live with 10 but would prefer 5 as it then closely matches our local temperature display and then I don’t have to field questions about why they don’t match and get into explanations of polling rates, etc.

Most weather services have a minimum refresh interval, so going beyond that won’t improve anything as its still returning the same data during that interval.

In the case of the Open Weather Map API, the data is refreshed every 10 minutes at best.

“First, we recommend making API calls no more than once in 10 minutes for each location, whether you call it by city name, geographical coordinates or by zip code. The update frequency of the OpenWeather model is not higher than once in 10 minutes.”