companion icon indicating copy to clipboard operation
companion copied to clipboard

"Time of Day" Trigger with Range

Open ukiews opened this issue 1 year ago • 5 comments

Is this a feature relevant to companion itself, and not a module?

  • [X] I believe this to be a feature for companion, not a module

Is there an existing issue for this?

  • [X] I have searched the existing issues

Describe the feature

Under Triggers there is an option to execute events based on "Time of Day." This works fine in the user is logged in. However, say the triggers is se to run at 10:00:00. If the software is launched at 10:01:00, the trigger will obviously not execute. This is not practical for triggers on AV systems that are booted on for specific events at different times, with different streamdeck layouts.

So we need the ability to trigger within a given time range, say 10:00–10:30. This would have to be a one-time trigger, so that the trigger would only execute once at that specified time range.

Usecases

No response

ukiews avatar Jan 26 '24 22:01 ukiews

That's already possible.

Set the Event to Startup Set the Condition to internal: Variable: Check boolean expression with the Expression timestampToSeconds($(internal:time_hms)) >= 36000 && timestampToSeconds($(internal:time_hms)) <= 37800 Set the Action to whatever you want

That will check once on startup if the time is between 10:00:00 and 10:30:00 inclusive. If it is between that time the action is triggered.

If you also wanted to handle the case of startup being at 09:55:00 but still want the action to fire when it hits 10:00:00 there are other ways to do it, such as using a variable to see if the thing has already been triggered, that way it doesn't matter how many times the event fires to check (so you could add an additional event to fire at 10:00:00 in case Companion starts up prior to that) and have the action also change a variable to true and adjust the condition to check that variable to see if it has already fired once or not.

thedist avatar Jan 27 '24 13:01 thedist

@thedist thats a good suggestion.

I think the only thing we should do to improve this is to have a new feedback/condition to make these timestamp comparisons easier to do

Julusian avatar Jan 27 '24 16:01 Julusian

@thedist Thank you! If I want this to check for a specific day of the week as well, would I add an "Event" "Time of Day" and keep the time cleared?

ukiews avatar Jan 27 '24 22:01 ukiews

If I want this to check for a specific day of the week as well, would I add an "Event" "Time of Day" and keep the time cleared?

no, you should add another condition of type internal: Variable: Check boolean expression with the Expression $(internal:time_dow) == 1 || $(internal:time_dow) == 2 or whatever the check should be based on which days it should be.

To explain, the events aren't filters. Having multiple events just means more times/scenarios when the trigger should be executed. The conditions can then be used to decide whether to actually run the trigger each time one of the events says to execute.

Julusian avatar Jan 27 '24 22:01 Julusian

If I want this to check for a specific day of the week as well, would I add an "Event" "Time of Day" and keep the time cleared?

no, you should add another condition of type internal: Variable: Check boolean expression with the Expression $(internal:time_dow) == 1 || $(internal:time_dow) == 2 or whatever the check should be based on which days it should be.

To explain, the events aren't filters. Having multiple events just means more times/scenarios when the trigger should be executed. The conditions can then be used to decide whether to actually run the trigger each time one of the events says to execute.

Got it. Basically, they execute as OR, not AND. A description note would be helpful next to the field.

ukiews avatar Jan 27 '24 23:01 ukiews