NOAA Weather - Trigger from Current Condition

Posted on
Wed Jul 23, 2014 6:36 pm
towsled offline
Posts: 30
Joined: Jul 19, 2014

NOAA Weather - Trigger from Current Condition

I am new to Indigo and thought I would try building a trigger. I thought it would be neat if I could trigger my house coach lights on if the NOAA current condition contained the word "Thunderstorm" as there are many different NOAA Thunderstorm Current Condition states all of which though contain "Thunderstorm". In looking at the triggers for device states it appears that I can only perform "equal to" or "not equal to" operations but not "contains". Does anyone have a way around this?

Thanks,
Dan..

Posted on
Wed Jul 23, 2014 7:50 pm
kw123 online
User avatar
Posts: 6893
Joined: May 12, 2013
Location: Dallas, TX

Re: NOAA Weather - Trigger from Current Condition

put the attached py script into the action in server/scripts (replace the number by either "yourNOAAdevicename" or the device number of your NOAA device (no quotes))..

then in the python action switch on lights, send email etc. checkout the wiki example pages in python scripts


hope that helps

Karl
Attachments
Screen Shot 2014-07-23 at 8.47.26 PM.png
Screen Shot 2014-07-23 at 8.47.26 PM.png (64.32 KiB) Viewed 2203 times

Posted on
Wed Jul 23, 2014 8:02 pm
RogueProeliator offline
User avatar
Posts: 2310
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: NOAA Weather - Trigger from Current Condition

One note/correction that I noticed -- it should be using square brackets as opposed to parenthesis... Also, the compare with find is going to be case sensitive which could be problematic; a quick-and-easy approach would be to lower case the string prior to doing the find:
Code: Select all
if dev.states["currentCondition].lower().find("thunderstorm") >= 0:

Adam

Posted on
Wed Jul 23, 2014 9:28 pm
kw123 online
User avatar
Posts: 6893
Joined: May 12, 2013
Location: Dallas, TX

Re: NOAA Weather - Trigger from Current Condition

yes you are right..

Code: Select all
if indigo.devices[822525185].states["currentCondition"].lower().find("thunder") >=0:
     Do python stuff

question is does towsled know python... i.e. Do python stuff

if not describe your action and we can help you

Karl

Posted on
Wed Jul 23, 2014 9:42 pm
RogueProeliator offline
User avatar
Posts: 2310
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: NOAA Weather - Trigger from Current Condition

Dan, now that I think about your original question, you don't really need it scripted -- when you create your trigger, set it up to trigger on "Has Any Change" for "Current Condition" as the Trigger, but on the Conditions tab you would setup a condition for "If device [your device] Current Condition contains Thunderstorm."

Adam

Posted on
Thu Jul 24, 2014 3:24 pm
towsled offline
Posts: 30
Joined: Jul 19, 2014

Re: NOAA Weather - Trigger from Current Condition

Karl & Adam - Thanks for the input. Not familiar with Python so it looks like I will need to read up as I try and get more complex. Now I see how the conditions tab is used and this makes much more sense in the scripted example. Got everything set and now just waiting for a thunderstorm :)

Thanks for all of your help and guidance!
Dan..

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest

cron