Option to execute actions serially, in order show in the UI

Posted on
Fri Aug 24, 2018 3:56 pm
Chad_NE offline
User avatar
Posts: 16
Joined: Aug 19, 2018

Option to execute actions serially, in order show in the UI

Indigo maximizes performance and reliability by running actions in parallel to the greatest extent possible. This works for the vast majority of cases. Unfortunately, it can also result in non-deterministic execution with irreproducible results. Consider the following actions in a action group:

set value of variable_1 to X
set value of variable_2 to Y
run action group that depends on variable_1 and variable_2

I have found that the third action in the list will sometimes run before the first. I know it is against everything Indigo is hoping to accomplish, to allow serialized execution. However, I wish I could have a checkbox on the action group to "Execute sequentially".

Of course, I can put all of the above into a python script. If I do that however, I am no longer dealing with clearly named variables, but variable numbers. This isn't maintainable, as I have to look up each number in the variable list to understand the code a month from now. It also loses the elegance that Indigo offers.

I can also introduce delays. That could work, but the minimum delay provided is 1 second... a bit too slow for responsive lighting.

-------
Warning, wonky details follow

If you want to know the specifics of what I'm trying to accomplish, take a peak at the attached screen capture. To make a very large lighting installation maintainable:

- I have lighting levels for each type of device and time of day in a folder in the variables table.
- A schedule sets global brightness variables to the appropriate values from the table four times a day.
- The attached action fires when you walk into a room (motion sensor), or touch an Insteon dimmer switch
- It sets room brightness variables from the global values
- A guard-variable is set true, allowing an action group to run and apply those lighting levels

The intent is a dynamic scene, appropriate to the time of day. During the day, I want most lights to be very bright, and at night, more gentle lighting is preferred. I get a scene appropriate to time of day just by walking into a room or pawing at a dimmer switch... no hunting for a button required.

This works fine, but I quickly discovered that actions run in parallel. I originally carried out all the actions in this one action group. I then tried using a guard variable (1_SDY_fureScene) for barrier synchronization, but of course, all the variable assignments are executed in parallel.

All this was discussed quite some time ago in the following thread:
viewtopic.php?f=152&t=15946
Attachments
Not sequential.jpeg
Action group needs to execute serially and deterministically
Not sequential.jpeg (70.35 KiB) Viewed 1883 times

Posted on
Fri Aug 24, 2018 4:28 pm
jay (support) offline
Site Admin
User avatar
Posts: 18212
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Option to execute actions serially, in order show in the

Chad_NE wrote:
Of course, I can put all of the above into a python script. If I do that however, I am no longer dealing with clearly named variables, but variable numbers. This isn't maintainable, as I have to look up each number in the variable list to understand the code a month from now. It also loses the elegance that Indigo offers.

I can also introduce delays. That could work, but the minimum delay provided is 1 second... a bit too slow for responsive lighting.


The request is on the list, but it's quite low priority given 1) the very low demand (and high development/qa impact) and 2) as you point out there are other ways to accomplish the task. You can use names rather than IDs for variables, just understand that names can change and that will break the script.

One way we help with the name<->ID map is to add the name of the variable when you select the Copy Python Reference contextual menu - it results in:

Code: Select all
indigo.variables[123456789] # "img_url"

We add the variable (or other object) name as a comment. So, while it won't be updated with name changes, it does give you an idea of what the variable is.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Aug 25, 2018 12:34 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Option to execute actions serially, in order show in the

I’ve not examined your process in detail, but I understand your concept.

Would it be an option to trigger on variable_2 value change, and have that execute the action_group that depends on var 1/2?

Or even trigger on var 1 to set var 2, then on var 2 to execute actions.

Messy but an option!

Finally, it sounds like your whole concept could be turned into a plugin...


Sent from my iPhone using Tapatalk Pro

Posted on
Sat Aug 25, 2018 5:29 pm
Chad_NE offline
User avatar
Posts: 16
Joined: Aug 19, 2018

Re: Option to execute actions serially, in order show in the

Howartp from the UK,

Thanks so much for responding and thinking about the problem!

< Messy but an option!

Not messy at all; and I appreciate you taking the time to understand the issue and propose a solution. Your approach is what allowed me to determine that the variable assignments in an action list run concurrently. Basically, I set two parameter variables with values that will be used in an Action Group when run. I then set a third, guard variable (1_SDY_fireScene) to true. The Action Group watches 1_SDY_fireScene, and runs when it become true. Unfortunately, the guard variable is sometimes set to true before both of the parameter variables are. This showed that variable assignments do not run serially. Since anything you put in an action list runs in parallel, there's no way to serialize it without introducing delays.

< Would it be an option to trigger on variable_2 value change, and have that execute the action_group that depends on var 1/2?
Unfortunately, variable 2 being assigned is no guarantee that variable 1 has also been assigned just yet, even if it comes first in the action list.

< Or even trigger on var 1 to set var 2, then on var 2 to execute actions.
Very clever! Yes, that would work. I think you would assign variables 1 and 2 obviously invalid values at initialization, and after the actions run. That way, you could trigger on a value change and be sure that it's a new assignment.

< Finally, it sounds like your whole concept could be turned into a plugin...
What an interesting idea! If I do run into something that stumps me, I guess I always do have the option of creating a plugin.


PS: I was able to accomplish what I needed by eliminating the dependency. Essentially, I have variables 1 and 2 assigned updated values four times a day using a schedule. The action group which uses these variables is thus always working with valid values. The solution offers less flexibility, but it is completely reliable, and less complicated than my original approach.

Posted on
Sat Aug 25, 2018 5:53 pm
Chad_NE offline
User avatar
Posts: 16
Joined: Aug 19, 2018

Re: Option to execute actions serially, in order show in the

Jay,

< The request is on the list, but it's quite low priority given 1) the very low demand (and high development/qa impact)

That is a very polite understatement given that:

- Only two people cared about this
- It's been 320 days since anyone raised the issue
- You are doing everything possible to improve performance and reliability by avoiding serial execution
- The checkbox I am asking for might just as well say "Shoot myself in the foot"

I am surprised you did not pull your hair out when you saw this request. Now I understand why you can order items in an action list. At first however, the idea of an ordered list suggested completely ordered and serialized execution. This lead to a two hour debugging session complicated by the fact that the concurrency I was unaware of inherently lead to irreproducible results. : )

I have since gone less crazy with my degrees of flexibility, and found something that works well. It is also simpler, and more maintainable. Fortunately, Indigo is so powerful, there are many ways to get the job done.

< One way we help with the name<->ID map is to add the name of the variable when you select the Copy Python Reference contextual menu

Wow, that is pretty cool! Thanks for telling me about this capability, and for taking my posting seriously. I think I should give you a break before coming up with anymore "great ideas".

Appreciatively,

-- Chad

Posted on
Sun Aug 26, 2018 10:40 am
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Option to execute actions serially, in order show in the

Personally I’d really welcome a checkbox that would force a series of Actions to execute in the order
they were set in. Save having to work out an annoying set of delays.

Carl

Posted on
Mon Aug 27, 2018 2:50 pm
mat offline
Posts: 769
Joined: Nov 25, 2010
Location: Cambridgeshire - UK

Re: Option to execute actions serially, in order show in the

I usually just add a delay to those actions I want to happen later - typically in my case AV equipment switch on, and then change a setting - "delay by" 10 seconds

I guess it depends if the action is time critical from the user side.

Late 2018 mini 10.14

Posted on
Mon Aug 27, 2018 3:12 pm
Korey offline
User avatar
Posts: 813
Joined: Jun 04, 2008
Location: Henderson, NV

Re: Option to execute actions serially, in order show in the

ckeyes888 wrote:
Personally I’d really welcome a checkbox that would force a series of Actions to execute in the order
they were set in. Save having to work out an annoying set of delays.

Carl


+1

--
Korey

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests