Conditional Trigger

Posted on
Mon Mar 20, 2017 1:18 pm
aldera offline
User avatar
Posts: 188
Joined: Aug 30, 2016
Location: Michigan, USA

Conditional Trigger

I have a trigger set up for each door so that when the door is opened it sends a text, email, turns on lights and makes an announcement on my Sonos speakers. That's all I want it to do when I'm home. When I'm away from home, I want it to also turn on the siren. I have a variable called houseMode that can be set for either home or away. Is there a way to do this without having to write 2 identical triggers for each door that has a condition requirement for the houseMode variable to equal "home" for one and to equal "away" for the other? TIA

Posted on
Mon Mar 20, 2017 2:26 pm
mat offline
Posts: 769
Joined: Nov 25, 2010
Location: Cambridgeshire - UK

Re: Conditional Trigger

No you will need to create two triggers. Just copy and paste, then amend as necessary.

Late 2018 mini 10.14

Posted on
Mon Mar 20, 2017 3:10 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Conditional Trigger

Or write a script as an additional action that checks the variable and turns on the siren.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Mar 21, 2017 2:33 pm
aldera offline
User avatar
Posts: 188
Joined: Aug 30, 2016
Location: Michigan, USA

Re: Conditional Trigger

jay (support) wrote:
Or write a script as an additional action that checks the variable and turns on the siren.


Bingo!

Still rather new to Indigo and just starting to learn about Python programming but I dug around in the Indigo Scripting Tutorial and cobbled together a few lines of code to put in the trigger for each door. Works like a champ and I didn't have to duplicate my triggers. Thanks.

First script turns on the siren, if I'm away. Second script turns off the siren after a 1-minute delay.
Code: Select all
# Script to turn siren on if houseMode="away"
houseMode = indigo.variables[13706081]  #houseMode variable
if houseMode.value == "away":
   indigo.device.turnOn(920113160)  #turn on siren
   
# Script to turn siren off in 1 minute, if houseMode="away" (delay 1 minute)
houseMode = indigo.variables[13706081]  #houseMode variable
if houseMode.value == "away":
   indigo.device.turnOff(920113160)  #turn off siren

Posted on
Mon Apr 03, 2017 12:29 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Conditional Trigger

Have a look at the 3rd example on http://wiki.indigodomo.com/doku.php?id= ... g_tutorial

You can set auto-off in your turnOn command so you don't need two seperate actions with a 1 minute delay.


Sent from my iPhone using Tapatalk

Posted on
Mon Apr 03, 2017 4:39 pm
aldera offline
User avatar
Posts: 188
Joined: Aug 30, 2016
Location: Michigan, USA

Re: Conditional Trigger

howartp wrote:
Have a look at the 3rd example on http://wiki.indigodomo.com/doku.php?id= ... g_tutorial

You can set auto-off in your turnOn command so you don't need two seperate actions with a 1 minute delay.


Sent from my iPhone using Tapatalk


Yep. That works, too. Just updated my code. Thanks.

Code: Select all
# Script to turn siren on if houseMode="away"
houseMode = indigo.variables[13706081]  #houseMode variable
if houseMode.value == "away":
   indigo.device.turnOn(920113160, duration=60)  #turn on siren for 1 minute

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest