Skip to content

Offline badge with name_add_mac_suffix: true — mDNS broadcast name ≠ catalog name #2480

Closed as not planned

Description

@aioue

Summary

Device Builder shows Offline (or stays Unknown then goes Offline via ping) for ESPHome nodes configured with name_add_mac_suffix: true, even when:

  • Home Assistant's ESPHome integration is healthy and entities update normally
  • The device is reachable on the LAN (ICMP to its IP succeeds)
  • mDNS resolution of the suffixed hostname works from inside the add-on container

The root cause is a name mismatch between the YAML catalog key (esphome.name, e.g. example-node) and the mDNS broadcast name ({name}-{mac_suffix}, e.g. example-node-aabbcc).

Environment

Item Value
Device Builder backend esphome-device-builder 1.7.0
ESPHome CLI / add-on 2026.7.3
Add-on image ghcr.io/esphome/esphome-hassio:2026.7.3
host_network true
Device ESP32-S3 class board
YAML esphome.name example-node
YAML name_add_mac_suffix: true
mDNS broadcast example-node-aabbcc._esphomelib._tcp.local.

Steps to reproduce

  1. Configure any ESPHome device with name_add_mac_suffix: true and a short base name (under 24 chars).
  2. Flash and confirm HA integration works.
  3. Open Device Builder in the HA add-on ingress UI.
  4. Observe the device card shows Offline (reachability drawer: "via ping").

Expected behavior

Device shows Online (via mDNS) once the _esphomelib._tcp service is visible, matching HA integration health.

Actual behavior

  • Pre-fix log line (repeated every ping sweep):
    Device example-node (example-node.yaml): unknown → offline (via ping)
    
  • Post-fix (with patch applied): unknown → online (via mdns) within ~1s of browser start.

Evidence (from inside the add-on container)

mDNS resolution:

split ('example-node', 'aabbcc')
suffixed ['192.168.x.x']    # example-node-aabbcc.local
base None                   # example-node.local — does not exist

Zeroconf browse finds example-node-aabbcc._esphomelib._tcp.local. at a routable LAN address.

Ping to that address succeeds from the container.

Cross-VLAN mDNS is enabled on the relevant VLANs — not a network/reflector issue.

Root cause

Two code paths assume the mDNS service instance name equals the configured esphome.name:

  1. MdnsSource._on_esphomelib_service_state_change (mdns.py ~484): _find_device_by_name(device_name_from_service(...)) looks up example-node-aabbcc in the catalog; configured name is example-node → short-circuit, announcement ignored.

  2. Ping sweep (ping.py): resolves device.address ≈ example-node.local (from StorageJSON fallback in _loading.py). That hostname does not exist when name_add_mac_suffix: true — only {name}-{suffix}.local is registered.

The adopt flow already handles broadcast ≠ catalog name via probe_device(name, service_name=mdns_name) (importable.py ~279), but there is no equivalent for ongoing name_add_mac_suffix monitoring.

PTR ownership: _apply_service_info also gates ONLINE on _has_live_ptr(device_name, ...) using the catalog name; with mac suffix the live PTR is under the broadcast name, so even a partial fix must use the broadcast label for PTR checks.

Proposed fix

  1. Add _find_device_for_mdns_broadcast(broadcast_name) on DeviceStateMonitor: exact match first, then strip a trailing -{6hex} MAC suffix when it matches a unique configured base name (disambiguate duplicate names by MAC when known).

  2. Route esphomelib/http browser callbacks through that mapper; apply state against the catalog name, but check PTRs against the broadcast name.

  3. In the ping sweep, when device.address fails to resolve, also try {name}-{mac_suffix}.local from the device's known MAC (once mDNS TXT has populated it).

I have a working patch + pytest repro (test_handler_marks_mac_suffix_broadcast_online) validated locally and hot-patched on a live HA add-on (log: unknown → online (via mdns)).

Notes

  • status_use_ping was removed from the add-on schema in Device Builder 2026.6+; the FAQ still mentions it. There is no UI toggle — ping fallback is always active when ICMP works.
  • Setting wifi.use_address to a static IP does not fix the offline badge (tested); the mDNS name mismatch is the blocker.
  • Workaround: set name_add_mac_suffix: false and use a unique literal name (or adopt with suffix baked into esphome.name).

Activity

  1. aioue commented on Aug 1, 2026

    @aioue
    Author

    Patch tested on live system, restores "Online"

    Image
  2. aioue commented on Aug 1, 2026

    @aioue
    Author

    Draft patch for the behaviour described above (not proposed as the definitive fix): #2481

  3. bdraco commented on Aug 1, 2026

    @bdraco
    Member

    The current design is that when you adopt a device in the dashboard it removes name_add_mac_suffix: true and flashes the device to remove it. Its intended for provisioning devices out of the box, and than adopting them in the dashboard. We don't have a way to link the specific device to the mac suffix and picking the first possible match would potentially promote the wrong device online.

  4. bdraco commented on Aug 1, 2026

    @bdraco
    Member

    Thanks for the thorough writeup and the patch, the investigation quality here is genuinely appreciated.

    After looking at this carefully we're going to keep the current behavior. name_add_mac_suffix is a provisioning feature; it exists so a factory can flash one image to many units and each one shows up on the network with a unique name. Once a device is adopted, the dashboard bakes the suffixed name into esphome.name as a literal and turns the option off, and that's the intended production state. A managed config that keeps the option on is one YAML that can be running on any number of physical units at once, and the dashboard's device model is one row per YAML file; there's no safe way to bind that row to a specific unit. Mapping suffixed broadcasts back to the base name means whichever unit announces first gets promoted, and its IP, version and config hash get stamped onto the row; with more than one unit the row flaps between them, and the MAC can't disambiguate because we only learn a device's MAC through paths that require the name to have matched already. For what it's worth the legacy dashboard had the same limitation; its status tracking was also keyed on the configured name.

    The supported paths are to adopt the device, which bakes the suffix in for you, or to give the config a unique literal name; you already found the second one as your workaround.

    Good catch on the FAQ still mentioning status_use_ping, that reference is stale and we'll get it cleaned up.

  5. bdraco commented on Aug 1, 2026

    @bdraco
    Member

    Looks like esphome/esphome.io#7070 already dropped the FAQ item.

  6. aioue commented on Aug 1, 2026

    @aioue
    Author

    Appreciate your thorough reply. I didn't fully absorb that the Dash is not a representation of specific units - that just happens to be my use case.

    Again, thank you for taking the time to explain. Have a great weekend 🖖

  7. locked and limited conversation to collaborators on Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions