Skip to content

feat: add Set Host action and host variable - #123

Merged
phillipivan merged 5 commits into
bitfocus:masterfrom
fredrikhareide:feature/set-host-action
Nov 21, 2026
Merged

phillipivan merged 5 commits into
bitfocus:masterfrom
fredrikhareide:feature/set-host-action

Conversation

@fredrikhareide

Copy link
Copy Markdown
Contributor

Allows the Ember+ provider the module connects to be changed at runtime from a button, rather than only through the config UI, so a single Companion instance can be retargeted between providers.

The new host is persisted with saveConfig so it survives a restart, and any Bonjour selected device is cleared as it would otherwise take precedence. The connection host is exposed as the 'host' variable.

Allows the Ember+ provider the module connects to be changed at runtime
from a button, rather than only through the config UI, so a single
Companion instance can be retargeted between providers.

The new host is persisted with saveConfig so it survives a restart, and
any Bonjour selected device is cleared as it would otherwise take
precedence. The connection host is exposed as the 'host' variable.

Co-authored-by: Cursor <cursoragent@cursor.com>
@bryce-seifert

Copy link
Copy Markdown
Member

LGTM, @phillipivan do you have any feedback?

@phillipivan

phillipivan commented Sep 7, 2026 •

Copy link
Copy Markdown
Collaborator

Sorry I missed this, busy week.

Since this is an unusual feature for a companion module - what is the use case where this a preferable option to adding additional ember plus connections?

However, assuming there is a good case for this feature - I think it must also include the ability to set the port, since not all ember providers use port 9000 (including Companion!), and for some devices it is configurable, so even moving from like to like connection might not be on the same port.

Comment thread src/index.ts Resolved
Comment thread src/actions.ts
subscribe: subscribeParameterAction(self),
},
[ActionId.SetHost]: {
name: 'Set Host',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest drop down to set hostname, port or both. with host and port options exposed via isVisibleExpression

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it makes sense to have this as a dropdown since the point of the feature is to set it programatically

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean is a drop down to chose between setting host only, port only or host and port.

Comment thread src/actions/host.test.ts Resolved
Comment thread src/variables.ts Resolved
Comment thread src/actions.ts Resolved
@fredrikhareide

Copy link
Copy Markdown
Contributor Author

The core goal is to standardize dynamic control surface assignment across all our modules.

In a multi-gallery broadcast environment (say, 5 or 6 control rooms), each physical position usually stays fixed with its own hardware and Buttons setup. However, the actual show or resources that position needs to control changes depending on the production.

Instead of remapping layout or changing positions inside Buttons, we handle this at the module level. We have buttons that set these connection strings to the correct address and or port.

This makes the setup very flexible and professional. I am actually hoping to get something like this into the Companion and Buttons software to be able to do this directly on the connections instead of building it into each module. But I guess that is further out.

@phillipivan

Copy link
Copy Markdown
Collaborator

Thanks for explaining.

Can I ask why not just change pages on the surface?

I can imagine the companion project as a whole would have some reticence to implement a feature like this as for some modules it's not likely to work very well - but is a whole other discussion.

Even with this module, changing connection to a dissimilar device is likely to leave all actions, feedbacks, and variables broken; or at least behaving in an unexpected manner - depending on the structure of the ember tree.

@fredrikhareide

Copy link
Copy Markdown
Contributor Author

The goal is to build the shell of the pages once and reuse them for all galleries. We have 7 or more galleries that all need these buttons. And the pages would add up fast and be a nightmare to maintain. Not sure how much you have worked with Buttons but they have a concept of Shared sections and Positions that have Position variables for doing these things. They will implement some solution for this in Buttons going forward but it will take some time. Changing the connection string is fine as long as we run the destroy and reconnect correctly. We have done this in production with the Mosart module I made for a long time.

The Set Host action now allows changing the connection port independently or together with the host. Either field can be left empty to preserve the current value. Added validation for hostnames/IPs and port numbers, a Learn button to reset to current config, and exposed the configured port as the `port` variable.
Disable emberplus-connection's internal 5s auto-reconnect and handle
retries in the module with exponential backoff (5s → 60s, reset on
connect). Stop discarded clients from retrying forever, and treat a
connect() timeout (resolved Error) as a failure.
@fredrikhareide

Copy link
Copy Markdown
Contributor Author

Hi! While working on this module I found a reconnect problem when the Ember+ device is unreachable:

Already on master: emberplus-connection retries every 5s forever. connect() resolves with an Error on timeout instead of rejecting, so the module never sees the failure. Also, discard() doesn't stop the library's retry timer if the socket never connected, so every host or port change leaves a client behind that keeps retrying.
It's made worse by the new Set Host action: each host or port change from a button or trigger now leaks one more of these clients, so they can pile up fast.

I have a fix on feature/set-host-action: the library's own retries are turned off and the module reconnects with backoff (5s → 60s, back to 5s once connected).

@codecov-commenter

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@phillipivan

Copy link
Copy Markdown
Collaborator

Please split the reconnect fix into a seperate PR.

There have been some changes to the base ember+ library connection handling, plus I am working through some bug fixes on that library, and I'd like to see where this fix sits after all that is complete; but there is no reason for the feature to wait in that.

@phillipivan
phillipivan merged commit de19525 into bitfocus:master Nov 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants