Serializing Action Group Execution

Posted on
Thu Apr 28, 2016 11:04 am
nsosnicki offline
Posts: 168
Joined: Nov 14, 2004
Location: Boston, MA, US

Serializing Action Group Execution

I am attempting to use an embedded python script execute an action group (which itself is also an embedded python script) multiple times, "passing" a different parameter each time. I seem to be hitting a race condition where the calling script finishes before the action groups are executed.

Based on this post viewtopic.php?p=99891#p99891 I am using an Indigo variable to store the parameter to be passed.

Is there any way to serialize the execution or other ideas of how to pass a parameter effectively?

Example code. Call Test 1 is the script that sets the variable to the parm and executes the action group multiple times:
Code: Select all
parmVar=indigo.variables[1037427998]

indigo.variable.updateValue(parmVar, "Value 1")
parmVar.refreshFromServer()
indigo.server.log("1-1: "+parmVar.value)
indigo.actionGroup.execute("Call Test 2")

indigo.variable.updateValue(parmVar, "Value 2")
parmVar.refreshFromServer()
indigo.server.log("1-2: "+ parmVar.value)
indigo.actionGroup.execute("Call Test 2")


Call Test 2 is the script in the action group that simply logs the parm value from the variable:
Code: Select all
parmVar=indigo.variables[1037427998]
parmVar.refreshFromServer()
parm=parmVar.value

indigo.server.log("2-1: "+parm)


The output from executing Parm Test 1 is:
Code: Select all
  Action Group                    Call Test 1
  Script                          1-1: Value 1
  Action Group                    Call Test 2
  Script                          1-2: Value 2
  Action Group                    Call Test 2
  Script                          2-1: Value 2
  Script                          2-1: Value 2


What is desired would be:
Code: Select all
  Action Group                    Call Test 1
  Script                          1-1: Value 1
  Action Group                    Call Test 2
  Script                          2-1: Value 1
  Script                          1-2: Value 2
  Action Group                    Call Test 2
  Script                          2-1: Value 2


Thanks

Posted on
Thu Apr 28, 2016 11:12 am
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Re: Serializing Action Group Execution

Make n actions in an action group and add a delay to each. First delay=0; second delay=1 sec ; third delay =2 secs...
And put the scripts Into the individual actions



Sent from my iPhone using Tapatalk

Posted on
Mon May 02, 2016 9:42 am
nsosnicki offline
Posts: 168
Joined: Nov 14, 2004
Location: Boston, MA, US

Re: Serializing Action Group Execution

Thanks. While that does resolve the race condition in my simple test script, it's not really practical for using as a function that should be able to be called from anywhere/anytime.

However, in the "Shared Classes and Methods in Python Files" section of http://wiki.indigodomo.com/doku.php?id= ... g_tutorial I did find what I was looking for. I created the called function as an external Python file, imported the Indigo IOM into that function, dropped it into site-packages, and it works perfectly.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 9 guests

cron