Home AMX User Forum NetLinx Studio

Netlinx as RSS reader

I'm trying to develop my own alternative to iWeather, and an option seems to be using an RSS source like rssweather.com. Is there any way to access this info via a Netlinx master? Anyone have any other options? (That are applicable north of the border, that is....)

Jeff
«1

Comments

  • viningvining Posts: 4,368
    RSS Weather

    Try this. This was created about a year ago. DHawthorne then converted it into a module form, someone else added the ^BAT to the the forescast feedback while some one else provided a link to the missing icons. So, in a sense it was a forum creation.

    Edit Notes:
    Removed zip file and replaced modified version in a more recent post.
  • Jeff LockyearJeff Lockyear Posts: 147
    Thanks a ton guys. I should have done a search before posting a question.... I'll take a look at this stuff today.

    Cheers!

    Jeff
  • Jeff LockyearJeff Lockyear Posts: 147
    Hey vining, I looked at the file you posted and it's great. You've saved me a ton of work and given me a great jumping-off point. My only question is regarding the "GET" url. Where did you fine the guidline/protocol for that? I can't use the one in your example because it won't work for Canadian cities (no zip code, zone, or 5-day forecast).

    Thanks again

    Jeff
  • viningvining Posts: 4,368
    Well I probably went to the RRS.weather site and put in my information to view local weather and then viewed the source on the return web page. Then I probably telnetted the site playing with a different things, read up on the HTTP 1.1 protocol. In the array that contains the city information there are notes for URLs to look up some of this info like the noaa code. Best bet though would be to look up the source on the web page.
  • Jeff LockyearJeff Lockyear Posts: 147
    Understood. Thanks again.

    Jeff
  • viningvining Posts: 4,368
    You may have to put in data for the nearest major city in order to get forecast feedback. I often use the nearest major local city that provides the forecast feedback and then force the city name displayed on the TP to the actual name of the city the customer lives in.
  • Jeff LockyearJeff Lockyear Posts: 147
    No worries. Unfortunately the nearest US city is Buffalo, and they get wildly different weather than Toronto (much worse, typcially). Actually, I've got XML info from Yahoo! that's working really well. And apparently Environment Canada will be getting their RSS act together soon and have extended forecasts etc.

    Thanks again for your help. I don't think I'll be using the module you posted, but looking at it sure got me on the right track.

    Cheers,

    Jeff
  • viningvining Posts: 4,368
    See if this works. The only thing odd is the".cwto--:fpcn51.cwto-" after zone in the piece code from the rss site. RSSWeather returns nice forecast data for toronto so it just a matter of inputting the proper data.

    country = ca
    county = '' (2 single quotes, no space in between)
    city = toronto
    state = on
    zipcode = '' (2 single quotes, no space in between)
    zone = fpcn11 (this may need a little playing with)


    From RSSWeather for Toronto Ontario Canada
    rss.php?config=&forecast=zandh&place=toronto&state=on&zipcode=&country=ca&county=&zone=fpcn11.cwto--:fpcn51.cwto--&alt=rss20a" 
    
    PERSISTENT CHAR CityData[][30] = 
         {
    		    // leave unkown fields as '' (no space between)
    		    // (you should get info back with just city,state, country & zip)
         {'CA'},	    // Country: figure this out yourself
         {''},	    // go to >>> http://www.itl.nist.gov/fipspubs/co-codes/states.htm 
    		    // (to find code for your area)
         {'ON'},	    // State: figure this out yourself
         {'fpcn11'},    // go to >>> http://weather.noaa.gov/pub/data/forecasts/marine/coastal/
    		    // (coastal and inland waterways) (you could parse this page it you want!!)
         {'Toronto'},   // City: figure this out yourself
         {''}	    // Zipcode: figure this out yourself
         
         } ;
    
  • alexanboalexanbo Posts: 282
    Hey vining, I looked at the file you posted and it's great. You've saved me a ton of work and given me a great jumping-off point. My only question is regarding the "GET" url. Where did you fine the guidline/protocol for that? I can't use the one in your example because it won't work for Canadian cities (no zip code, zone, or 5-day forecast).

    Thanks again

    Jeff

    I user RSSWeather fine with weather on the West Coast of Canada and Alberta.

    The Get Statement I use is
    "'GET /hw3.php?place=',cWEATHER_CITY,'&state=',cWEATHER_STATE,'&country=',cWEATHER_COUNTRY,' HTTP/1.0',13,10,13,10"
    

    Where place is the city(you have to look at the list at RSS Weather and choose one that's on the lise), state = province, two letter abbreviation ie BC, AB and country = CA
  • flcusatflcusat Posts: 309
    vining wrote:
    Try this. This was created about a year ago. DHawthorne then converted it into a module form, someone else added the ^BAT to the the forescast feedback while some one else provided a link to the missing icons. So, in a sense it was a forum creation.

    Vining, a couple of questions in the module header you have dvTP_Array but I didn't find it in the axi file. Also I put all the parameters needed for Miami Florida but I'm not geting anything in the TP. Here is how my local information looks like:
    
    
    PERSISTENT CHAR CityData[][30] = 
         {
    		    // leave unkown fields as '' (no space between)
    		    // (you should get info back with just city,state, country & zip)
         {'US'},	    // Country: figure this out yourself
         {'12086'},	    // go to >>> http://www.itl.nist.gov/fipspubs/co-codes/states.htm 
    		    // (to find code for your area)
         {'FL'},	    // State: figure this out yourself
         {'FLZ074'},    // go to >>> http://weather.noaa.gov/pub/data/forecasts/marine/coastal/
    		    // (coastal and inland waterways) (you could parse this page it you want!!)
         {'Miami'},   // City: figure this out yourself
         {'33184'}	    // Zipcode: figure this out yourself
         
         } ;
    
    VOLATILE DEV dvTPWeatherArray[] = {dvTP1_Weather} ;
    
    
    
    

    I also left dvTP_Array out and only using one TP instead of 3.

    The module definition looks like this:
    MODULE_NAME='VAV_!MyWeatherMod1' ( DEV dvRSS,CHAR sCityData[][],
    				   DEV dvTPWeatherArray[],INTEGER nTPBtnWeatherArray[],
    				   INTEGER nFeedback[],
    				   INTEGER nWeather_DeBug,INTEGER nWeatherRefreshTime)
    
    

    and the module definition like this:
    DEFINE_MODULE  'VAV_!MyWeatherMod1' WEATH1 (dvRSS,
                                                CityData,dvTPWeatherArray,
    					    nTPBtnWeatherArray,nFeedbackChannels,
    					    nWeather_DeBug,
    					    nWeatherRefreshTime) ;
    

    I kept the same channels for the TP. Any ideas why I'm not getting the info from the RSS?
  • flcusatflcusat Posts: 309
    Also from where are you getting the sunrise and sunset information?
  • DHawthorneDHawthorne Posts: 4,584
    I've found a bug in the module regarding wind direction. If the wind speed is very low, and the direction kind of fluttering around, the site outputs "VRB" instead of a directional value, and it breaks all the items after that. I put in a real cludgy fix that just tests for the VRB (there is almost certainly a more elegant way to do it, but it works). Inside the fnRSSParser function, find the section that starts with "find_string(iRSSBuf,'id="winddir"',1)" and replace it with the following:
    	  nFBS = find_string(iRSSBuf,'id="winddir"',1)
    	  if (nFBS)
    	       {
    	       stack_var char cWindDir [3]
    	       cRSSTrash = get_buffer_string(iRSSBuf, nFBS + 11)
    	       nFBS = find_string(iRSSBuf,'inline;">',1)
    	       cRSSTrash = remove_string(iRSSBuf,'inline;">',1)
    	       IF(FIND_STRING(iRSSBuf, "'VRB'", 1))
    		    sRss.winddir = 'variable'
    	       ELSE
    		{
    		   nFBS = find_string(iRSSBuf,'(',1)
    		   sRSS.winddir = get_buffer_string(iRSSBuf, nFBS - 1)
    		   cRSSTrash = remove_string(iRSSBuf,'(',1)
    		   nFBS = find_string(iRSSBuf,'&#176',1)
    		   cWindDir = get_buffer_string(iRSSBuf, nFBS - 1)
    		   sRSS.winddir = "sRSS.winddir,cWindDir"
    		}
    	       i ++
    	       }
    
    

    This will fix those instances where it will only find 3 of 20 possible values.
  • flcusatflcusat Posts: 309
    Dave I'm still not getting anything from RSS. Any other suggestions?
  • DHawthorneDHawthorne Posts: 4,584
    flcusat wrote:
    Dave I'm still not getting anything from RSS. Any other suggestions?
    Try deleting the city name and use only the zip code. I've noticed sometimes it doesn't want to recognize the city name, even though it returns it properly.
  • flcusatflcusat Posts: 309
    DHawthorne wrote:
    Try deleting the city name and use only the zip code. I've noticed sometimes it doesn't want to recognize the city name, even though it returns it properly.

    Thanks Dave. I'll give it a try tonight.
  • viningvining Posts: 4,368
    DHawthorne wrote:
    This will fix those instances where it will only find 3 of 20 possible values.
    I don't think I've ever seen it that bad but I've also never noticed the "VBR" return. Of course I can't say I ever looked for it either. I always thought when the panel showed N/A it just didn't get a returned value. Nice catch!

    flcusat wrote:
    1, I also left dvTP_Array out and only using one TP instead of 3.
    2, Also from where are you getting the sunrise and sunset information?
    3, in the module header you have dvTP_Array but I didn't find it in the axi file.
    4, Also I put all the parameters needed for Miami Florida but I'm not geting anything in the TP.
    1, I often leave arrays of 1 TP as an array of 1 TP.
    2, TimeManager
    3, Those can be removed. I had a subroutine hiding in the compiled weather module on a recent install and I neglected to pull those out of the header.
    4, Try what Dave suggested. So far every one of my jobs that I've installed this in have used the same set of paremeters as they're in the same 50 mile radius area. Needless to say I haven't had exposure to the problems that arise from trying to acquire data for different regions.

    Edit Notes:
    Modified zip file. Removed the dvTP_Array from the module headers and inserted Dave's fix for wind direction return of "VBR".
    increased structure char array for winddir to eight to fit the word "variable".
  • flcusatflcusat Posts: 309
    Vinning since I was having problems getting this to work with my city parameters I decided just to test the file with yours but still can't get this to work. Could you check the attached file and tell me what is wrong with it? Thanks in advance.
  • viningvining Posts: 4,368
    Hmmm!

    In the debug window put in "nWeather_DeBug" and set it to 1. Then open diagnostics and run the code. I believe button # 1 in the GUI is "Last Updated >" or at least that's where mine is hidden will manual run the update process.

    When you push the update button take a look at the send_string 0 strings the module puts out. My thinking is that you're not resolving the DNS and you will have to set this to your router or gateway address in Diagnostics>Network Addresses. If you were just using your own values I would say that you have some bad values but using the default should work w/o problems. Are you running TimeManager? If that's working then your DNS is fine?

    Set the debug flag and see what you get? Post a copy of the diagnostics.
  • flcusatflcusat Posts: 309
    vining wrote:
    Hmmm!

    In the debug window put in "nWeather_DeBug" and set it to 1. Then open diagnostics and run the code. I believe button # 1 in the GUI is "Last Updated >" or at least that's where mine is hidden will manual run the update process.

    When you push the update button take a look at the send_string 0 strings the module puts out. My thinking is that you're not resolving the DNS and you will have to set this to your router or gateway address in Diagnostics>Network Addresses. If you were just using your own values I would say that you have some bad values but using the default should work w/o problems. Are you running TimeManager? If that's working then your DNS is fine?

    Set the debug flag and see what you get? Post a copy of the diagnostics.

    Vining, setting the DNS to my router IP address solve the problem. I'll play a little bit more tomorrow and let you Know. Thanks.
  • flcusatflcusat Posts: 309
    OK, here are the results that I've found so far. As I said before changing he DNS to my router IP address( it was 10.10.1.1) solve the connectivity problem and now I'm receiving data with your parameters. I changed the parameters to my city's parameters which are:

    'US'
    '12086'
    'FL'
    'FLZ074'
    'Miami'
    '33184'

    I compiled it and sent it to the master and still getting the data like the Norwalk parameters were in. Doing what Dave suggested regarding the city in blank didn't help either. I also compare the data in the TP with what is showing at RSSWeather.com and for some reason the Heat Index is not updating when I have the Norwalk parameters in.

    Here is what the diagnostics showed when I ran debug with "nWeather_DeBug" as you suggested:
    Line      1 :: Time 06:58:11 - Updating RSS Weather! From: *-Button_Event-* line <620>$0D$0A - 06:57:24
    Line      2 :: Connected Successfully - 06:57:24
    Line      3 :: CIpEvent::OnLine 0:4:1 - 06:57:24
    Line      4 :: RSS Connected! line-<632>$0D$0A - 06:57:24
    Line      5 :: RSS Get Request Sent! line-<650>$0D$0A - 06:57:24
    Line      6 :: RSS captured:6360 bytes from server! line-<800> - 06:57:24
    Line      7 :: RSS captured data sent to parser! line-<801> - 06:57:24
    Line      8 :: RSS - PARSING COMPLETE! - Received & parsed 18 of a possible 20 values! line-<450>$0D$0A - 06:57:24
    Line      9 :: Exiting TCP Read thread - closing this socket for local port 4 - 06:57:30
    Line     10 :: CIpEvent::OffLine 0:4:1 - 06:57:30
    Line     11 :: RSS server disconnected! line-<811> - 06:57:30
    
    

    I didn't have a hidden button in the panel for the manual update, so probably the version I downloaded from here is slightly different than the one you are referring to. The one that I have is the one you posted in this thread in May 29( three above this one).

    Also from where are you getting the Radar's information?
  • viningvining Posts: 4,368
    Did you re-compile the Main.axs or the module and resend? The only reason the module would need to be re-compiled is if you change the refresh rate, which should really stay where as is. Once you make changes for location data save the INCLUDE file or if you pasted it into your main like you did just re-compile the MAIN.axs and transfer. If you're sending the updated compiled MASTER file it can't show Norwalk data unless Norwalk data is what was put in the location data fields. If the data put into the fields isn't any good when the module runs you just won't get any data returned.
  • flcusatflcusat Posts: 309
    vining wrote:
    Did you re-compile the Main.axs or the module and resend? The only reason the module would need to be re-compiled is if you change the refresh rate, which should really stay where as is. Once you make changes for location data save the INCLUDE file or if you pasted it into your main like you did just re-compile the MAIN.axs and transfer. If you're sending the updated compiled MASTER file it can't show Norwalk data unless Norwalk data is what was put in the location data fields. If the data put into the fields isn't any good when the module runs you just won't get any data returned.

    That's the weird thing. I recompiled the Main.axs. I didn't change anything in the module and still getting the Norwalk data with the Miami parameters.

    Here is how the Main.axs looks with the Miami parameters
  • viningvining Posts: 4,368
    Are you sure you're transferring the most recent file? I would try going to transfer file>remove all and then reselect.
  • flcusatflcusat Posts: 309
    vining wrote:
    Are you sure you're transferring the most recent file? I would try going to transfer file>remove all and then reselect.

    Vining I've done that a trillion of times already. At this point I don't have a clue of what it is going on. I even create a new workspace with a new main.axs that have the included declared and not paste like before with the Miami parameters and still getting the Norwalk data.
    Here is the new workspace
  • viningvining Posts: 4,368
    Well, after you made the changes to the include file did you save the file. Go to the workspace file tree and go to includes>VAV_Weather_Settings and right click > file properties and make sure you have the correct file and file path. I 'd even remove the file from system and then do an add existing include file again. See if it's the same file with Miami data in it.

    It's has to be something very simple with the files.
  • flcusatflcusat Posts: 309
    Vining, Thanks for all your help. After the 5th trillions of time(I don't know ho many hours I had put into this) I got it to work. I deleted the #INCLUDE 'VAV_Weather_Settings' line in the main.axs compiled and included again and it worked, go figure. But still the Heat Index is not getting updated neither with my parameters or yours so it has to be something with the code. Could you confirm this please? Next step is put time manager to work. Not big deal for you seasoned guys but I'm a newbie trying to learn as much as I can in the weekends, since during the weekdays is almost impossible although trying to do so in the weekends and expend time with the wife and kids is really hard too.
  • flcusatflcusat Posts: 309
    On a side note I had to increase the description field from 30 to 50 due to our weather today:Cumulonimbus Clouds Observed 83°F.
  • flcusatflcusat Posts: 309
    Also, I had to increase the forecast title from 30 to 40 because it was truncated when displayed "Forecast for the rest of this afternoon". The Heat Index is still no showing any value and according to the module if it were not receiving a value from the string, should be showing N/A. This whole thing is way over my programming skills so I can't figure out what it is going on.
    Sometimes there are some discrepancies between the values showing in the panel and the values showing at RSSWeather.com but it looks like the values showing at the web site are retrieve from the server every certain amount of time and the values displayed are not the most current even if you refresh the page.
  • viningvining Posts: 4,368
    The RSS feed is slightly different from the PHP page you see when going to the site.
    The URL below is for "Content Encoded" but you can also select plain text or XHTML.

    I often thought it would be nice just to parse the HTML (PHP) so we could get more icons but that's far down on the list.

    I'd run your code but I'm presently only running a partial program since I killed my NI-4000 and then killed my back up NI-4000.

    check you values to the values in this URL for zip, county code and zone and then compare the returns to what you see when go to this web page.

    You can also try what Dave recommended a while back and just input the zip code. All other values should be just a pair of single quote no space ''. Go back and find his thread and verify this.

    This is the html equivalent of what the module is getting an parsing. I think! It's been a while.
    http://www.rssweather.com/rss.php?hwvUT=F&hwvUP=in&hwvUS=mph&hwvUV=mi&hwvCCChange=forecast&hwvSF=Y&maxdays=3&daysonly=2&hwvStyle=ce&place=miami&state=fl&zipcode=33184&country=us&county=12086&zone=FLZ074&alt=rss20a
    
Sign In or Register to comment.