How to convert "execute group [in integer]"

Posted on
Sat Aug 22, 2020 8:53 am
macpro offline
User avatar
Posts: 765
Joined: Dec 29, 2005
Location: Third byte on the right

How to convert "execute group [in integer]"

I'm converting a script that executes an action group with a delay:

Code: Select all
repeat with i from 1 to 45
   execute group "Slaapkamer Wekker - Snooze" in (40 * i)
end repeat


The python documentation has no option to specify a delay.
How should I convert this?

Posted on
Mon Aug 24, 2020 9:38 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: How to convert "execute group [in integer]"

Code: Select all
# This will run the script with i going from 1 to 45:
for i in range(1, 46):
    # sleep for the number of seconds
    self.sleep(40 * i)
    # execute the action group
    indigo.actionGroup.execute(ID_OF_ACTION_GROUP)


Note you'll want to run this as an external script since it's a long-running script.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Aug 24, 2020 10:07 am
macpro offline
User avatar
Posts: 765
Joined: Dec 29, 2005
Location: Third byte on the right

Re: How to convert "execute group [in integer]"

Thanks.

I had to add
Code: Select all
import time
because self. sleep wasn't recognised.
And the multiplier had to go.
Code: Select all
time.sleep(40)

Posted on
Mon Aug 24, 2020 1:23 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: How to convert "execute group [in integer]"

Instead try using:

indigo.activePlugin.sleep(40)

which will be more friendly if the Indigo Server is trying to restart and wants to shutdown the script.

Image

Posted on
Mon Aug 24, 2020 1:34 pm
macpro offline
User avatar
Posts: 765
Joined: Dec 29, 2005
Location: Third byte on the right

Re: How to convert "execute group [in integer]"

That works also.

I use time.sleep also in other Python scripts. Should I replace them everywhere with indigo.activePlugin.sleep?

Posted on
Mon Aug 24, 2020 2:02 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: How to convert "execute group [in integer]"

Sorry, self.sleep is for plugins... :oops:

Yes, any scripts that are run from Indigo should use indigo.activePlugin.sleep() in case the server needs to restart while a script is sleeping.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests