Grandstream GXP21xx Weather

UPDATE: This article (and sadly many others) have sat in my “Drafts” folder for far too long. I had originally intended to give this a look-over before release about a year ago, but I never got around to it. One of my co-workers recently reported a problem with the weather display on their IP phone. It seems that the Yahoo! feed may now be down (as predicted in this article). I’m publishing this now to assist anyone who may be interested in working on a MITM-type replacement for it. The original intent of this article was to help people find the appropriate city-code for their area.

Grandstream GXP21xx-series phones have a neat weather application. I’m using a GXP2140 with color screen and I thought it would be nice to display the weather on the home screen (a feature native to the phone).

grandstream_weather

The trick is trying to find the Location ID, or as Grandstream calls it “City Code” for your area. The phone automatically tries to find the best Location ID to use, but at least in my case, it wasn’t as accurate as I would have liked. So how do you find the correct location?

A packet capture shows that the phone grabs its weather information from Yahoo!

GET /forecastrss?p=USNJ0234&u=f HTTP/1.1
User-Agent: Grandstream Model HW GXP2120 SW 1.0.8.4 DevId 000b8200ff00
Host: xml.weather.yahoo.com
Accept: */*

A little research shows that Yahoo! gets this data from Weather.com, and these Location IDs are Weather.com related. You can query weather.com for a Location ID for a given place name in text form at the following link:

http://wxdata.weather.com/wxdata/search/search?where=London

Only the first 10 results are shown:

<search ver="3.0">
 <loc id="UKXX0085" type="1">London, GLA, United Kingdom</loc>
 <loc id="USAR0340" type="1">London, AR</loc>
 <loc id="USCA9301" type="1">London, CA</loc>
 <loc id="USKY1090" type="1">London, KY</loc>
 <loc id="USOH0520" type="1">London, OH</loc>
 <loc id="USTX0788" type="1">London, TX</loc>
 <loc id="USWV0443" type="1">London, WV</loc>
 <loc id="SFXX6559" type="1">London, LP, South Africa</loc>
 <loc id="SFXX7547" type="1">London, MP, South Africa</loc>
 <loc id="FJXX0101" type="1">Londoni, C, Fiji</loc>
</search>

Let’s use New York, NY as an example.

$ wget -q -O- "http://wxdata.weather.com/wxdata/search/search?where=New%20York"
<search ver="3.0">
 <loc id="USNY0996" type="1">New York, NY</loc>
 <loc id="UKXX7149" type="1">New York, LIN, United Kingdom</loc>
 <loc id="JMXX0950" type="1">New York, 14, Jamaica</loc>
 <loc id="JMXX1405" type="1">New York, 06, Jamaica</loc>
</search>

A few different results are returned for “New York“, but the one we want it USNY0996. Once we know this code we update it in the web interface of the IP phone. In the case of my phone this was found under Settings -> Web Services

grandstream_weather

It looks like Yahoo! is using a newer API for weather these days, so I’m not sure how much longer these phones will be able to get weather. Documentation about the API is available here:

https://developer.yahoo.com/weather/archive.html

For posterity I’ve included a quick partial example of the output from these requests, in case you should ever need to implement your own service (to be intercepted at your firewall, or via DNS) in order to maintain this feature on your phone.

curl -s "http://xml.weather.yahoo.com/forecastrss?p=UKXX0085&u=c"

The results have been trimmed down for brevity

<channel>
 <lastBuildDate>Thu, 20 Aug 2015 7:19 pm BST</lastBuildDate>
 <ttl>60</ttl>
 <yweather:location city="London" region=""   country="UK"/>
 <yweather:units temperature="C" distance="km" pressure="mb" speed="km/h"/>
 <yweather:wind chill="20"   direction="210"   speed="16.09" />
 <yweather:atmosphere humidity="78"  visibility="9.99"  pressure="1015.92"  rising="0" />
 <yweather:astronomy sunrise="5:50 am"   sunset="8:12 pm"/>
<item>
 <pubDate>Thu, 20 Aug 2015 7:19 pm BST</pubDate>
 <yweather:condition  text="Mostly Cloudy"  code="28"  temp="20"  date="Thu, 20 Aug 2015 7:19 pm BST" />
 <yweather:forecast day="Thu" date="20 Aug 2015" low="17" high="22" text="Mostly Cloudy" code="27" />
 <yweather:forecast day="Fri" date="21 Aug 2015" low="15" high="24" text="AM Clouds/PM Sun" code="30" />
 <yweather:forecast day="Sat" date="22 Aug 2015" low="18" high="29" text="Sunny" code="32" />
 <yweather:forecast day="Sun" date="23 Aug 2015" low="14" high="22" text="Showers" code="11" />
 <yweather:forecast day="Mon" date="24 Aug 2015" low="12" high="20" text="Showers" code="11" />
</item>
</channel>
This entry was posted in General Nonsense. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *