JP Weather

JP Weather is a simple module to put the weather in a page.

It can read weather.gov's current conditions, from sensors usually at airports and schools. And it can read the seven-day forecasts, specified by zip code.

It uses intelligent caching, so that once it reads any weather data, it will keep it. This is useful because weather.gov only allows you to read the forecast once an hour, and the current conditions every ten minutes.

It then sends that data through completely customizable and simple templates. You can see examples around the sides of this page.

Download newest version here.

FAQs

Q: Do I need to put both a weather station and a zip code?

No. In fact, you almost certainly don't need both. If you pick a pre-defined template that starts with current-, you only need the current conditions station. If you pick one that starts with fore-, you only need the forecast zip code. And both-, obviously, needs both.


Q: How often does this update? How is the caching?

It updates as fast as it's allowed to. The rules on weather.gov allow you to check the current conditions every ten minutes, and the seven day forecast every hour. Not only would updating faster accomplish nothing (As the data is not updated more often.), but you risk weather.gov blocking you if you do.

Additionally, this cached data is global to the site, not the page or the module. I.e., if you put the module on the page five different times, with the same forecast location, it will only get the data once. (That is how we do the examples on this site. All those examples are the same location with data only fetched once.)

This module does not have the option to cache the module HTML. There's no reason for that. The only thing this module does is hand the weather data it's cache to the template, and doing that directly is going to be faster than checking an html cache first and coordinate the HTML cache with the weather data cache. Too much work for so little data.

 

Q: How do I make local icons work?

Local icons requires write permissions to the directory they're being put in. It can't use the FTP subsystem to put them there. So if you can't write to /images/, put them in /tmp/. If you inexplicable can't write there, or have a .htaccess stopping you from reading files from there, just use remote icons.

 

Q: Something is wrong and I don't know what.

Firstly, if there is an error displayed, that is the problem. :) If there is not an error displayed, switch the module to the 'debug' template, and reload the page. (You might have to move the module to another position, because it's a lot of text and might not fit where it is. Or view the page source.)

On the page, you should have should have a $current:Array(), with a $forecast:Array after it the page. The first one should contain info retrieved from the 'Current Conditions Station', and the second should contain the 'Forecast Zip Code' info. Remember, you probably only have one of those options filled out, so it's fine if the other array is blank.
If the weather data showing there seems reasonable good, there is something wrong with your template. Possibly the file is empty, or the template is bad, or it's trying to use the current conditions data and you've only filled in the forecast, or vis versa. Try another template. (If it was one of my original templates that's bad, send me an email and I'll fix for the next release and send you a fix.)

If the weather data is bad, see next question.

(P.S. I don't know how many times I've tripped up thinking something was wrong with a module when Joomla had just decided not to show it on a page or it was in a position that did not exist. You might want to turn on the module title to make sure Joomla is trying to show it at all.)

 

Q: Something is wrong with the weather data.

First, clear the Joomla cache to get new data. If that does not work, there are two possibilities.

The first is that you've somehow gotten blocked from weather.gov. (See the warning below about repeatedly clearing the cache.) If that has happened, simply wait until tomorrow, everything will fix itself. You might even want to turn the module off until then, so you won't make *any* demands on them...they might remove the block faster. I'm not sure, but it can't hurt.

The last possibility is that weather.gov changed their data format, and everything is broken. Doh. Nothing you can do about that. Check the homepage, if that happens I'll put up a notice and work on a new release asap.

 

Q: I want a better template.

Make one! It's not hard. First, figure out if you want to show current conditions or the forecast or both. You can copy one of the existing templates and start editing.

If you are doing forecasts, note each day has three areas of information...day, night, and total. This is the difference between 'single' and 'dual' in the templates.

Day is the daytime forecast (From 6AM to 6PM), night is the nighttime forecast (6PM to 6AM), and total is an overall forecast of that day. Or, rather, the overall focecast from 6AM that morning to 6AM the next morning. I.e., days change at 6AM instead of midnight.

Also, you'll run into the very annoying problem that weather.gov will give out partial days. I.e., if you're trying to show day and night forecast for today, but if it's after 6 in the evening, you no longer get the 'day' forecast for the current day in the data, probably because that 'forecast' is now in the past. That's why you can remove 'lopsided days' in the module config. Also, from midnight to 6 in the morning, the correct forecast to describe current weather is for 'yesterday night' because of how the 'days' work. Please don't shoot the messenger for weather.gov's weirdness on this issue. However, the current conditions part makes perfect sense.

 

If you come up with a particularly clever template, and want us to distribute it, feel free to email it back to us and we'll look at it. Just paste it into an email, no need to get fancy. Obviously you must license it under the GPL if you want to do that. You will get credit for your work.


CACHE WARNING: When working on a site, it's very easy to get in the habit of constantly clearing the cache. This will clear the weather data, which means the next page load will retrieve it again. That means you will be repeatedly downloading the same data from weather.gov, which you are not supposed to do. You're only supposed to do that every ten minutes for current conditions, and once an hour for the forecast.

*Slightly* exceeding that is fine, in fact, checking ten times as much as you're supposed to seems fine, but keep doing downloading it over and over constantly, and you *will* get temporarily blocked from retrieving the data.

To avoid this problem, when you go to the 'Clear Cache' page, use the 'check all' checkbox like normal, but then *uncheck* 'jp_weather' before you clear the cache.

Or, a better method is to just disable the Joomla cache while you're working...we'll override that option to cache the weather data anyway, but nothing else will be cached. That way you can see your changes without getting banned for too many weather data fetches.

JP Weather

Current Conditions
Mostly Cloudy
Wind east at 9 mph
Temp: 76°
Today
Rain Showers Likely
Precip chance:14%
Hi:74° / Lo:66°
Tomorrow
Rain Showers
Precip chance:73%
Hi:69° / Lo:53°
Tuesday
Mostly Sunny
Precip chance:92%
Hi:65° / Lo:42°
Wednesday
Mostly Sunny
Precip chance:42%
Hi:58° / Lo:41°
Thursday
Sunny
Precip chance:10%
Hi:64° / Lo:47°
Friday
Slight Chance Rain Showers
Precip chance:5%
Hi:69° / Lo:50°