ESPhome not respecting hostname when name_add_mac_suffix

ESPHome 2024.5.5 and several version prior

Wrote 0x37b830 bytes to file /config/.esphome/build/box3/.pioenvs/box3/firmware-factory.bin, ready to flash to offset 0x0
======================== [SUCCESS] Took 603.27 seconds ========================
INFO Successfully compiled program.
INFO Resolving IP address of box3.localdomain
ERROR Error resolving IP address of box3.localdomain. Is it connected to WiFi?
ERROR (If this error persists, please set a static IP address:
ERROR Error resolving IP address: [Errno -2] Name or service not known

relevant parts from config

  name: box3
  friendly_name: Box3

  name: ${name}
  friendly_name: ${friendly_name}
  name_add_mac_suffix: true

router shows device hostname as box3-5ac0dc
routher shows device mac as 30:30:f9:5a:c0:dc

dig box3.localdomain FAIL
dig box3-5ac0dc.localdomain OK

homeassistant connecting and discovery without issue
ping box3-5ac0dc.localdomain from ESPhome OK

HA also uses the name-mac when adding device

All works great but ESPhome just doesnt want to use name-mac for dns query. I know to use “use_address” for OTA updates or set it to ping to prevent “offline” but hoping someone may have permanent fix or know where this is in code so I can fumble through a fix.

already an issue in github as well

While looking through the code it occurred to me “how would this even be possible?”.

If I dont know the IP there is no way I could event try to get the mac. Without a mac I definitely cannot use it in the hostname. You can provision a device one time using this but after you would have no way to use hostname since a needed value, the mac address, is missing.

Docs say
Using name_add_mac_suffix allows [creators]( to provision multiple devices at the factory with a single firmware and still have unique identification for customer installs.

I thought I could ignore this but I see this is not possible and better understand why after some thinking.

I think this would work so you may provision device for setup but after this most be commented out and name should be changed to match name-mac in device file