Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional actions #1052

Open
cybershoe opened this issue Mar 27, 2020 · 12 comments
Open

Conditional actions #1052

cybershoe opened this issue Mar 27, 2020 · 12 comments
Labels
area/internal Related to an internal action or function of Companion. Enhancement New feature or request Needs beer! This needs discussion while drinking beer
Milestone

Comments

@cybershoe
Copy link

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.

@krocheck
Copy link
Member

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

@cybershoe
Copy link
Author

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

@krocheck
Copy link
Member

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

@josephdadams josephdadams added Enhancement New feature or request area/internal Related to an internal action or function of Companion. Needs beer! This needs discussion while drinking beer labels Mar 28, 2020
@cybershoe
Copy link
Author

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

@benjaminpick
Copy link

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.

@seanmcnally98
Copy link

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"?

@MeestorX
Copy link

MeestorX commented Nov 6, 2022

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?

@seanmcnally98
Copy link

seanmcnally98 commented Nov 6, 2022

[...]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

@Julusian
Copy link
Member

Julusian commented Nov 6, 2022

@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.

@seanmcnally98
Copy link

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

@Suenee
Copy link

Suenee commented Dec 11, 2022

+1
More ideas for conditions #2233

@joezimjs
Copy link
Contributor

joezimjs commented Nov 30, 2023

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/internal Related to an internal action or function of Companion. Enhancement New feature or request Needs beer! This needs discussion while drinking beer
Projects
Status: No status
Status: No status
Development

No branches or pull requests

9 participants