Page 1 of 1

NOAA Weather - Trigger from Current Condition

PostPosted: Wed Jul 23, 2014 6:36 pm
by towsled
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..

Re: NOAA Weather - Trigger from Current Condition

PostPosted: Wed Jul 23, 2014 7:50 pm
by kw123
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

Re: NOAA Weather - Trigger from Current Condition

PostPosted: Wed Jul 23, 2014 8:02 pm
by RogueProeliator
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

Re: NOAA Weather - Trigger from Current Condition

PostPosted: Wed Jul 23, 2014 9:28 pm
by kw123
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

Re: NOAA Weather - Trigger from Current Condition

PostPosted: Wed Jul 23, 2014 9:42 pm
by RogueProeliator
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

Re: NOAA Weather - Trigger from Current Condition

PostPosted: Thu Jul 24, 2014 3:24 pm
by towsled
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..