Bitfocus Companion Documentation

repository·main·Indexed 25 days ago

https://github.com/bitfocus/companion

An open-source control platform for managing professional AV hardware and software through a unified interface using modules. This documentation covers installation via Docker and Docker Compose, configuration via config.yaml, Prometheus and Grafana metrics integration, and developer guides for the React UI, shared-lib, and companion-launcher.

Tokens
49K
Snippets
65
Records
317
Agent score
81%

What's inside Bitfocus Companion

  1. Introduction to Bitfocus Companion

    main

    Bitfocus Companion is a free and open-source software platform designed to control a wide variety of hardware and software devices. It supports over 700 different types of devices, including audio mixers, video switchers, lighting systems, and streaming gear.

    Companion operates through a system of modules and drivers that allow it to communicate with these devices. You can find the complete list of supported modules on the official Bitfocus website.

  2. Understand the Companion Admin Interface layout

    main

    The Companion admin interface is organized into three primary areas:

    • Sidebar (Left): Used for navigating between different pages and configuration sections.
    • Main Panel (Center/Left): The primary area for performing tasks like configuring devices, surfaces, buttons, variables, or triggers.
    • Secondary Panel (Right): Provides details, previews, or contextual settings related to the active task in the main panel.

    On smaller screens, the main and secondary panels are combined into a single view using additional navigation controls to optimize space.

    Note: If the Admin Password feature is enabled, a lock icon will appear in the top header to allow locking the interface.

  3. What is companion-launcher?

    main

    The companion-launcher is the small window that appears when running the desktop version of Bitfocus Companion.

    Since version 3.0, the launcher has been decoupled from the main Companion process. It operates as a standalone mini-application that runs Companion directly using a bundled version of Node.js. This architecture allows the Electron version (used for the UI) and the Node.js version (used for the Companion core) to be managed independently, preventing version conflicts and ensuring that the desktop experience remains consistent with headless builds.

  4. What is Companion Satellite and when to use it

    main

    Companion Satellite is a lightweight application designed to run on a separate machine to forward locally connected surfaces (like Stream Decks) to a central Companion instance over a network.

    Use Companion Satellite if:

    • Your hardware surfaces (e.g., Stream Deck) are physically located away from the Companion server.
    • Your Companion instance is running in an environment where direct USB access is unavailable, such as a server or a Docker container.
    • You have multiple operators with individual surfaces that all need to be controlled by a single central Companion setup.
  5. Store an action's result in variables

    main

    Certain module actions (such as queries or device value fetches) return a result. If an action provides a Store Action Result option, you can capture this value for use in button text, feedbacks, or other actions.

    You can store results in two ways:

    1. Local variable: Target a specific button location using syntax like $(this:page)/$(this:row)/$(this:column) and provide a variable name.
    2. Custom variable: Select an existing custom variable or choose an option to create a new one if it does not exist.

    Once stored, the result behaves like any other variable in Companion.

  6. Use logic operations in Feedbacks

    main

    Companion v3.4.0 introduced the ability to perform logical operations within feedbacks using new internal feedback types. Instead of standard option fields, these feedbacks allow you to compose logical conditions by adding other feedbacks as inputs.

    Available internal logic feedbacks:

    • internal: Logic AND
    • internal: Logic OR
    • internal: Logic XOR
  7. Manage variables and scope in Companion expressions

    main

    In multi-line expressions, you can store and update intermediate values using variables.

    Variable Declaration

    • Bare assignment (name = value): Sets a variable. If the variable doesn't exist, it is created in the current scope. If it exists in an outer scope, it updates that existing variable.
    • Declaration (let name = value): Explicitly creates a new variable in the current scope.
    • Constant declaration (const name = value): Creates a new variable that cannot be reassigned.

    Scopes and Shadowing

    Scopes are defined by blocks { ... } (e.g., inside if, for, while, or functions).

    • Shadowing: Using let or const inside a block creates a new variable that hides any outer variable with the same name within that block.
    • Persistence: To make a value survive a block (like a loop or if statement), declare it before the block using let or const, then update it inside using a bare assignment.

    Rule of thumb: Use let/const for fresh variables; use bare assignment name = ... to update existing variables in outer scopes (like accumulators).

    // Updating an outer variable (Accumulator pattern)
    let total = 0
    for (const x of [1, 2, 3]) {
    	total = total + x // updates the outer `total`
    }
    total // 6
    
    // Shadowing (Inner variable hides outer)
    let name = 'outer'
    if (true) {
    	let name = 'inner' // a separate variable
    	name // 'inner' here
    }
    name // still 'outer'
  8. Use expressions instead of feedbacks for dynamic styling

    main

    In Companion 5.0, you may not need a feedback for every dynamic change. Every property on a graphics element can be an expression. Expressions can reference variables and perform calculations, causing the element to redraw automatically whenever the underlying variable changes.

    Common use cases for expressions over feedbacks:

    • Setting a Text element's content directly from a variable.
    • Making a Text element's Color an expression (e.g., returning red or green based on $(custom:armed)).
    • Controlling visibility using the Enabled field (e.g., using blink(500) to make an element blink).
  9. Understand expression execution limits

    main

    To prevent infinite loops or excessive resource usage, Companion enforces execution limits on all expressions.

    Every expression runs under a budget for:

    1. Number of operations (loop iterations and function calls).
    2. Depth of nested function calls.

    If an expression exceeds this budget, it is aborted and treated as an invalid expression (similar to a syntax error). While the budget is generous for standard logic, keep expressions used in high-frequency areas (like field visibility checks) simple to avoid hitting limits.

  10. How feedbacks work in Companion 5.0

    main

    In Companion 5.0, a feedback allows a button to change its appearance automatically based on device state or logic. Unlike previous versions that applied a single flat style to a button, 5.0 feedbacks work by overriding properties on specific graphics elements (such as Text, Image, or Background) while the feedback's condition is met.

    Key Concepts

    • Element Overrides: When configuring a feedback, you select a specific element, then pick which properties of that element (e.g., Text element's Color or Text Size) to override.
    • Priority/Ordering: Feedbacks are applied from top to bottom. If multiple feedbacks attempt to change the same property, the feedback lower in the list (the one appearing later) takes precedence.
    • Types of Feedbacks:
      • Boolean feedbacks: These are on/off. When the condition (like an expression or variable state) is true, the overrides are applied. When false, the button reverts to its normal state.
      • Module (advanced) feedbacks: Provided by a connection/module. These can return complex styles, such as a meter or a status color, or even a complete generated image to represent device status.
  11. Use Collections to group connections, triggers, or variables

    main
    Collections allow you to group related connections, triggers, or custom variables. This enables you to manage them as a single unit, such as enabling or disabling an entire group of items simultaneously during an event. This is particularly useful for organizing complex setups.
  12. Reference variables and objects in expressions

    main

    Variables are referenced using the standard $(connection:variable) syntax. Inside expressions, variables retain their original type (number, array, object, etc.).

    Accessing Data:

    • Arrays: Use bracket notation: $(custom:my_array)[0].
    • Objects: Use dot or bracket notation: $(custom:settings).timeout or $(custom:settings)['timeout'].
    • Optional Chaining: Use ?. to safely access properties that might be missing: $(custom:settings)?.timeout.
    • Nullish Coalescing: Use ?? to provide a fallback if a value is undefined: $(custom:name) ?? 'Unknown'.
    • Spread Operator: Use ... to combine arrays or objects: [...$(list_a), ...$(list_b)].

    Note: Nested variable references like $(custom:$(custom:b)) are not supported. Use the parseVariables function instead.

    $(custom:my_array)[0]
    $(custom:settings).timeout
    $(custom:settings)?.timeout ?? 1000
    [...$(custom:list_a), ...$(custom:list_b)]