Open
Description
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
Button text can be entered either as text (with inline variable support) or as an expression with numerous calculations and functions available. For the modules on the other hand there is the option to allow users to enter variables in textinput options and then parse the variables in the text.
The goal of this feature suggestion is to extend the expressions functionality to all action options.
Aspects:
- The options get a new optional (mandatory if expression is present) property
expressionEnabled: boolean
to store if the expression or the original input is used - When the option expressionEnabled is set, the input element gets a toggle button to switch between the default input (ordinary textinput, dropdown, checkbox, number slider...) and an expression textinput
- When the expression is changed or a variable used in the expression changes, the result of the expression is calculated and typecasted to what the option needs
- textinput -> result as string
- chekbox -> result is truthy value
- number -> result parsed as number
- dropdown -> when result is number then index of options, when text then matching item
- multidropdown -> when result is array of numbers or strings then multiple items, when number or string then single item
- variable -> result as string
- failed expressions should give null and the module can decide what to do then
- the expression doesn't change what is written in the value of the original option, at execution time either the original value or the expression result is used
- The options get a new optional property
expression: string
to preset the expression itself - The option gets a new optional property
affectsSubscription
. Calls to subsribe/unsubscribe would only be made if the option changes and this property is not set to false
Possibilities tbd:
- extend expressions also to feedback options, but not sure about the usecases at the moment. It would require to track feedbacks with expressions and then recalculate them if any used variable in the expression changes
- how/where to store expressions, enable state of expressions and affectsSubscription in the database
- should there be range checks at core level or should this be left to the module (like with regex also is only a visual hint)?
Usecases
Using variables or custom variables in actions and at the same time retaining the convenience of input elements like dropdown menu for manual selection.