companion icon indicating copy to clipboard operation
companion copied to clipboard

Conditional actions

Open cybershoe opened this issue 4 years ago • 12 comments

Allow actions attached to a button to be conditional upon feedback switcher. Either allow addition of a "condition" action, which then contains sub-actions, or allow a condition to be specified for each individual action.

Use case: If I want to define a button to declaratively set up a particular key, fill, and background on the preview bus, I need to be able to tie the USK to the next transition if and only if the key is not already on air. Currently that button will result in a different scene depending on whether the keyer is already on air.

cybershoe avatar Mar 27 '20 13:03 cybershoe

#372 covers this but for feedback. Its on the radar for the next major version

krocheck avatar Mar 27 '20 15:03 krocheck

I read 372, it looked like it was scoped exclusively to feedback, but if it includes actions that's fine by me.

cybershoe avatar Mar 27 '20 15:03 cybershoe

Because of how actions and feedbacks are programmed, getting this in place for one should mean a pretty easy port for the other.

krocheck avatar Mar 27 '20 15:03 krocheck

Two whom do I need to send the beer to get this prioritized? :)

cybershoe avatar Jun 07 '21 21:06 cybershoe

With the new trigger feature in version 2.2.0, you can now create conditional actions. Basically this is how it works:

  • In the buttons, set internal variables to a certain state
  • In the trigger, dependant on certain conditions (that can be combined with an AND operator), you can execute actions. It's more a workaround than anything, but it helps.

benjaminpick avatar Mar 28 '22 08:03 benjaminpick

Seconding this suggestion. I'm setting up a complex lighting rig, and I'd like certain actions to be based on the state of the other lights. Right now the workaround is to use the "Button Press and Release if Variable meets Condition" function, but that means many, many extra "ghost" buttons that serve no other purpose than to just be proxies for conditional actions in another button.

A suggestion: a good place to put this hypothetical "conditions" option for each press action might be a button next to the trash icon that opens a submenu. Kind of like the relatively new "Learn" button. Maybe "Conditions"? Or "Logic"?

seanmcnally98 avatar Nov 05 '22 22:11 seanmcnally98

I wonder if what I'm doing in my module would help? I'm experimenting with Custom Variables values changed by feedback. Actions can use these variables to change what a button does depending on the variable. Not sure which module(s) you need this on or whether the device supports the feedback needed?

MeestorX avatar Nov 06 '22 14:11 MeestorX

[...]Actions can use these variables to change what a button does depending on the variable.

I'm assuming you mean your specific module can do this, since companion software itself can't. Me and OP are looking for this on a global level, that way any module can make use of it.

My specific use-case is this: I have 10 smart lights set up, and I have actions like "Blue" "Red" "Green" etc. to change the colors of every light in the room at once. This is for a concert stage, so I wanted to be able to pick one light to be the spotlight - make that one colored White, while all the rest of them stay whatever color they are. I could make a button to have, say light #​3 turn white, but the second I change all the other lights to another color, say Red for example, light #​3 will become Red too instead of staying white.

The solution is to store which light should be the spotlight in a variable, and have buttons that can set that variable. And, if logical conditions were supported, inside the "Red" button for each action I could put "if [variable] is not equal to 1, make light #​1 red, if not equal to 2 make light #​2 red, and so on and so forth.

Instead, with the way things are currently laid out, I need to place actions for every possible variable position in a separate button and use the "Button Press and Release if Variable meets Condition" function. If [variable] = 1 press page 99 button 1, which makes every light except #​1 the new color, if [variable] = 2 press page 99 button 2 which makes every light except #​1 the new color, and so on. All of that needs to be inside my "Red" button, and I need all these extra buttons on page 99. Having logic simply be accessible inside of the "Red" button would be much cleaner, and be a lot less work to set up with larger matrices.

edit: accidentally referenced some issues with my number signs, used this syntax to cancel them out

seanmcnally98 avatar Nov 06 '22 21:11 seanmcnally98

@MeestorX I don't understand how that will help with this, as even if feedbacks could set custom-variables, how would that make actions be conditional?

This task is currently on my list of things to look at doing for 3.1, which unfortonately is a little way off, but I do have a rough idea on how I expect it to work internally already.

For the UI, I am thinking it will appear as a new type of action internal: choose action. This action will have a section for building the condition with feedbacks, and a section to define the actions that should be executed.
This isn't final, it is my current idea on how this should work, and is heavily inspired by how home assistant solve the same problem.
I am concerned that the sidebar editor is not enough space to use an action like this, that could be enough to rethink this.

Julusian avatar Nov 06 '22 22:11 Julusian

Thanks so much for weighing in and for all you do, I'm glad it's on the roadmap! Looking forward to future releases :)

seanmcnally98 avatar Nov 06 '22 22:11 seanmcnally98

+1 More ideas for conditions #2233

Suenee avatar Dec 11 '22 08:12 Suenee

Yes yes yes PLEASE add a "conditional action". I've mocked something up:

Companion Conditionals

The "Conditions" section is a screengrab from https://www.htmlelements.com/vue/demos/querybuilder/overview/ which is a demo of a condition/query builder component that you should probably steal a lot of ideas from. It's definitely the best condition builder I've seen before.

Of course, this seems to break pretty far away from how action options are built now, and obviously having sub-actions doesn't work at all with how it's currently built (not to mention sub-sub-sub-actions if you nest conditionals...), but there's gotta be some way to do it. I believe in you guys!

joezimjs avatar Nov 30 '23 18:11 joezimjs