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

Allow trigger conditions evaulated with more boolean logic, and allow actions to be performed when condition evaluates to false as well as true #2770

Open
2 tasks done
phillipivan opened this issue Feb 26, 2024 · 9 comments
Labels
area/backend Something in the core of companion area/gui GUI / Webapp related area/internal Related to an internal action or function of Companion. Enhancement New feature or request

Comments

@phillipivan
Copy link

phillipivan commented Feb 26, 2024

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

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

Is there an existing issue for this?

  • I have searched the existing issues

Describe the feature

At the moment all Trigger conditions are combined with Boolean ands. We could create more sophisticated triggers by allowing other Boolean operations (OR, XOR, NAND, NOR, XNOR).

Similarly actions are only performed when the conditions evaluate to true, allowing a separate set of actions to be performed when they evaluate to false allows more efficient programming of two-state operational conditions.

An example of this is in the Stagetec Nexus routers I use. While the UI looks old, it allows using up to 4 input conditions combined with 3 Boolean operators, and the four actions can be either on true or on false. The evaluated logic can then be an input condition for other logic allowing for more complex or efficient programming.

I have attached a screen shot for reference.

stagetec nexus logic

Usecases

More efficiently create complex actions, state machines etc. Especially for things that need to toggle, or where behavior similar to a radio button (XOR) is required.

@premultiply
Copy link

Right.

Most simple usecase is mapping of a simple tally input (boolean feedback or variable from mixer etc.) to a tally output (camera tally input, lamp etc.).

Today this simple operation is surprisingly complicated and needs at least two triggers for each tally channel for "on" and "off" without any further logic as already mentioned.

What is still missing (or is not obvious how it should work) is a simple direct mapping of a boolean state from feedback or boolean variable to true and false actions in one operation.

@phillipivan phillipivan changed the title Allow trigger conditions with boolean logic, allow actions to be performed when condition evaluates to false as well as true Allow trigger conditions evaulated with more boolean logic, and allow actions to be performed when condition evaluates to false as well as true Feb 27, 2024
@hadphild
Copy link

Both Companion and Tally Arbiter are amazing projects. It would be really good if they could be combined together to get the Logic from TA to be added to the all switchers and camera modules in Companion. Like Feedback to the devices over connections. This could make tally very easy and make Companion even better.

Could there be a wizard for trigger to auto create the Tally stats. IE List all switchers and list all cameras and there numbers.

So in the triggers is auto does tally Red / Green on ATEM 1 and Green only Tally on Panasonic RP150 (PTZ Camera controller)

@Julusian Julusian added Enhancement New feature or request area/gui GUI / Webapp related area/internal Related to an internal action or function of Companion. area/backend Something in the core of companion labels Mar 2, 2024
@Julusian
Copy link
Member

Julusian commented Mar 2, 2024

I think this would be covered by #372 and #1052 . Does this include anything that wouldn't be solved by that?

My current thinking is to take inspiration from home-assistant for the ui. I don't have any screenshots in easy reach of that

@phillipivan
Copy link
Author

phillipivan commented Mar 3, 2024

@Julusian I think there is some cross-over, and sorry I didn't find them, I was searching for things related to triggers.

There are some differences, which I think are as follows:

  • Triggers / Actions / Feedbacks. Though I appreciate whats done for one is likely done or practical to be done for the others.
  • I'm requesting a complete set of boolean operators, and ideally the ability to nest/chain them similar to the screen shot I provided.
  • Capacity to define actions performed when evaluation is false (though I see this is mentioned further down in Conditional actions #1052).

@dnmeid
Copy link
Member

dnmeid commented Mar 6, 2024

On condition becoming false is available since a few versions.

With the condition internal: Variable: Check boolean expression you can already do everything you want and more.

You can compare and check as many variables as you want and tie all the evaluations with boolean logic. I admit that the only boolean operators are AND, OR and NOT. NAND and XOR would have to be expressed with them.
I've seen a lot of graphical solutions for complex boolean equations and I find none of them very pleasing. Companion is used mainly by average non-programmers who don't know about bool at all. Maximum thing I would suggest is the option of a top-level "all conditions" (AND) or "any condition" (OR). With everything finer grained control I suggest to stick with the expression based solution we already have.

@premultiply
Copy link

Unfortunately, this does not really help in terms of complexity, as it does not reduce the number of entries.

A single "Evaluate input condition" with two output branches is missing here: "If value (becomes) true, do this" and "If value (becomes) false, do this".
This would significantly help to reduce the complexity and the number of necessary configuration steps.

It would also be very useful to be able to use Boolean feedback directly as input instead of always having to use comparatively complicated variables. The actual data type or value range is often not clearly recognizable for the user and differs from module to module.

Of course, all of this is currently possible, but it is surprisingly complicated and not intuitive to realize, for example, a very simple direct tally assignment of a mixer input to a camera.

@Julusian
Copy link
Member

Julusian commented Mar 6, 2024

My thinking for this (and more generally for #372 and #1052) is based around home-asssitant:
image

Which basically needs us to implement some building blocks such including:

  • an action which can be an if/else possibly with an arbitrary number of elseif
  • a feedback which can perform an AND using 1 or more other feedbacks as the 'options'
  • a feedback which can perform an OR using 1 or more other feedbacks as the 'options'

An argument could be made for also adding some 'when condition is false' actions to triggers, but the same can be achieved by using the if/else instead.

Perhaps something else to think about is a way to use a feedback in an expression, through some temporary local variable.

@phillipivan
Copy link
Author

For reference the #1 thing I use XORs for in that kind of system is turning momentary inputs (ie GPIs) into latching states; which is a common task for me.

@Coupe70
Copy link

Coupe70 commented Aug 24, 2024

+1 for an "Else Action"

Event is true ->
Condition is checked.
If condition is met, perform action(s) x.
ELSE perform action(s) y.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/backend Something in the core of companion area/gui GUI / Webapp related area/internal Related to an internal action or function of Companion. Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants