Yahoo weather and basic HTTP ?'s

def90def90 Junior MemberPosts: 14
I'm trying to set up my own Weather module and learn a little bit about HTTP programming at the same time. So far I am trying to use the following sites:

http://xoap.weather.com/weather/local/80301?cc=*&dayf=10

http://weather.yahooapis.com/forecastrss?p=80301

Basically I am tacking online/offline with a variable and sending an IP_Client_Open command if needed, then a GET command. I have tried various strings with the GET command and can't seem to get any incommin strings from the web sites.

For reference:
http://developer.yahoo.com/weather/

If I am using http://weather.yahooapis.com/forecastrss?p=80301 I am thinking weather.yahooapis.com should be in the IP_CLIENT_OPEN command and the GET string should be: /forecastrss?p=80301 I have also tried weather.yahooapis.com/forecastrss?p=80301 for the GET string..

I have tried many variations of:

IF(CONNECTED=0) IP_CLIENT_OPEN(dvIP_WEATHER.Port,'http://weather.yahooapis.com',80,1)

WAIT_UNTIL(CONNECTED=1){
SEND_STRING dvIP_WEATHER,"
'GET /forecastrss?p=80301 HTTP/1.1',13,10,
'HOST: [url]http://weather.yahooapis.com',13,10[/url],
13,10"}

I have tried it with and without the extra HTTP/1.1 and Host parameters as well.

Does anyone have any good lay person reading on the HTTP and HOST portions of the GET command syntax or a basic explanation of what is needed for this and why?

Thanks..

Comments

  • Joe HebertJoe Hebert Junior Member Posts: 2,154
    def90 wrote:
    Does anyone have any good lay person reading on the HTTP and HOST portions of the GET command syntax or a basic explanation of what is needed for this and why?
    Everything you ever wanted to know about the web can be found here:

    http://www.w3.org/

    Here is a link to the HTTP standard:

    http://www.w3.org/Protocols/rfc2616/rfc2616.html

    def90 wrote:
    HOST: should not include the http:// prefix

    HTH
  • filpeefilpee Junior Member Posts: 64
    If your new (or old) to http requests then do yourself a favor and grab yourself a copy of wireshark (formerly ethereal) over at http://www.wireshark.org/

    It will show you what your pc is sending/receiving over the lan cable so you will be able to see exactly how your requests are being handled.

    It can be a bit daunting so you may prefer the easier to read LiveHTTPHeaders plugin for firefox.
    http://livehttpheaders.mozdev.org/


    using your example of sending a GET request to http://weather.yahooapis.com/forecastrss?p=80301 I can see that my browser is sending the data
    GET /forecastrss?p=80301 HTTP/1.1
    Host: weather.yahooapis.com
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14
    Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 300
    Connection: keep-alive
    
  • viningvining X Member Posts: 4,348
    RSSWeather.com is also a good source for a consistant return. I've been using it for years and so far it only required one modification. I would offer you the code but I don't want to rob you of the chance to try this on your own.

    Here's a link to a recent post that has a module that uses HTTP that you can use as an aid or reference.

    http://www.amxforums.com/showthread.php?p=25830#post25830

    Read the references that Joe suggested and filpee's suggestion to use WireShark is a must to determine the dialogue that is required. It allows you to see what you need to send and let's you see what you should recieve when you connect from your PC.
  • def90def90 Junior Member Posts: 14
    vining wrote: »
    RSSWeather.com is also a good source for a consistant return. I've been using it for years and so far it only required one modification. I would offer you the code but I don't want to rob you of the chance to try this on your own.

    I think I allready have a copy of what you posted here.. But what fun would that be? I find that I retain and understand this stuff alot better if I struggle through something and figure it out rather than cut and paste.. :)

    I did come up with a program that updates a DYNDNS account through dyndns.org using some tips I picked up here and tried converting what I was doing with that to the weather sites with no luck..

    filpee, I'll check out the tools you linked too..
  • a_riot42a_riot42 AMX Wizard Posts: 1,619
    I have wondered about this myself, but questioned the usefulness of online weather services indexed by zip code. I don't know about where you live, but here in Seattle the weather would have to be indexed by street address to be useful :) I have used the weather stations though, and thought they were pretty cool and reasonably accurate with updates every few seconds if needed and don't require internet access.
    Paul
  • def90def90 Junior Member Posts: 14
    a_riot42 wrote: »
    I have wondered about this myself, but questioned the usefulness of online weather services indexed by zip code. I don't know about where you live, but here in Seattle the weather would have to be indexed by street address to be useful :) I have used the weather stations though, and thought they were pretty cool and reasonably accurate with updates every few seconds if needed and don't require internet access.
    Paul


    I agree completely but people are asking for it. They are asking for yahoo, apple and google style widgets for their touchscreens and until AMX has a built in browser or easy way to do it I have to come up with something.. People are even showing me pictures of ads for Savant wondering why their panels can't do this, I of course let them know that Savant is complete vaporware but that is beside the point. People have it on their computers and phones and they want it on their panels..
  • a_riot42a_riot42 AMX Wizard Posts: 1,619
    Wow. Your customers are far more sophisicated than mine. I still have to tell my clients they don't have to point the touch panel at the TV to make it work.
    Paul
  • viningvining X Member Posts: 4,348
    def90 wrote:
    People have it on their computers and phones and they want it on their panels..
    For the price they pay for these things it's no wonder why they think it should be capable of the same things a pocket PC or iPhone can do. I think because there's no demand on the commerical/corporate side of the business for these types of capabilities AMX doesn't feel they are all that important. It does make it hard to explain to customers why AMX is better when all they see is the front end of the system, what it can't do compared it's compettion and don't really care and/or can't possibly understand how much better the back end with our customized programs, especially at the initial sales pitch stage.
  • jjamesjjames AMX Sustaining Engineer Posts: 2,898
    I'm actually surprised people *request* it. I've yet to run into a client who wants their whole-house controller to display info that they can easily get by tuning to The Weather Channel. We supply it and when we point it out, they just say, "oh, neat" and could really care less.

    You all must have more tech savy clients . . . ours just want stuff to turn on and off. *sigh*
  • ericmedleyericmedley Senior Member - 3709 Posts Posts: 4,157
    jjames wrote: »
    I'm actually surprised people *request* it. I've yet to run into a client who wants their whole-house controller to display info that they can easily get by tuning to The Weather Channel. We supply it and when we point it out, they just say, "oh, neat" and could really care less.

    You all must have more tech savy clients . . . ours just want stuff to turn on and off. *sigh*

    Our clients love those kinds of things. My most favorite features: Weather, Multi-zone kitchen timer, mini-emailer,

    I actually get my weather feed via telnet from weatherunderground. We also have several cleints who paid for the AMX i!-Weather.
  • DHawthorneDHawthorne Junior Member Posts: 4,584
    I was using Vining's RSSWeather happily for a long time, but they made a change that completely killed it for me: you can only update from the feed once an hour, no matter what location's weather you are looking for. This ruined the ability to check the weather in various places without waiting an hour between checks, and that was a big selling point to my customers.

    So I switched to the Weatherbug feed. They have a published API ... though it's not entirely complete nor entirely accurate. They don't give as much data as RSSWeather, but neither do they have the restrictions. I have a working module that was loosely built off Vining's, including a "lite" interface for such devices as the R4, where you can strip off what you don't need. I don't have it in much of a form that could be easily shared right now, but if people are interested, I can put something together.
  • jjamesjjames AMX Sustaining Engineer Posts: 2,898
    I've stuck with The Weather Channel's XML feed. Pretty easy to parse, and it's been working for quite a while now.
  • def90def90 Junior Member Posts: 14
    DHawthorne wrote: »
    So I switched to the Weatherbug feed. They have a published API ... though it's not entirely complete nor entirely accurate.

    That's a great find, I don't know why my searches weren't picking up that site.. Just downloaded the API, looks simple, what is not accurate about it? Thanks..
  • viningvining X Member Posts: 4,348
    DHawthorne wrote:
    I was using Vining's RSSWeather happily for a long time, but they made a change that completely killed it for me: you can only update from the feed once an hour,
    I was thinking this morning that if you parse out the cookie and pass it back in additional GET requests you may be able to do multiple locations during a single session. I was going to play with it a bit to see it this would work but ran out of time. I'll let you know if I have any luck when I get a chance to play with it some more.
  • DHawthorneDHawthorne Junior Member Posts: 4,584
    def90 wrote: »
    That's a great find, I don't know why my searches weren't picking up that site.. Just downloaded the API, looks simple, what is not accurate about it? Thanks..

    Some of the parameters to the GET command are completely ignored, and others, if you include them, will cause the whole thing to return data from Arlington VA ... no matter what you were really asking for. My workaround was to only submit a zip code for US locations. For international stations, just the country code (and you have to use theirs, which are decidedly non-standard) and city name. In all cases, the actual local station you get will be the closest match to what area you asked for with the most current data ... and it may change on a day to day basis.
  • def90def90 Junior Member Posts: 14
    I have allready noticed that some of the commands in their api guide are slightly different than what is posted on their online help guide. Each command seems to work though.

    I figured out my initial problem of not receiving info back from the web, I was using port 1 (0:1:0) and managed to look at it for hours before my brain told me that was the problem..

    Do you guys prefer specifying a port or using the First_Local_Port command?
  • Spire_JeffSpire_Jeff Formerly Caffeinated Programmer Posts: 1,917
    FIRST_LOCAL_PORT is just the constant 2 as I recall. It does not perform any magic to give you a unique port for each instance. Also, the compiler does not like it when you try to declare a device with FIRST_LOCAL_PORT+x, so I just use numbers and try to avoid duplication.

    Jeff
  • viningvining X Member Posts: 4,348
    def90 wrote:
    Do you guys prefer specifying a port or using the First_Local_Port command?
    FIRST_LOCAL_PORT is a constant defined in NETLINX.axi and has no use what so ever. Forget it even exists.

    from NETLINX.axi (C:\Program Files\Common Files\AMXShare\AXIs)

    DEFINE_CONSTANT
    (*-- NetLinx.axi version
    *)
    CHAR NETLINX_AXI_VERSION[6] = '1.42'
    (*-- URL Constants
    *)
    CHAR URL_Flg_TCP = 1; // TCP connection
    CHAR URL_Flg_AcctInfoPresent = $02; // Added v1.21 - If set, the User and Password fields are valid
    CHAR URL_Flg_Temp = $10; // Temp Connection
    CHAR URL_Flg_Stat_PrgNetLinx = $20; // URL set by NetLinx Set_URL_List
    CHAR URL_Flg_Stat_Mask = $C0; // status mask upper 2 bits
    CHAR URL_Flg_Stat_Lookup = $00; // Looking up IP
    CHAR URL_Flg_Stat_Connecting = $40; // connecting
    CHAR URL_Flg_Stat_Waiting = $80; // waiting
    CHAR URL_Flg_Stat_Connected = $C0; // connected
    (*-- IP Address Flag Constants
    *)
    CHAR IP_Addr_Flg_DHCP = 1; // Use DHCP
    (*-- for user
    *)
    INTEGER FIRST_VIRTUAL_DEVICE = 32768;
    INTEGER FIRST_LOCAL_PORT = 2;
  • def90def90 Junior Member Posts: 14
    Yeah, I typically set specific ports for iP controlled EQ but I see alot of manufacturers modules out there that use FIRST_LOCAL_PORT+1 and so on..

    I was just wondering if there was any advantage to using it, I seem to remember having a problem with a module that used this once until I set it to a specific port..
  • viningvining X Member Posts: 4,348
    def90 wrote:
    I was just wondering if there was any advantage to using it, I seem to remember having a problem with a module that used this once until I set it to a specific port..
    Let me try this again!

    FIRST_LOCAL_PORT is a constant defined in NETLINX.axi and has no use what so ever. Forget it even exists.

    So, no there is no advantage. I use numbers only and define all devices in one location in my main file and use multuple DEFINE_DEVICE sections to keep it organized and easily searched. I'll then reference these device in .axi files where I pass them to modules or what ever.
  • def90def90 Junior Member Posts: 14
    I know what it does, and I currently do what you do, I define everything with a specific number, I was just wondering why any one would choose to use it..
Sign In or Register to comment.