Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Weather Warnings Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: April 08 2006 at 09:56 | IP Logged Quote TonyNo

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 View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: April 08 2006 at 19:33 | IP Logged Quote TonyNo

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 View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: April 09 2006 at 20:34 | IP Logged Quote dhoward

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 View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: April 09 2006 at 23:40 | IP Logged Quote TonyNo

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 View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: April 10 2006 at 22:07 | IP Logged Quote TonyNo

How would I code a regexdiff with plain regex command?
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: April 11 2006 at 16:22 | IP Logged Quote dhoward

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 View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: April 11 2006 at 17:13 | IP Logged Quote TonyNo

Cool. I'll try this tonight!
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: April 11 2006 at 21:48 | IP Logged Quote TonyNo

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 View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: April 12 2006 at 22:24 | IP Logged Quote TonyNo

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 View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: April 13 2006 at 21:58 | IP Logged Quote TonyNo

Heh. Caught my first watch tonight!
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
mustangcoupe
Super User
Super User
Avatar

Joined: August 08 2003
Location: United States
Online Status: Offline
Posts: 308
Posted: April 13 2006 at 22:13 | IP Logged Quote mustangcoupe

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 View mustangcoupe's Profile Search for other posts by mustangcoupe Visit mustangcoupe's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: April 14 2006 at 07:35 | IP Logged Quote TonyNo

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 View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: April 17 2006 at 23:50 | IP Logged Quote TonyNo

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 View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: April 19 2006 at 22:30 | IP Logged Quote dhoward

Tony,

What is YAC?

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: April 19 2006 at 23:09 | IP Logged Quote TonyNo

YAC = Yet Another Caller id app

http://sunflowerhead.com/software/yac/
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
theowl
Groupie
Groupie
Avatar

Joined: February 24 2006
Location: United States
Online Status: Offline
Posts: 59
Posted: June 17 2006 at 15:36 | IP Logged Quote theowl

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 View theowl's Profile Search for other posts by theowl
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: June 17 2006 at 16:29 | IP Logged Quote TonyNo

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 View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
theowl
Groupie
Groupie
Avatar

Joined: February 24 2006
Location: United States
Online Status: Offline
Posts: 59
Posted: June 18 2006 at 17:55 | IP Logged Quote theowl

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 View theowl's Profile Search for other posts by theowl
 
brian2170
Newbie
Newbie


Joined: April 29 2008
Online Status: Offline
Posts: 15
Posted: April 29 2008 at 17:34 | IP Logged Quote brian2170

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 View brian2170's Profile Search for other posts by brian2170
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: April 29 2008 at 17:41 | IP Logged Quote TonyNo

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 View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 

Page of 2 Next >>
  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum