Announcement

Collapse
No announcement yet.

Way to control whether events run synchronous or asynchronous?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Way to control whether events run synchronous or asynchronous?

    1st scenario
    Let's say you have an event that runs several events in the action section, like so:

    IF manually triggered
    THEN
    Run Event A
    Run Event B
    Run Event C

    Does HS4 wait for Event A to complete before running Event B? If not, is there a way to force it to run linearly?

    2nd scenario
    Nested events, like so:

    IF manually triggered
    THEN
    Run Event A
    (Event A runs Event A1)
    (Event A1 runs Event A2)
    Run Event B
    Run Event C

    Similar question from the first scenario, is there a way to force linear execution in that all of the nested events from Run Event A complete before Run Event B executes?

    Using Wait statements seems like an imprecise kludge since there's no guarantee of how long each sequence might take.

    Any thoughts or suggestions appreciated.

    #2
    The answer to all three of your questions is, “No”. At least not with the events configured as you’ve presented them.

    In order to achieve what you’re wanting (linear event execution), you’ll need to use virtual devices for each event trigger. Then in each event, the last action would be to turn on the next event’s trigger virtual device.

    In your first scenario for example, create virtual devices called “Event A Trigger”, “Event B Trigger”, and “Event C Trigger” (or whatever naming convention you prefer). The “master” event, instead of calling all three events, would only turn on the Event A Trigger virtual device. Then the last action of Event A would turn on the Event B Trigger virtual device. Et cetera.

    Also, in each event you will probably want to reset the triggering virtual device, i.e. Event A would have an action to turn off Event A Trigger.

    Of course, another option is scripting…

    Comment


      #3
      Actually you can run events linearly without virtual devices.

      Rather than using the standard 'Run Event' as the event action, use 'Run a script or script command' with the following immediate script statement:

      &hs.TriggerEventAndWait("<event name>")

      This will run and then wait until the event has completed before carrying on with the next action in the event.

      Just repeat this for additional events you want to run in turn.
      Jon

      Comment


        #4
        Originally posted by jon00 View Post
        Rather than using the standard 'Run Event' as the event action, use 'Run a script or script command' with the following immediate script statement:

        &hs.TriggerEventAndWait("<event name>")
        Cool! 🙌 I never knew about this script function. Thanks for pointing this out, Jon 👍

        Like I said, scripting...😉

        Comment


          #5
          As always, brilliant jon00, this will also allow me to keep the nested Event structure it seems. Many thanks for the suggestion.

          rjh since it's already part of the HS API, I'm surprised this is not an option in the Action pull down list, ie, "Run Another Event (and wait)"
          Seems like an easy feature to add.

          Comment


            #6
            Originally posted by TC1 View Post
            rjh since it's already part of the HS API, I'm surprised this is not an option in the Action pull down list, ie, "Run Another Event (and wait)"
            Seems like an easy feature to add.
            ...or even a tick box on the existing event options.

            Jon

            Comment


              #7
              Is there a way to run this script &hs.TriggerEventAndWait("<event name>") but only have the event run if it's conditions are met?

              Comment


                #8
                Originally posted by charbwin View Post
                Is there a way to run this script &hs.TriggerEventAndWait("<event name>") but only have the event run if it's conditions are met?
                There's no reason to use a script to call an Event now that HS4 has added the ability to run synchronous and check the conditions right from the GUI interface:

                Click image for larger version

Name:	image.png
Views:	141
Size:	36.2 KB
ID:	1575879
                Make sure you're on the latest version of HS4​

                Comment


                  #9
                  That works great. Much simpler, thanks.

                  Comment

                  Working...
                  X