Repository navigation
feat: add hostname option to show a hostname instead of the IP address - #430
Conversation
… 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>
|
Thanks for taking a look! The previous CI run failed on the lint step, so I pushed a fix (38e62b8):
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! |
|
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 |
|
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:
So I don't know of a good maintained option, and I'd go with the configurable approach. My plan for this PR:
Does the option name |
|
Glad the simpler approach covers your use case too! |
Use the configured hostname in the URL and QR code instead of looking it up over mDNS, and drop the multicast-dns dependency.
|
Thanks! I pushed the change (149cdae): |
|
Your feature is now included in v6.2.0. Thanks for the contribution and for working through the feedback! 🙂 |
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.localis 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-mirrorplaceholder before the address is known, and it is regenerated when the address changes.Changelog
MMM-Remote-Control.js: new defaulthostname: '', used in the URL and QR code when set; no QR code for the placeholder; QR code regenerated when the address changesconfig.schema.json,README.md: document the optiontests/dom/MMM-Remote-Control.test.js: tests for the IP address, the configured hostname and the placeholderRequirements
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) andtest:dom(55 passed) pass.test:unithas one failure on Windows only (moduleManager.test.js:/vs\path separator), unrelated to this change.