Author |
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: April 08 2006 at 09:56 | IP Logged
|
|
|
I've started a new project to enable PH to get and respond to local weather alerts. The only problem I can see is that this uses polling, and sometimes warnings are issued only minutes before the event is to occur.
You need to create a new Global Variable called "CURWWA", and update your zone info in ph_geturl. Zone info is available here by drilling-down to your location (click on the correct XML button).
wwa.sql
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: April 08 2006 at 19:33 | IP Logged
|
|
|
Hmm. This will be tougher than it seemed. Multiple alerts will happen and need to be dealt with (i.e. a watch and a warning). In the XML file, each alert is in an <item> tag.
VB script seems to support XML parsing via a DOM that could handle this elegantly (like the current INI/profile file handling), but I'd like to try and keep this in PH.
More later.
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: April 09 2006 at 20:34 | IP Logged
|
|
|
Tony,
This looks really interesting. Please keep us posted. If you need any help on how to do something, just let me know.
Dave.
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: April 09 2006 at 23:40 | IP Logged
|
|
|
Holy schnikeys!
Here is what I thought would work...
Code:
ph_setvar_a( 1, 3, 1) + ph_doloop( "ph_concatvar( 1, 2, ph_regexdiff( '<item>~255<title>', '</title>', '[LOCAL1]', ph_getvar_n( 1, 3)) + ', ') + ph_setvar_a( 1, 3, pos('[LOCAL1]', '<item>', [LOCAL3] + 1))", "[LOCAL3] <> 0") |
|
|
But I just realized that I need to rework it to use ph_regex so I can put the position of the last found string in LOCAL3.
That will have to wait until tomorrow!
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: April 10 2006 at 22:07 | IP Logged
|
|
|
How would I code a regexdiff with plain regex command?
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: April 11 2006 at 16:22 | IP Logged
|
|
|
Tony,
Im thinking this:
Code:
ph_rtnes(ph_regex("<item>~255<title>","[LOCAL1]",ph_getvar_n(1,3),0,4,5))) + ph_rtnes(ph_regex("</title>","[LOCAL1]",ph_getvar_n(1,4) + ph_getvar_n(1,5),0,6,7)) + ph_mid("[LOCAL1]",ph_getvar_n(1,4) + ph_getvar_n(1,5),ph_getvar_n(1,6) - ph_getvar_n(1,5) - ph_getvar_n(1,4)) + ph_rtne(ph_setvar_a(1,3,ph_getvar_n(1,6) + ph_getvar_n(1,7))) |
|
|
[LOCAL3] should start at 1 and will be incremented with the new starting point with each successive search so that you can place it in a loop.
What Im doing is a ph_regex looking for the first piece of code. Im setting [LOCAL4] to the start and [LOCAL5] to the length. Im using ph_rtnes so I get an empty string. I then search for the end piece of code using the previous [LOCAL4] + [LOCAL5] as the starting point. This start and length is placed in [LOCAL6] and [LOCAL7]. I could save some variables by reusing but didnt here for clarity sake.
I then use a ph_mid function to extract the data between the two regex commands. Last, I set [LOCAL3] to the end of the previous search so that it is set for the next search.
HTH,
Dave.
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: April 11 2006 at 17:13 | IP Logged
|
|
|
Cool. I'll try this tonight!
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: April 11 2006 at 21:48 | IP Logged
|
|
|
OK, I found some typo's...
Code:
ph_rtnes(ph_regex("<item>~255<title>","[LOCAL1]",ph_getvar_n(1,3),0,4,5)) + ph_rtnes(ph_regex("</title>","[LOCAL1]",ph_getvar_n(1,4) + ph_getvar_n(1,5),0,6,7)) + mid("[LOCAL1]",ph_getvar_n(1,4) + ph_getvar_n(1,5),ph_getvar_n(1,6) - ph_getvar_n(1,5) - ph_getvar_n(1,4)) + ph_rtne(ph_setvar_a(1,3,ph_getvar_n(1,6) + ph_getvar_n(1,7))) |
|
|
More later!
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: April 12 2006 at 22:24 | IP Logged
|
|
|
Update! The macro now grabs all alerts listed and puts them into the Global "CURWWA". I still need to have this trigger an announcement or do something more useful.
WWA2
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: April 13 2006 at 21:58 | IP Logged
|
|
|
Heh. Caught my first watch tonight!
|
Back to Top |
|
|
mustangcoupe Super User
Joined: August 08 2003 Location: United States
Online Status: Offline Posts: 308
|
Posted: April 13 2006 at 22:13 | IP Logged
|
|
|
Tony,
I was just playing with this macro, and wondered... How often is enough to run a macro? I dont want to over work the PC(it is running windoz )
How often do you rin your macros, this one, the weather macro, ect...
__________________ Todd Hannemann
HA newbie
PowerHome - UPB - ELK
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: April 14 2006 at 07:35 | IP Logged
|
|
|
Great question. Figure out how often YOU want them to run, then offset the reference time of those that will hit at the same time. You don't want several to fire at once.
Macro, Freq, Ref Time
email, 6, 00:18
check ip, 15, 00:20
ping, 15, 00:23
wwa, 15, 00:26
weather, 30, 00:45
Edited by TonyNo - April 14 2006 at 07:36
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: April 17 2006 at 23:50 | IP Logged
|
|
|
I now filter out all alerts except watches and warnings, and then do something with the info...
If home:
- Announce new alert
- Pop-up alert on all computers here (via YAC)
If away:
- Send a text message to my cell phone
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: April 19 2006 at 22:30 | IP Logged
|
|
|
Tony,
What is YAC?
Dave.
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: April 19 2006 at 23:09 | IP Logged
|
|
|
YAC = Yet Another Caller id app
http://sunflowerhead.com/software/yac/
|
Back to Top |
|
|
theowl Groupie
Joined: February 24 2006 Location: United States
Online Status: Offline Posts: 59
|
Posted: June 17 2006 at 15:36 | IP Logged
|
|
|
Tony,
Does this macro grab the title of the alert, or title and description? I grabbed an alert today and got "Short Term Forecast - Vernon (Wisconsin)" and that was it.
Here's the RSS it's reading from...
<?xml version="1.0" encoding="UTF-8" ?>
- <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
- <channel>
<title>Wisconsin - (Vernon/WIZ053) - Current Watches, Warnings and Advisories for Wisconsin Issued by the National Weather Service</title>
<link>http://www.weather.gov/alerts/wi.html</link&g t;
<lastBuildDate>Sat, 17 Jun 2006 14:48:00 EDT</lastBuildDate>
<ttl>4</ttl>
<language>en-us</language>
<managingEditor>robert.bunge@noaa.gov</managingEdit or>
<webMaster>w-nws.webmaster@noaa.gov</webMaster>
<description>Current Watches, Warnings and Advisories for Wisconsin (Vernon/WIZ053) Issued by the National Weather Service</description>
- <image>
<url>http://weather.gov/images/xml_logo.gif</url> ;
<title>NOAA - National Weather Service</title>
<link>http://weather.gov</link>
</image>
- <item>
<title>Short Term Forecast - Vernon (Wisconsin)</title>
<link>http://www.weather.gov/alerts/wi.html#WIZ053.ARX NOWARX.183400</link>
<description>BLACK RIVER FALLS...LA CROSSE...<br>PRAIRIE DU CHIEN...SPARTA/TOMAH...VIROQUA...WINONA<br>134 PM CDT SAT JUN 17 2006<br><br>.NOW...<br>THROUGH 3 PM...LOOK FOR SOME SHOWERS AND PERHAPS A THUNDERSTORM TO<br>MOVE NORTH INTO THE AREA. MOST OF THE SHOWERS WILL BE EAST OF<br>PRAIRIE DU CHIEN AND LA CROSSE TO THE TOMAH AND BLACK RIVER FALLS<br>WISCONSIN AREAS. RAIN AMOUNTS THROUGH 3 PM WILL RANGE FROM A<br>TRACE...UP TO TWO TENTHS OF AN INCH WITH ANY THUNDERSTORMS. SHOWERS<br>AND THUNDERSTORMS ARE EXPECTED TO BECOME MORE WIDESPREAD AND<br>NUMEROUS THROUGH THE MID AND LATE AFTERNOON HOURS.<br><br>$$<br><br>RRS<br> ;<a href=http://www.crh.noaa.gov/arx/>Issuing Weather Forecast Office Homepage</a></description>
</item>
</channel>
</rss>
I'm trying to figure out your macro code by code, but it's taking some time.
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: June 17 2006 at 16:29 | IP Logged
|
|
|
It just grabs the title. The description was too long for my purposes. In the version I run, I filter out some of the titles (like short term forecasts).
|
Back to Top |
|
|
theowl Groupie
Joined: February 24 2006 Location: United States
Online Status: Offline Posts: 59
|
Posted: June 18 2006 at 17:55 | IP Logged
|
|
|
Ahh, OK
I finally sat down and wrote out your code. Basically, your just seeking the <item>, then the <title>. Located the ending </title>...and grabbing information between. Seems so simple once I got to understand how it was working.
Now to get it to grab the <description> tag as well since my PH system is 95% TTS........at least, for now
Great Job!
|
Back to Top |
|
|
brian2170 Newbie
Joined: April 29 2008
Online Status: Offline Posts: 15
|
Posted: April 29 2008 at 17:34 | IP Logged
|
|
|
Hi guys, i have been away from my power home projects for a while, but after the tornadoes here in Virginia, I am interested in the weather alert macros. I copied the macro form Tony's post(thank you), I would like to know how to filter out all but the watches and warnings for my area. Any help would be greatly appreciated, Thank you.
Brian
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: April 29 2008 at 17:41 | IP Logged
|
|
|
That should be all you are getting.
Did you go to the link and find your location?
http://www.weather.gov/alerts/
|
Back to Top |
|
|