Differentiate network name from node name

Is it possible to have a device use a different name on the network (DHCP name) than it does in ESPHome (node name)?

Specifically my problem is that ESPHome naming only allows underscores and not hyphens. My DNS server (bind9) only allows hyphens and not underscores!

So now I can’t name my device “garage_smart_light_1”, it has to become something like “garagesmartlight1

so call it garagesmartlight1

Clearly I’m aware of that option. I’m looking for better options.

Get a better DNS server?

1 Like

I think underscores are still not allowed in hostnames, so bind is behaving appropriately, I mean it is the de rigeur DNS server on the internet!

mDNS is not something I am prepared to research after 10 pm on a Friday night.

I’m going to assume there is no such option available in ESPHome, or someone would have provided a constructive response. I’m still fairly new to it, so wasn’t sure if I’d missed it somewhere.

All I can think of is to name it with dns allowable names, basically use hyphens.

Hyphens are not allowed in the ESPHome device’s hostname because that does not work with how it translates into code.
It’s the DNS vs mDNS predicament.

I decided to use the use_address option to set the device’s IP address, and assign a static address on my DHCP server. The DNS name can then be whatever you want (with hyphens).

1 Like

If only I could. But ESPHome does not allow them.

I don’t know too much about mDNS, except that sometimes it takes priority over DNS and breaks my name resolution. On Mac I have to kill the mDNSResponder process to resolve names correctly again :frowning:

I used to do this and got sick of it. I don’t want to have to maintain so many static DHCP assignments/DNS entries.

Yeah @exxamalte pointed that out so I didn’t bother posting a correction. I did now.

I know right! Just let me run my DNS and DHCP servers and stop putting all this mDNS shit on my network!

2 Likes

After further digging I found some more details about ESPHome and hyphens on GitHub:

But sadly the PR has gone stale and been closed, no activity since October 2019.

Well! Turns out the code change to allow hyphens in ESPHome was trivial, so I made the change and @OttoWinter accepted it!

  • Feature request here: #418
  • Accepted PR here: #1223

I expect it will be in the next release.

2 Likes