bitfocus / companion

Bitfocus Companion enables the reasonably priced Elgato Streamdeck and other controllers to be a professional shotbox surface for an increasing amount of different presentation switchers, video playback software and broadcast equipment.
http://bitfocus.io/companion
Other
1.47k stars 489 forks source link

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 phillipivan opened 4 months ago

phillipivan commented 4 months ago

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

Is there an existing issue for this?

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 commented 4 months ago

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.

hadphild commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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

dnmeid commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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 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 commented 3 months ago

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.