Author |
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
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: 695
|
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: 2889
|
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: 695
|
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: 2889
|
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: 695
|
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: 2889
|
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: 695
|
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: 2889
|
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: 2889
|
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: 2889
|
Posted: December 12 2006 at 23:23 | IP Logged
|
|
|
Welcome to PowerHome and good job!
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: October 13 2012 at 13:20 | IP Logged
|
|
|
Hey TonyNo,
could you whipup an update for 2.14?
Peter
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: October 14 2012 at 11:19 | IP Logged
|
|
|
It needs an update?
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: October 14 2012 at 11:33 | IP Logged
|
|
|
Yeah, mine doesn't work anymore since early this summer. Could you look into it?
I reside near Eindhoven or Helmond in the Netherlands....
Edited by krommetje - October 14 2012 at 11:34
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: October 28 2012 at 07:08 | IP Logged
|
|
|
Bumping Tonyno....
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: October 28 2012 at 12:21 | IP Logged
|
|
|
Peter,
Just wanted to see if you wanted to try something new.
Beta 2.1.4 includes a new URLScraper plugin which is designed for exactly this type of task. The default urlscraper.ini file has even been preconfigured for some of the values from weatherunderground. I went ahead and also made a special configuration for your location.
The great thing about the plugin is that it runs in the background in its own thread and doesnt require a macro to maintain.
If you'd like to try this, open the PH Explorer and navigate to PowerHome|Setup|Plugins. On a blank line, give it an ID of WEATHER. Set the Launch data to PH_URLScraper.phurlscraper. Set the Initialization data to c:\powerhome\plugins\urlscraper.ini.
Copy and paste this data into your urlscraper.ini file:
Code:
[config]
urlcount=1
[URL_1]
url=http://www.wund.com/cgi-bin/findweather/getForecast?quer y=Eindhoven
freq=0.5
scrapecount=2
[URL_1_1]
regexsearch=<div id="main">[\s\S]*?<span>(.+)</span>[\s\S]*?<h4>(.+)</h4>[\s\S]*?<label>Wind:</label>[\s\S]*?<span>[\s\S]*?<span>(.+)</span>[\s\S]*?from[\s\S]*?<span>(.+)</span>[\s\S]*?<label>Dew Point:</label>[\s\S]*?<span>(.+)</span>
regexoccur=1
regexflags=0
[URL_1_2]
regexsearch=<label>Pressure:</label>[\s\S]*?<b>(.+)</b>[\s\S]*?<label>Windchill:</label>[\s\S]*?<span>(.+)</span>[\s\S]*?<label>Humidity:</label>[\s\S]*?<div class="b">(.+)</div>[\s\S]*?<label>Visibility:</label>[\s\S]*?<span>(.+)</span>
regexoccur=1
regexflags=0
|
|
|
I'll also email the file to you in case the board screws up the formatting.
Create two new generic plugin triggers. You can give them ID's of WEATHER1 and WEATHER2. Set the Trigger ID number to "Command 1" for both and the Trigger Value to "Option 1" for WEATHER1 and "Option 2" for WEATHER2.
When the WEATHER1 trigger fires, the temperature will be in LOCAL1, the condition in LOCAL2, the windspeed in LOCAL3, the wind direction in LOCAL4, and the dewpoint in LOCAL5.
When the WEATHER2 trigger fires, the pressure will be in LOCAL1, the windchill in LOCAL2, the humidity in LOCAL3, and the visibility in LOCAL4.
Give it a whirl.
Dave.
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: November 02 2012 at 17:41 | IP Logged
|
|
|
Interesting. I need to get current. ;)
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: November 02 2012 at 20:47 | IP Logged
|
|
|
Don't know if it makes any difference but for what it's worth my old Get Weather works fine for me. Beware of forum blanks..
insert into macroheader values ('GET_WEATHER','GET WEATHER',0,0,1);
insert into macrodetail values ('GET_WEATHER',1,27,'',NULL,'IF (ph_getglobal_s("CURFORECAST")= "", "NOP", "START")',0,'','');
insert into macrodetail values ('GET_WEATHER',2,38,'',0,'ph_setvar_s(2,1,ph_getglobal_s("CU RTEMP")) + ph_setglobal_s("CURTEMP","1") + IF (ph_getglobal_s("CURTEMP") ="1", ph_setglobal_s("CURTEMP",ph_getvar_s(2,1)), ph_createglobal("CURTEMP","") )',0,'','');
insert into macrodetail values ('GET_WEATHER',3,38,'',0,'ph_setvar_s(2,1,ph_getglobal_s("CU RWINDCHILL")) + ph_setglobal_s("CURWINDCHILL","1") + IF (ph_getglobal_s("CURWINDCHILL") ="1", ph_setglobal_s("CURWINDCHILL",ph_getvar_s(2,1)), ph_createglobal("CURWINDCHILL","") )',0,'','');
insert into macrodetail values ('GET_WEATHER',4,38,'',0,'ph_setvar_s(2,1,ph_getglobal_s("CU RHUMIDITY")) + ph_setglobal_s("CURHUMIDITY","1") + IF (ph_getglobal_s("CURHUMIDITY") ="1", ph_setglobal_s("CURHUMIDITY",ph_getvar_s(2,1)), ph_createglobal("CURHUMIDITY","") )',0,'','');
insert into macrodetail values ('GET_WEATHER',5,38,'',0,'ph_setvar_s(2,1,ph_getglobal_s("CU RFORECAST")) + ph_setglobal_s("CURFORECAST","1") + IF (ph_getglobal_s("CURFORECAST") ="1", ph_setglobal_s("CURFORECAST",ph_getvar_s(2,1)), ph_createglobal("CURFORECAST","") )',0,'','');
insert into macrodetail values ('GET_WEATHER',6,26,'',NULL,'START',0,'','');
insert into macrodetail values ('GET_WEATHER',7,37,'',NULL,'******************************* ********************************',0,'','');
insert into macrodetail values ('GET_WEATHER',8,37,'',NULL,'**** MUST ENTER YOUR ZIP IN NEXT LINE *************',0,'','');
insert into macrodetail values ('GET_WEATHER',9,15,'[LOCAL5]',NULL,'ph_geturl( "mobile.wunderground.com/cgi-bin/findweather/getForecast?bra nd=mobile&query=32561")',0,'','');
insert into macrodetail values ('GET_WEATHER',10,37,'',NULL,'****************** TESTING ONLY ******************',0,'','');
insert into macrodetail values ('GET_WEATHER',11,38,'',0,'ph_writefile("C:\PH\WEATHER\GET_W EATHER.TXT",9,ph_getvar_s(1,5))',1,'','');
insert into macrodetail values ('GET_WEATHER',12,38,'',0,'ph_setvar_s(1,5,ph_READfile("C:\P H\WEATHER\GET_WEATHER.TXT"))',1,'','');
insert into macrodetail values ('GET_WEATHER',13,37,'',NULL,'****************************** ****************************',0,'','');
insert into macrodetail values ('GET_WEATHER',14,15,'[LOCAL1] ',NULL,'posw(ph_getvar_s(1,5),"<tr><td>Temperatu re</td>",1)',0,'','');
insert into macrodetail values ('GET_WEATHER',15,15,'[LOCAL1] ',NULL,'posw(ph_getvar_s(1,5),"<b>",ph_getvar_n(1,1))' ,0,'','');
insert into macrodetail values ('GET_WEATHER',16,15,'[LOCAL9] ',NULL,'posw(ph_getvar_s(1,5),"</b>",ph_getvar_n(1,1)) ',0,'','');
insert into macrodetail values ('GET_WEATHER',17,10,'CURTEMP',NULL,'mid(ph_getvar_s(1,5),ph _getvar_n(1,1)+3,ph_getvar_n(1,9)-ph_getvar_n(1,1)-3)',0,'', '');
insert into macrodetail values ('GET_WEATHER',18,15,'[LOCAL4]',NULL,'"The temperature is " + "{CURTEMP}" + " degrees"',0,'','');
insert into macrodetail values ('GET_WEATHER',19,27,'',NULL,'if (posw("[LOCAL5]", "Windchill") = 0, "BYPASS_WC","NOP")',0,'','');
insert into macrodetail values ('GET_WEATHER',20,10,'CURWINDCHILL',NULL,'ph_regexdiff("> Windchill</td>~255<b>","</b>"," [LOCAL5]",1,0)',0,'','');
insert into macrodetail values ('GET_WEATHER',21,15,'[LOCAL4]',NULL,'"[LOCAL4]" + ", with a windchill of " + "{CURWINDCHILL}" + " degrees, "',0,'','');
insert into macrodetail values ('GET_WEATHER',22,26,'',NULL,'BYPASS_WC',0,'','');
insert into macrodetail values ('GET_WEATHER',23,15,'[LOCAL3] ',NULL,'ph_regexdiff("Humidity</td>~255<td><b >","</b></td></tr>"," [LOCAL5]",1,0)',0,'','');
insert into macrodetail values ('GET_WEATHER',24,10,'CURHUMIDITY',NULL,'"[LOCAL3]"',0,'','');
insert into macrodetail values ('GET_WEATHER',25,37,'',NULL,'*************** ESTIMATED ****************************',0,'','');
insert into macrodetail values ('GET_WEATHER',26,38,'',0,'IF ("{CURHUMIDITY}" = "255%", ph_setglobal_s("CURHUMIDITY" ,"around " + RAND(100) + "%"), 0)',0,'','');
insert into macrodetail values ('GET_WEATHER',27,37,'',NULL,'****************************** *****************************',0,'','');
insert into macrodetail values ('GET_WEATHER',28,15,'[LOCAL4]',NULL,'"[LOCAL4]" + " and the humidity is " + "{CURHUMIDITY}" + "."',0,'','');
insert into macrodetail values ('GET_WEATHER',29,37,'',NULL,'******************** FOR TTS USE ********************',0,'','');
insert into macrodetail values ('GET_WEATHER',30,10,'TEMP_STR',NULL,'"[LOCAL4]"',0,'','');
insert into macrodetail values ('GET_WEATHER',31,37,'',NULL,'****************************** *****************************',0,'','');
insert into macrodetail values ('GET_WEATHER',32,15,'[LOCAL1]',NULL,'posw(ph_getvar_s(1,5),"Forecast as of",1)',0,'','');
insert into macrodetail values ('GET_WEATHER',33,15,'[LOCAL9] ',NULL,'posw(ph_getvar_s(1,5),"</b>",ph_getvar_n(1,1)) ',0,'','');
insert into macrodetail values ('GET_WEATHER',34,15,'[LOCAL4] ',NULL,'mid(ph_getvar_s(1,5),ph_getvar_n(1,1),ph_getvar_n(1, 9)-ph_getvar_n(1,1))',0,'','');
insert into macrodetail values ('GET_WEATHER',35,15,'[LOCAL1]',NULL,'posw(ph_getvar_s(1,5),''alt="" /><br />'',ph_getvar_n(1,1))',0,'','');
insert into macrodetail values ('GET_WEATHER',36,15,'[LOCAL9]',NULL,'posw(ph_getvar_s(1,5),"<br /><br />",ph_getvar_n(1,1))',0,'','');
insert into macrodetail values ('GET_WEATHER',37,10,'CURFORECAST',NULL,'ph_getvar_s(1,4) + " " + mid(ph_getvar_s(1,5),ph_getvar_n(1,1)+15,ph_getvar_n(1,9)-ph _getvar_n(1,1)-15)',0,'','');
insert into macrodetail values ('GET_WEATHER',38,9,'',NULL,'"{TEMP_STR}"',0,'','');
insert into macrodetail values ('GET_WEATHER',39,9,'',NULL,'"{CURFORECAST}"',0,'','');
insert into macrodetail values ('GET_WEATHER',40,26,'',NULL,'EXIT',0,'','');
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
|
|