Interface CompanionActionDefinition

The definition of an action

interface CompanionActionDefinition {
    callback: ((action, context) => void | Promise<void>);
    description?: string;
    learn?: ((action, context) => undefined | CompanionOptionValues | Promise<undefined | CompanionOptionValues>);
    learnTimeout?: number;
    name: string;
    options: SomeCompanionActionInputField[];
    subscribe?: ((action, context) => void | Promise<void>);
    unsubscribe?: ((action, context) => void | Promise<void>);
}

Properties

callback: ((action, context) => void | Promise<void>)

Called to execute the action

Type declaration

    • (action, context): void | Promise<void>
    • Parameters

      Returns void | Promise<void>

description?: string

Additional description of the action

learn?: ((action, context) => undefined | CompanionOptionValues | Promise<undefined | CompanionOptionValues>)

The user requested to 'learn' the values for this action.

Type declaration

learnTimeout?: number

Timeout for the 'learn' function (in milliseconds) Companion sets a default value of 5s, to ensure that the learn does not get stuck never completing You can change this if this number does not work for you, but you should keep it to a sensible value

name: string

Name to show in the actions list

The input fields for the action

subscribe?: ((action, context) => void | Promise<void>)

Called to report the existence of an action Useful to ensure necessary data is loaded

Type declaration

    • (action, context): void | Promise<void>
    • Parameters

      Returns void | Promise<void>

unsubscribe?: ((action, context) => void | Promise<void>)

Called to report an action has been edited/removed Useful to cleanup subscriptions setup in subscribe

Type declaration

    • (action, context): void | Promise<void>
    • Parameters

      Returns void | Promise<void>