Skip to content

feat: add hostname option to show a hostname instead of the IP address - #430

Merged
KristjanESPERANTO merged 4 commits into
Jopyth:developfrom
s1len7:feat/qr-hostname
Nov 1, 2026
Merged

KristjanESPERANTO merged 4 commits into
Jopyth:developfrom
s1len7:feat/qr-hostname

Conversation

@s1len7

@s1len7 s1len7 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Feature Addition

Description

The URL and QR code on the mirror always use the first IPv4 address. On a home network that address can change with DHCP, and a name such as mirror.local is easier to read and type.

With the new option hostname (e.g. hostname: "mirror.local"), the configured name is shown in the URL and QR code instead of the IP address, e.g. http://silent-pi4-display.local:8080/remote.html. The default is an empty string, so existing setups keep showing the IP address.

The QR code is also no longer generated for the ip-of-your-mirror placeholder before the address is known, and it is regenerated when the address changes.

Changelog

  • MMM-Remote-Control.js: new default hostname: '', used in the URL and QR code when set; no QR code for the placeholder; QR code regenerated when the address changes
  • config.schema.json, README.md: document the option
  • tests/dom/MMM-Remote-Control.test.js: tests for the IP address, the configured hostname and the placeholder

Requirements

None (no new dependencies).

Additional info

Following the review, the earlier mDNS lookup (useHostname + multicast-dns) was replaced by this configurable option.

Checked locally on Node 26: node --run lint, node --run test:spelling, test:integration (18 passed) and test:dom (55 passed) pass. test:unit has one failure on Windows only (moduleManager.test.js: / vs \ path separator), unrelated to this change.

s1len7 and others added 3 commits October 29, 2026 22:23
… IP address

The URL and QR code always use the first IPv4 address, which can change
with DHCP and is harder to type than a name. With useHostname enabled,
node_helper asks the local network over mDNS (reverse PTR query via
multicast-dns) for the hostname of each address and falls back to the
address when nobody answers within 1.5 seconds.

The frontend now regenerates the QR code when the address changes and
no longer generates one for the placeholder before the address is known,
so a delayed hostname answer cannot leave a stale QR code.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@s1len7

s1len7 commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for taking a look! The previous CI run failed on the lint step, so I pushed a fix (38e62b8):

  • node_helper.js: use toReversed(), rename done → isDone, and move the hostname lookup into an async sendIpAddresses() helper instead of chaining .then()
  • MMM-Remote-Control.js: pass an explicit separator to join() and put the simple hasAddress check first

Spelling, lint, unit, integration, DOM and coverage all pass locally on Node 24. Could you approve the workflow run when you get a chance? Thanks!

@KristjanESPERANTO

Copy link
Copy Markdown
Collaborator

Thanks for the PR! 🙂

Avoiding QR-code generation for the placeholder URL makes sense.

For the hostname part, what do you think about a more pragmatic approach: making the hostname configurable instead of detecting it automatically? Hostnames rarely change in a typical home setup, so configuring it once seems reasonable. That would also avoid the lookup complexity and additional dependencies.

I'm also hesitant about adding multicast-dns, given that its latest release was over four years ago and there are some open PRs and issues. Looks unmaintained. An actively maintained alternative could still make automatic detection an option. Do you know any?

@s1len7

s1len7 commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review!

Agreed — a configurable hostname is simpler and covers my use case just as well. The hostname of my mirror hasn't changed since I set it up, and dropping the lookup removes the timeout/fallback logic and the new dependency entirely.

On alternatives for automatic detection, I checked a few:

  • multicast-dns: you're right, the latest release (7.2.5) is from May 2022.
  • bonjour-service is actively maintained (1.4.4, July 2026), but it depends on multicast-dns itself, so it doesn't really solve the problem.
  • Node's built-in dns.lookupService() would avoid any dependency, but it relies on the system resolver (nss-mdns) to resolve .local names, which usually isn't available inside a Docker container — the setup I wanted to fix.

So I don't know of a good maintained option, and I'd go with the configurable approach.

My plan for this PR:

  • Replace useHostname with a string option (e.g. hostname, default empty). When set, it is used in the URL and QR code instead of the IP address; when empty, behavior stays as it is today.
  • Remove multicast-dns and the mDNS lookup code from node_helper.js.
  • Keep the QR code fix (no QR for the placeholder, regenerate when the address changes).
  • Update config.schema.json, README.md and the tests accordingly.

Does the option name hostname work for you, or would you prefer something else? I'll push the changes once you're fine with the direction.

@KristjanESPERANTO

Copy link
Copy Markdown
Collaborator

Glad the simpler approach covers your use case too! hostname works for me. Please go ahead, and thanks for checking the alternatives! 🙂

Use the configured hostname in the URL and QR code instead of looking it up over mDNS, and drop the multicast-dns dependency.
@s1len7 s1len7 changed the title feat: add useHostname option to show the mDNS hostname instead of the IP address feat: add hostname option to show a hostname instead of the IP address Nov 1, 2026
@s1len7

s1len7 commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! I pushed the change (149cdae): useHostname and the mDNS lookup are replaced by the hostname string option, and multicast-dns is removed. The QR code fix is kept, and the PR description is updated. Could you approve the workflow run when you get a chance?

@KristjanESPERANTO
KristjanESPERANTO merged commit 08ddc1e into Jopyth:develop Nov 1, 2026
1 check passed
@KristjanESPERANTO

Copy link
Copy Markdown
Collaborator

Your feature is now included in v6.2.0. Thanks for the contribution and for working through the feedback! 🙂

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.

2 participants