Weather by Zip Code (US Only) from RSS Feed

Here's a little NetLinx module I wrote to get weather from an RSS feed via Zip Code (US and US Territories only)

The deal on this one is that the .comm module follows the rules and is strictly for comm back and forth from the server. It does no UI functions or polling or preset storage. There is a sample UI module and TP File included that shows you how to use the .comm module. the moudle<>Main Program API documentation is also included. It's really pretty simple. You send it a zip code and it spits back all the weather data. You can control the rate at which it spits the data back to you and choose to use or ignore whatever you don't want to get from it.

It's free to use - but if you charge for it - please send me a little kick back. :) I've included my paypal account if you feel so moved. :)

Hit me up with any questions you may have.
cheers!
e
Link to the file at my FTP server http://www.drivehq.com/file/df.aspx/publish/emmp_band/RSS_Weather_Module

Comments

  • viningvining X Member Posts: 4,328
    I don't see an attachment using.my phone or iPad, I swear this new forum sucks. Don't see new posts in "today's post" or sometimes even "new posts" .
  • ericmedleyericmedley Senior Member - 3709 Posts Posts: 4,126
    vining wrote: »
    I don't see an attachment using.my phone or iPad, I swear this new forum sucks. Don't see new posts in "today's post" or sometimes even "new posts" .


    Yeah - that's really annoying, isn't it...

    I edited the post and put a link to my ftp server so you can download it. I should just do a git repo or something.
  • viningvining X Member Posts: 4,328
    Thanks, I'll take a gamder at it. I don' t need the module but I do like looking at others code and gui's to steal ideas when ever possible. Plus I never know when my rss weather mod will break and I'll need a replacement.
  • viningvining X Member Posts: 4,328
    Hey I notice you're pulling from RSSWeather.com which what I use but when I wrote my module there was an enforced speed limit on queries of no more than 1 per hour, you could actually pull a bit more frequently if you tried but to do multiple cities as you have done, updating hourly, it would return an error message instead of data saying "slow down". I assume you haven't seen these messages and this rule is no longer exists or no longer enforced so I can go back to supporting multiple cities too.
  • ericmedleyericmedley Senior Member - 3709 Posts Posts: 4,126
    vining wrote: »
    Hey I notice you're pulling from RSSWeather.com which what I use but when I wrote my module there was an enforced speed limit on queries of no more than 1 per hour, you could actually pull a bit more frequently if you tried but to do multiple cities as you have done, updating hourly, it would return an error message instead of data saying "slow down". I assume you haven't seen these messages and this rule is no longer exists or no longer enforced so I can go back to supporting multiple cities too.


    That's good to know. Thanks! In my case I'm only looking at one city at a time for the whole system. I have made an array of the struct to handle more than one city simultaneously but have never ran into issues with it. I do only poll for new weather (preset 1) every hour. Hit limits as tight as once an hour seem a bit draconian if you ask me. I used to hit the old NOAA Telnet terminal server every 5 minutes and it didn't mind a bit.
  • viningvining X Member Posts: 4,328
    ericmedley wrote: »


    That's good to know. Thanks! In my case I'm only looking at one city at a time for the whole system. I have made an array of the struct to handle more than one city simultaneously but have never ran into issues with it. I do only poll for new weather (preset 1) every hour. Hit limits as tight as once an hour seem a bit draconian if you ask me. I used to hit the old NOAA Telnet terminal server every 5 minutes and it didn't mind a bit.
    Yeah I obviously just do one city too but Dave H. modified my mod to do multiple at one point and ran into those speed bumps, I had warned him prior. I think he then switched to something else. I've been using RSSWeather for a long time and don't think I've ever had other issues, it just always works if you can live with just one city and now a days with iPhone doing weather TPs isn't as cool as it was when I first wrote my module but I still usually include it in job.
  • GregGGregG Just some guy... Posts: 249
    NOAA will still provide all the data you could want about weather and forecasts for free, you just need to be willing to take "all the data". Not something a single AMX master can handle.
  • ericmedleyericmedley Senior Member - 3709 Posts Posts: 4,126
    GregG wrote: »
    NOAA will still provide all the data you could want about weather and forecasts for free, you just need to be willing to take "all the data". Not something a single AMX master can handle.


    I have tried using NOAA a few times but found it tended to be a bit kludgy. And their API is an API that was written by a team of engineers (See page 74 for explanation of therms for engineering team and engineer) who often use the definition of a term to define the definition of a term, thus causing an extraneous loop of thought (refer to appendix 3C on managing extraneous thought loops and it's companion article on our site) which made getting to the actual data (ref: White Paper 104523C-2 describing the purpose and use of 'actual data') rather difficult to implement.
  • GregGGregG Just some guy... Posts: 249
    Yeah it was not easy, we required the use of a custom fortran program (from noaa also) to help parse things into a database that can then be used normally to create your own api server.
  • ericmedleyericmedley Senior Member - 3709 Posts Posts: 4,126
    vining wrote: »
    Hey I notice you're pulling from RSSWeather.com which what I use but when I wrote my module there was an enforced speed limit on queries of no more than 1 per hour, you could actually pull a bit more frequently if you tried but to do multiple cities as you have done, updating hourly, it would return an error message instead of data saying "slow down". I assume you haven't seen these messages and this rule is no longer exists or no longer enforced so I can go back to supporting multiple cities too.


    Hey Vinning,
    I've been kinda testing the connection rssweather.com to see if I can break it as you mentioned. Oddly, I have had no issues with it blocking me even with multiple requests. I re-wrote it to keep weather from 10 cities and it's dutifully kept them all current. Your statement about the block spurred my poor addled brain too recall an issue I ran into early on that I just wrote off on my part. But, I downloaded your module to peek at what you did and I wonder if it's the same issue.

    I too (early on) ran into errors as you describe but wrote if off to how I was hitting the server. The first version was similar to yours in that I didn't do any of the web-browser preamble spoofing. I just hit the port with the "Get" and it seemed to work fine. But, I did get an occasional error that would persist. I didn't think that it might actually be the website blocking me. I put in the preamble spoof and it all went away.

    I wonder if you might try doing the same to see if it stops blocking you.
  • viningvining X Member Posts: 4,328
    ericmedley wrote: »


    Hey Vinning,
    I've been kinda testing the connection rssweather.com to see if I can break it as you mentioned. Oddly, I have had no issues with it blocking me even with multiple requests. I re-wrote it to keep weather from 10 cities and it's dutifully kept them all current. Your statement about the block spurred my poor addled brain too recall an issue I ran into early on that I just wrote off on my part. But, I downloaded your module to peek at what you did and I wonder if it's the same issue.

    I too (early on) ran into errors as you describe but wrote if off to how I was hitting the server. The first version was similar to yours in that I didn't do any of the web-browser preamble spoofing. I just hit the port with the "Get" and it seemed to work fine. But, I did get an occasional error that would persist. I didn't think that it might actually be the website blocking me. I put in the preamble spoof and it all went away.

    I wonder if you might try doing the same to see if it stops blocking you.
    Maybe one of these days I'll check it out again but so far no ones even asked for a 2nd city, they all got phones now a days. I remember when I wrote my module, I think around 05', the docs I read for RSSWeather also stated not to request more frequently than once per hour, hopefully, since it doesn't seem to be an issue for you that limitation has ceased. It also wasn't an error per se, it would acutally return a message saying to "slow down" your requests and it might have even said what the doc said, not query their server more frequently than once per hour. I also included code in my mod so that if a return had less than 8 of the 20(?) expected weather values it would email the entire return the master received so I can see why. That would was to allow me to work on a fix and possibly update the code before any one was wiser but that never happened except for the few occasions when only 8 or less values were actually available from their servers which does happen from time to time.

    I'm not even sure if that module I posted back in the day used zip codes or city codes that were originally required, I think the code I run uses zips but I don't know if the posted mod was ever updated.
  • ericmedleyericmedley Senior Member - 3709 Posts Posts: 4,126
    Update on this module as of 10/21/2016: It is broke. :(

    The XML parser was weathering (see what I did there?) the little tweaks rssweather.net was doing. While they were rearranging some of their formatting of the web page, they were sticking to their guns on being totally XML 2.0 compliant. So, my spendy/verbose XML parser was hanging in there.

    However, recently rssweather.net fell prey to the lusty siren song of the interweb fortune grabbers. Their site is now a click-bait ad-haunted site. They've changed their entire data delivery API.

    I did a quick check and can probably salvage the code but it's going to take some time - a commodity I don't have a lot of right now. So, if/when I get 'round to it, I'll fix it and re-post it for y'all.

    Sorry folks! It was a good run. We had a blast while it lasted.
  • viningvining X Member Posts: 4,328
    ericmedley wrote: »
    Update on this module as of 10/21/2016: It is broke. :(

    The XML parser was weathering (see what I did there?) the little tweaks rssweather.net was doing. While they were rearranging some of their formatting of the web page, they were sticking to their guns on being totally XML 2.0 compliant. So, my spendy/verbose XML parser was hanging in there.

    However, recently rssweather.net fell prey to the lusty siren song of the interweb fortune grabbers. Their site is now a click-bait ad-haunted site. They've changed their entire data delivery API.

    I did a quick check and can probably salvage the code but it's going to take some time - a commodity I don't have a lot of right now. So, if/when I get 'round to it, I'll fix it and re-post it for y'all.

    Sorry folks! It was a good run. We had a blast while it lasted.

    After reading this I had to check mine since I haven't been receiving error emails, if my module doesn't get 10 of the 20 values it sends me an email with a copy of the entire reply from RSSWeather.com, I seem to be getting all the weather parameters but no forecasts. Now this is my system but I haven't received any emails from other systems so I assume they're all the same. The missing forecast would only represent 5 missing fields so no error email would be sent.

    Now I think my parser doesn't depend on a fixed order of returned elements and I know in another module I wrote the returns were all screwed up when that device decided to update to Perl 5.18, I think, which decided to enforce perl radomization that was always in their spec but not used. That randomized the order of returns when prior everything had a fixed order for years so I originally coded for a known, fixed order. That really sucked but was fixable. I'll see if I can pinpoint the break in the forecast.

  • viningvining X Member Posts: 4,328
    I maintain the last return received from RSS Weather on the master and apparently it's not sending any forecast data so maybe I have to tweak the account or something but it doesn't appear to be a module issue, at least not on mine.
    HTTP/1.1 200 OK

    Date: Fri, 21 Oct 2016 12:05:01 GMT

    Server: Apache

    Expires: Fri, 21 Oct 2016 12:35:01 GMT

    X-Cache: jpcache vv2 - file

    ETag: "jpd--815843306.2915"

    Transfer-Encoding: chunked

    Content-Type: text/xml



    b63

    <?xml version="1.0" encoding="ISO-8859-1" ?><?xml-stylesheet type="text/xsl" href="http://www.rssweather.com/xslt.php"; ?><?xml-stylesheet type="text/css" href="http://www.rssweather.com/rss.css"; ?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Danbury, Connecticut Weather</title><link>http://www.rssweather.com/zipcode/06810/wx.php?utm_source=rss&utm_medium=rss</link><description><![CDATA[Current weather, forecasts and alerts delivered using RSS.<p>The weather information for this RSS feed is taken from the National Weather Service (http://weather.noaa.gov/), and powered by HamWeather (http://www.hamweather.com/). </p><h2>Using the Feeds</h2><ul><li>Request Frequency - The feeds are updated once per hour. More frequent requests may result in your access being limited.</li><li>Web Site Usage - If you are using the feed on your web site, you are required to maintain a link to rssWeather.com and hamweather.com</li></ul></b></p>]]></description><ttl>60</ttl><generator>HamWeather (http://www.hamweather.com/)</generator><language>en</language><item><title>Danbury, Connecticut Weather :: 63F MOSTLY CLOUDY</title><link>http://www.rssweather.com/zipcode/06810/wx.php?utm_source=rss&utm_medium=rss</link><category>Current Conditions</category><pubDate>Fri, 21 Oct 2016 06:53:00 -0400</pubDate><description>63F MOSTLY CLOUDY</description><content:encoded><![CDATA[<h4><a href="http://www.rssweather.com/zipcode/06810/wx.php?utm_source=rss&utm_medium=rss"; title="Danbury, Connecticut Weather weather forecast"><img src="http://dssni5kiwicxb.cloudfront.net/images/fcicons/mcloudy.gif"; alt="MOSTLY CLOUDY" class="icon" width="55" height="58" id="mcloudy.gif" border="0"/></a><span class="sky">MOSTLY CLOUDY</span> <span class="temp">63°F</span></h4><dl style="display: inline;"> <dt style="display: inline; font-weight: bold;">Humidity:</dt><dd id="humidity" style="display: inline;">100%</dd> <dt style="display: inline; font-weight: bold;">Wind Speed:</dt><dd id="windspeed" style="display: inline;">5 MPH</dd> <dt style="display: inline; font-weight: bold;">Wind Direction:</dt><dd id="winddir" style="display: inline;">VRB </dd> <dt style="display: inline; font-weight: bold;">Barometer:</dt><dd id="pressure" style="display: inline;"> 29.85 in.</dd> <dt style="display: inline; font-weight: bold;">Dewpoint:</dt><dd id="dewpoint" style="display: inline;">63°F</dd> <dt style="display: inline; font-weight: bold;">Heat Index:</dt><dd id="heatindex" style="display: inline;">63°F</dd> <dt style="display: inline; font-weight: bold;">Wind Chill:</dt><dd id="windchill" style="display: inline;">64°F</dd> <dt style="display: inline; font-weight: bold;">Visibility:</dt><dd id="visibility" style="display: inline;">7 mi</dd></dl>]]></content:encoded><guid isPermaLink="false">C-0653 EDT FRI OCT 21 2016</guid></item></channel></rss> [/quote]
  • viningvining X Member Posts: 4,328
    After a little playing I discovered my original GET format which is what I'm using in the office works but no forecasts:
    SEND_STRING dvRSS,"'GET /rss.php?hwvUT=F&hwvUP=in&hwvUS=mph&hwvUV=mi&hwvCCChange=time&hwvSF=Y',
                       '&maxdays=5&daysonly=0&hwvStyle=body&place=',lower_string(sCity.city),
                       '&state=',lower_string(sCity.state),'&zipcode=',sCity.zip,
                       '&country=',lower_string(sCity.country),'&county=',lower_string(sCity.county),
                       '&zone=',upper_string(sCity.zone),'&alt=rss20a HTTP/1.1',STR_CRLF" ;
     SEND_STRING dvRSS,"'Host: www.rssweather.com',STR_CRLF" ; // ok for rss/xml and html
     SEND_STRING dvRSS,"STR_CRLF" ;
    

    but in some deployments I use this newer version which does not work at all, just returns a bad format message:
    SEND_STRING dvRSS,"'GET /zipcode/',JOB_ZIPCODE,'/rss.php',STR_CRLF";
    SEND_STRING dvRSS,"'Host: www.rssweather.com',STR_CRLF" ; // ok for rss/xml and html
    SEND_STRING dvRSS,"STR_CRLF" ;
    
    My jobs that use this format haven't been sending me errors because the returned string doesn't make it to my parser since there is no </rss> end tag and since it doesn't go to the parser it doesn't send an error.



  • viningvining X Member Posts: 4,328
    Ok I just added HTTP/1.1 to the end of the 2nd GET and that now works the same as the 1st. Not sure why it wasn't there in the 1st place or why it was working with out it but...
     SEND_STRING dvRSS,"'GET /zipcode/',JOB_ZIPCODE,'/rss.php HTTP/1.1',STR_CRLF"; SEND_STRING dvRSS,"'Host: www.rssweather.com',STR_CRLF" ; // ok for rss/xml and html SEND_STRING dvRSS,"STR_CRLF" ;
    
    still no forecasts.

    E, what GET are you using, the wx.php? I don't see any adds on the rss.php page.
    http://www.rssweather.com/zipcode/06810/rss.php

    I actually don't see any here either:
    http://www.rssweather.com/zipcode/06810/wx.php

  • wishihadwishihad Junior Member Posts: 6
    Try this:
    SEND_STRING 0:WEATHER_PORT:0,"'GET /zipcode/23435/rss.php/ HTTP/1.1',13,10,'Host: www.rssweather.com',13,10,13,10";
  • ericmedleyericmedley Senior Member - 3709 Posts Posts: 4,126
    wishihad wrote: »
    Try this:
    SEND_STRING 0:WEATHER_PORT:0,"'GET /zipcode/23435/rss.php/ HTTP/1.1',13,10,'Host: www.rssweather.com',13,10,13,10";


    Guys, it's not that the get command doesn't work. It works fine with a slight change. It's that the formatting of the XML coming back is totally jacked up. And I don't have time to do a complete rewrite right now. I will when I get a little time to do so.
  • viningvining X Member Posts: 4,328
    I logged into an old system and just happened to notice that it's RSS Weather information was all accurate and up to date including forecasts. It's using this GET format.
    SEND_STRING dvRSS,"'GET /wx/',lower_string(sCity.country),'/',
                        lower_string(sCity.state),'/',
                             lower_string(sCity.city),'/rss.php',crlf"
    

    Where:
    DEFINE_CONSTANT // city, state & country for weather
    
    CHAR WEATHER_CNTRY[]  = 'US' ; //2 letters for the country
    CHAR WEATHER_STATE[]  = 'CT' ; //2 letters for the state
    CHAR WEATHER_CITY[]   = 'Salisbury' ; //30 letters max (check RSSWeather.com for covered cities)  
    
    DEFINE_START
    
         {
         CityData[1] = WEATHER_CNTRY ;
         CityData[3] = WEATHER_STATE ;
         CityData[5] = WEATHER_CITY ;
         }
    
    DEFINE_MODULE  'VAV_!MyWeatherMod1' WEATH_1 (vdvSMTP_MD5_ENCRYPT,dvRSS,dvSmtpWeatherSocket,
                                                CityData,dvTP_R4WeatherArry,dvTPWeatherG4Arry,(*dvDMSWeatherArry,*)
                            nTPBtnWeatherArray,nFeedbackChannels,
                            dvTP_Array,nWeather_DeBug,
                            nWeatherRefreshTime,nWindSpeed,nWindGusts) ;
    .............................................................
    Module:
    
    DEFINE_START
    
    create_buffer dvRSS, cRSSBuf ; 
    
    
    
    sCity.country = sCityData[1] 
    sCity.county  = sCityData[2] 
    sCity.state   = sCityData[3] 
    sCity.zone    = sCityData[4] 
    sCity.city    = sCityData[5] 
    sCity.zip     = sCityData[6] 
    

    I believe this was the original GET format from when I originally wrote this module so it may be only my later changes are not completely working, go figure. I don't think I've ever modified my original parsing. routine. It would be funny if I had to update my newer systems with older code.
Sign In or Register to comment.