[ANSWERED]Sequential or simultaneous?

Posted on
Sun Oct 26, 2014 8:30 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

[ANSWERED]Sequential or simultaneous?

Please note, this is not the new-user question about why actions all happen together / using delays to prevent this.

At a technical level, do the actions of a trigger run sequentially or simultaneously?

I have an action group (well quite a few) which connect/restore combinations of Airfoil speakers. I use them with motion or switch triggers that announce their results to the local speaker instead of the whole house.

They first Save_State, then they Disconnect_All, then they Connect_Speaker_X. After the announcement, they Restore_State.

These are not all working reliably - which I suspect is because the actions are all running at the same time - either because they are executed simultaneously, or because they are executed sequentially without waiting for each to finish. I suspect Disconnect_All is taking longer to run than Save_State or Connect_X, which is why my speakers aren't being connected in the right combinations.

I could use a 1 second delay between each, but that means whenever a motion trigger fires it is maybe 5 seconds before the announcement.

Do/can actions be set to execute sequentially and complete before the next, without the use of delays? (UI option: "Wait for this command to finish before executing next") or, can the UI for delays be set to allow <1 second delays?

Peter

Posted on
Mon Oct 27, 2014 9:55 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Sequential or simultaneous?

The answer isn't a simple "parallel" or "sequential". For built-in actions, we attempt to run them in parallel as much as is possible - some actions end up being sequential given the nature of the action (embedded AppleScripts and Python scripts, INSTEON commands because we have to queue them up for the PowerLinc to execute sequentially, etc.), but those can be run in parallel with other actions. So, for instance, turning on a Z-Wave light and an INSTEON light will happen roughly in parallel.

Plugins also throw some oddness into the mix - when a plugin action fires, we hand it off to the plugin without doing anything else really - so it's up to the plugin how the action execution actually works and returns. So you might say they're sequential, but that's not necessarily the case since the plugin could very well thread operations to make them perform in parallel.

Now, for your particular case, you have 3 Airfoil actions (which will execute in parallel), followed by an announcement of some kind which is through some other action, then back to your Airfoil action. So, what's going to happen is all 4 Airfoil actions will run sequentially with no pauses (all 4 in a row). Your other action will execute outside the scope of those 4 actions because it's getting dispatched to something else (though you don't say what's doing the announcement).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Oct 27, 2014 4:47 pm
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: [ANSWERED]Sequential or simultaneous?

Hi Jay.

My trigger has 3 commands.

1) ActionGroup Airfoil-Bedroom
2) Speak (literally using the built in speak UI)
3) ActionGroup Airfoil-Restore

ActionGroup Airfoil-Bedroom has the three actions listed in my first post - save, disconnect, connect.

Will all four Airfoil's happen pretty much in parallel? Can you update the Airfoil plugin to execute sequentially - anyone using it will need this function unless they a) only ever broadcast housewide or b) use 1-second delays?

Peter

Posted on
Mon Oct 27, 2014 5:58 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: [ANSWERED]Sequential or simultaneous?

howartp wrote:
Will all four Airfoil's happen pretty much in parallel?


Not exactly. Remember, Indigo will try to run all 3 of your actions in parallel - so you'll probably end up seeing #3 execute sometime in-between the commands in #1 because each action group execution will be happening at the same time. So, the server will start sending the commands in action group 1 and the action in action group 3 at the same time. And of course so will #2 which is an entirely different thread.

howartp wrote:
Can you update the Airfoil plugin to execute sequentially


It's not a problem with Airfoil - it's the order in which the airfoil commands are being sent to the plugin. That is not alterable.

If you really want to make sure that everything happens in the order you want, then probably your best bet is to write a script that does it all. Airfoil's actions are scriptable, as is the ability to speak (with the appropriate flag to wait until speaking is done).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Oct 29, 2014 2:23 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: [ANSWERED]Sequential or simultaneous?

Ah, hadn't thought of scripting.

I'll give that a go tonight.

Posted on
Tue Jan 16, 2018 4:02 pm
ZachBenz offline
Posts: 163
Joined: Feb 08, 2014

Re: Sequential or simultaneous?

jay (support) wrote:
The answer isn't a simple "parallel" or "sequential". For built-in actions, we attempt to run them in parallel as much as is possible - some actions end up being sequential given the nature of the action (embedded AppleScripts and Python scripts, INSTEON commands because we have to queue them up for the PowerLinc to execute sequentially, etc.), but those can be run in parallel with other actions. So, for instance, turning on a Z-Wave light and an INSTEON light will happen roughly in parallel.

<snip>


With respect to Python script actions running sequentially, is this still true (with the latest Indigo version)? I have a trigger that fires off two actions:
    1. Run a python script that downloads a file
    2. Use the Better Email plugin to email that file as an attachment

If I don't add a delay in to the second action, it pretty much always starts try to send the email before the file is downloaded, suggesting non-sequential execution. In this case, I'd actually like to force sequential (i.e. wait for the file to finish downloading, or optionally timeout). My workaround is the hack of using a delay, which I have to make 'long enough' by trial and error. (Or I could put everything into the python script action I suppose, per your suggestion to the OP, assuming the Better Email plugin is scriptable...)

Thanks!

ZachBenz's Plugins: RingForIndigo

Posted on
Tue Jan 16, 2018 7:44 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: [ANSWERED]Sequential or simultaneous?

BetterEmail is scriptable:

Code: Select all

def sendAlertEmail(title, message):
   theSubject = "Indigo Alert: %s" % title
   theBody = "%s\" % (message)

   bePlugin = indigo.server.getPlugin("com.flyingdiver.indigoplugin.betteremail")
   if bePlugin.isEnabled():
      bePlugin.executeAction("sendEmail", deviceId=12345678,
      props={'emailTo':'foo@bar.com', 'emailSubject': theSubject, 'emailMessage': theBody})
      
   return


joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Wed Jan 17, 2018 12:27 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: [ANSWERED]Sequential or simultaneous?

As Joe is implying, you could add a call to his plugin within your existing python code, so once the file is downloaded, Python then emails the file via BetterEmail, rather than having a second UI command in the trigger itself.


Sent from my iPhone using Tapatalk Pro

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 9 guests