Determining enabled/disabled state of a trigger
Posted:
Thu Nov 03, 2016 4:48 pm
by aldera
Hello,
I'd like to be able to know the current state of a trigger via the Indigo Touch app on my phone. I thought I could create a variable for each trigger and set it to true/false depending on the trigger's current state. Is there a way to do this? Fairly new to Indigo and I'm not a Phython or Applescript programmer. Or is there another way that I'm not even aware of? Thanks.
Re: Determining enabled/disabled state of a trigger
Posted:
Sun Nov 06, 2016 11:17 am
by matt (support)
This might need some tweaking, but trying something like this. Create a repeating Schedule action for every couple of minutes (don't execute too frequently as it might take a second or so for Indigo to complete it). The action will be to execute an embedded Python script:
- Code: Select all
varfoldername = "TriggerEnabledStates"
if varfoldername in indigo.variables.folders:
targetfolder = indigo.variables.folders[varfoldername]
else:
targetfolder = indigo.variables.folder.create(varfoldername)
for trigger in indigo.triggers:
varname = trigger.name + "IsEnabled"
varname = varname.replace(" ","") # no spaces allowed in Indigo variable names
varvalue = str(trigger.enabled)
if varname not in indigo.variables:
indigo.variable.create(varname, varvalue, folder=targetfolder)
else:
targetvariable = indigo.variables[varname]
indigo.variable.updateValue(targetvariable, varvalue)
Re: Determining enabled/disabled state of a trigger
Posted:
Sun Nov 06, 2016 1:06 pm
by aldera
matt (support) wrote:This might need some tweaking, but trying something like this. Create a repeating Schedule action for every couple of minutes (don't execute too frequently as it might take a second or so for Indigo to complete it). The action will be to execute an embedded Python script:
- Code: Select all
varfoldername = "TriggerEnabledStates"
if varfoldername in indigo.variables.folders:
targetfolder = indigo.variables.folders[varfoldername]
else:
targetfolder = indigo.variables.folder.create(varfoldername)
for trigger in indigo.triggers:
varname = trigger.name + "IsEnabled"
varname = varname.replace(" ","") # no spaces allowed in Indigo variable names
varvalue = str(trigger.enabled)
if varname not in indigo.variables:
indigo.variable.create(varname, varvalue, folder=targetfolder)
else:
targetvariable = indigo.variables[varname]
indigo.variable.updateValue(targetvariable, varvalue)
Thanks for the code. I'll play with it and see if I can get it to work. Yesterday I spent several hours working on a Python tutorial since I've never used it before. We'll see if I remember anything from it. Out for the day so I won't get to play with it until later tonight or tomorrow. Thanks again!
Re: Determining enabled/disabled state of a trigger
Posted:
Sun Nov 06, 2016 5:08 pm
by aldera
Thanks, Matt! That code worked like a charm.
I even understood what the code was doing after only a few hours of a Python tutorial yesterday! Scary.
Now I just need to dig into the Indigo documentation and find out what functions and values are available to access from within Indigo.
THANKS!