| Author |
|
TonyNo Moderator Group


Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2619
|
| Posted: August 05 2006 at 11:01 | IP Logged
|
|
|
I've updated this to use the smaller, mobile version of WeatherUnderground...
Linky
Remember to change the ZIP code!
Peter, your link should be "mobile.wunderground.com/global/stations/06370.html".
|
| Back to Top |
|
| |
krommetje Super User


Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 511
|
| Posted: August 05 2006 at 14:12 | IP Logged
|
|
|
So i'd have to add 4 new GV's?
CURTEMP
CURWINDCHILL
CURHUMIDITY
CURFORECAST
Is that right?
Peter
|
| Back to Top |
|
| |
TonyNo Moderator Group


Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2619
|
| Posted: August 05 2006 at 15:05 | IP Logged
|
|
|
Oops! I assumed too much!
Yes, you have it covered.
Also, if you want temps in C, change...
Code:
| ph_regexsnap("<tr><td>Temperature</td>~255 <b>\(.+\)</b>°F"," [LOCAL1]",1,0) |
|
|
to
Code:
| ph_regexsnap("<tr><td>Temperature</td>~255 </span>~255<b>\(.+\)</b>°C"," [LOCAL1]",1,0) |
|
|
I have no windchill in my current page, so I can't alter that yet!
Note that the forum has added spaces and changed "& # 1 7 6 ;" to "°".
|
| Back to Top |
|
| |
krommetje Super User


Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 511
|
| Posted: August 05 2006 at 17:00 | IP Logged
|
|
|
I will import it as soon as possible.. (see PM)
Could you give it another name? I am getting a synthax error 37000 when importing the current one.. somthing to do with a name not being unique... say importweather or wunderground.sql or something?
Peter
|
| Back to Top |
|
| |
TonyNo Moderator Group


Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2619
|
| Posted: August 05 2006 at 20:20 | IP Logged
|
|
|
Renamed version (getweather2.sql):
Linky 2
|
| Back to Top |
|
| |
krommetje Super User


Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 511
|
| Posted: August 06 2006 at 01:32 | IP Logged
|
|
|
Working!!!
I have created a macro which converts Fahrenheit to Celcius which is run after the macro Getweather is run and stores it in another GV... Here is the SQL:
insert into macroheader values ('FTOC','FTOC',0,0,1);
insert into macrodetail values ('FTOC',1,10,'TIJDELIJK',NULL,'DOUBLE(ABS(DEC("{CURTEMP}"))) -32',0,'');
insert into macrodetail values ('FTOC',2,10,'CURTEMPA',NULL,'DOUBLE(ABS(DEC("{TIJDELIJK}")) )* 0.555',0,'');
it needs a GV called TIJDELIJK and CURTEMPA
I could narrow it down into one sinlgle formula but this was more clear to me... I kept on running into this dreaded ! when I wanted to multiply after substraction ...
Peter
Edited by krommetje - August 06 2006 at 04:59
|
| Back to Top |
|
| |
TonyNo Moderator Group


Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2619
|
| Posted: August 06 2006 at 10:37 | IP Logged
|
|
|
Good to hear.
You could just do this...
Set Global | CURTEMPA | string( 5/9*({CURTEMP}-32), "##.#")
|
| Back to Top |
|
| |
krommetje Super User


Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 511
|
| Posted: August 06 2006 at 12:08 | IP Logged
|
|
|
Well, that sinks into my shoes!!!
Thanks...
by the way: the GV's used by the macro are not numeric, so I can't update a virtual X10 module with it... I forgot how we did that with the old macro...
Peter
|
| Back to Top |
|
| |
TonyNo Moderator Group


Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2619
|
| Posted: August 06 2006 at 13:46 | IP Logged
|
|
|
Ah, I think you mean integers (no decimal)? If so, just change it to this...
Set Global | CURTEMPA | int(5/9*({CURTEMP}-32))
|
| Back to Top |
|
| |
Tomcat7194 Newbie

Joined: November 05 2006
Online Status: Offline Posts: 24
|
| Posted: November 05 2006 at 16:14 | IP Logged
|
|
|
Hey, great script. If I wanted to get more values from that page (like pressure, etc.), how would I go about modifying the script?
I'm kind of a newb, but it would be great to be able to get some more weather info from that page.
Thanks
Tom
|
| Back to Top |
|
| |
TonyNo Moderator Group


Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2619
|
| Posted: November 05 2006 at 18:45 | IP Logged
|
|
|
Thanks!
For getting pressure (or any other bit), you would first find the description in the code then pick out the value.
Looking at the code, the Pressure segment looks like this...
Code:
<tr><td>Pressure</td>
<td>
<span class="nowrap"><b>30.25</b> in</span& gt; |
|
|
I would grab it using a RegEx Diff to first locate the value by finding something close then surrounding the value (assuming you created a new Global called CurPress)...
Code:
| Set Global | CurPress | ph_regexdiff("Pressure</td>~255<b>","</b>" ,"[LOCAL1]",1,0) |
|
|
This first looks for "Pressure</td>", followed by anything (~255), followed by <b>. This is the start of our value. Next, we tell it where to stop grabbing (</b>). What is in between is our data (30.25).
You could then do the same for other data that you wanted to "scrape".
|
| Back to Top |
|
| |
illiath Newbie

Joined: December 02 2006 Location: United States
Online Status: Offline Posts: 1
|
| Posted: December 12 2006 at 20:33 | IP Logged
|
|
|
For anyone interested, here is a version updated to return both the F and the C temperature details...
Mostly I coded this modification as my husband and I are both used to different temperature standards, he's an american, and I'm an aussie, so things get confusing at times, this way both data is collected...
Code:
insert into macroheader values ('GET WEATHER','GET WEATHER DATA',0,0,1);
insert into macrodetail values ('GET WEATHER',1,16,'',NULL,'if( {INTERNET FLAG}=0, 999, 1)',0,'');
insert into macrodetail values ('GET WEATHER',3,15,'[LOCAL1]',NULL,'ph_readfile ( "C:\Program Files\powerhome\wum.htm" )',1,'');
insert into macrodetail values ('GET WEATHER',5,24,'No TTS',1,'[LOCAL1]',1,'');
insert into macrodetail values ('GET WEATHER',7,15,'[LOCAL3] ',NULL,'ph_regexsnap(''<tr><td>Temperature</t d>~255<b>\(.+\)</b>°F''," [LOCAL1]",1,0)',0,'');
insert into macrodetail values ('GET WEATHER',9,16,'',NULL,'if( "[LOCAL3]" = "{CURTEMP_F}", 2, 1)',0,'');
insert into macrodetail values ('GET WEATHER',11,15,'[LOCAL3] ',NULL,'ph_regexsnap(''<tr><td>Temperature</t d>~255<b>\(.+\)</b>°C''," [LOCAL1]",1,0)',0,'');
insert into macrodetail values ('GET WEATHER',13,16,'',NULL,'if( "[LOCAL3]" = "{CURTEMP_C}", 2, 1)',0,'');
insert into macrodetail values ('GET WEATHER',15,15,'[LOCAL4]',NULL,'"The temperature is " + "{CURTEMP_F}" + "F / "+ "{CURTEMP_C}" + "C degrees"',0,'');
insert into macrodetail values ('GET WEATHER',17,15,'[LOCAL3] ',NULL,'ph_regexdiff(">Windchill:</td>~255<nobr& gt;<b>","</b>","[LOCAL1]",1,0)',0,'');
insert into macrodetail values ('GET WEATHER',19,10,'CURWINDCHILL',NULL,'"[LOCAL3]"',0,'');
insert into macrodetail values ('GET WEATHER',21,15,'[LOCAL3] ',NULL,'ph_regexdiff("Humidity</td>~255<td><b >","</b></td></tr>"," [LOCAL1]",1,0)',0,'');
insert into macrodetail values ('GET WEATHER',23,10,'CURHUMIDITY',NULL,'"[LOCAL3]"',0,'');
insert into macrodetail values ('GET WEATHER',25,16,'',NULL,'if( "[LOCAL4]" = "{TEMP STR}", 2, 1)',0,'');
insert into macrodetail values ('GET WEATHER',26,10,'TEMP STR',NULL,'"[LOCAL4]"',0,'');
insert into macrodetail values ('GET WEATHER',27,15,'[LOCAL4]',NULL,'ph_regexdiff(''<b>Forecast as of~255</b><br />'',''</td></tr>'',"[LOCAL1]",1,0)',0,'');
insert into macrodetail values ('GET WEATHER',28,16,'',NULL,'if( "[LOCAL4]" = "{CURFORECAST}", 2, 1)',0,'');
insert into macrodetail values ('GET WEATHER',29,10,'CURFORECAST',NULL,'"[LOCAL4]"',0,'');
insert into macrodetail values ('GET WEATHER',30,16,'',NULL,'999',0,'');
insert into macrodetail values ('GET WEATHER',31,26,'',NULL,'"ERROR"',0,'');
insert into macrodetail values ('GET WEATHER',32,10,'CURFORECAST',NULL,'"Problem getting forecast."',0,'');
insert into macrodetail values ('GET WEATHER',2,15,'[LOCAL1]',NULL,'ph_geturl( "mobile.wunderground.com/cgi-bin/findweather/getForecast?bra nd=mobile&query=94085")',0,'');
insert into macrodetail values ('GET WEATHER',4,38,'',1,'ph_writefile ( "C:\Program Files\powerhome\wum.htm", 1, "[LOCAL1]" )',1,'');
insert into macrodetail values ('GET WEATHER',6,27,'',NULL,'if( left( "[LOCAL1]", 12 ) = "HTTP/1.1 404", "ERROR", "")',0,'');
insert into macrodetail values ('GET WEATHER',8,36,'',NULL,'"Current Temp is "+ "[LOCAL3]" + "F"',0,'');
insert into macrodetail values ('GET WEATHER',10,10,'CURTEMP_F',NULL,'"[LOCAL3]"',0,'');
insert into macrodetail values ('GET WEATHER',12,36,'',NULL,'"Current Temp is " + "[LOCAL3]" + "C"',0,'');
insert into macrodetail values ('GET WEATHER',14,10,'CURTEMP_C',NULL,'"[LOCAL3]"',0,'');
insert into macrodetail values ('GET WEATHER',16,16,'',NULL,'if( posw( "[LOCAL1]", "Windchill:") = 0, 5, 1)',0,'');
insert into macrodetail values ('GET WEATHER',18,16,'',NULL,'if( "[LOCAL3]" = "{CURWINDCHILL}", 2, 1)',0,'');
insert into macrodetail values ('GET WEATHER',20,15,'[LOCAL4]',NULL,'"[LOCAL4]" + ", with a windchill of " + "{CURWINDCHILL}" + ", "',0,'');
insert into macrodetail values ('GET WEATHER',22,16,'',NULL,'if( "[LOCAL3]" = "{CURHUMIDITY}", 2, 1)',0,'');
insert into macrodetail values ('GET WEATHER',24,15,'[LOCAL4]',NULL,'"[LOCAL4]" + " and the humidity is " + "{CURHUMIDITY}" + "."',0,'');
|
|
|
|
| Back to Top |
|
| |
TonyNo Moderator Group


Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2619
|
| Posted: December 12 2006 at 23:23 | IP Logged
|
|
|
Welcome to PowerHome and good job!
|
| Back to Top |
|
| |
|
|