Service to update zeroconf / mdns entries (e.g. for ESPHome)?

Hi all,

HomeAssistant loses track of my mdns devices if they change IP address, which drives me nuts. I know that I could just assign static IP address for each of these on my DHCP server, but that kind of defeats the purpose of using mdns in my opinion – if I’m going to do that, I might as well just use the IP address.

ESPHome, for example, uses mdns by default. I use the native API, which works awesome, but every couple of weeks I find that a device has dropped off from HomeAssistant, usually at the most inopportune moment, and so far the issue is usually that the IP address of the device has changed, and unfortunately HomeAssistant requires a restart to pick up the new address from mdns.

Does anyone know if the zeroconf service is exposed somehow so that I could put it in an automation?

For example, I can imagine something like the following pseudocode:

trigger:
    to: device.unavailable
condition:
    integration: ESPHome
action:
    service.start
    zeroconf.discover_devices
alternatively
    zeroconf.resolve
        id: mydevice.local

I’ve seen threads with other users with this issue. Is the only solution to manually set static IP addresses for all of these devices?

@n8henrie , I know this thread is ancient, but anyway: (how) did you solve this in the end?

Nothing very satisfying – upgraded to a pfsense router and set static IP addresses. ¯\_(ツ)_/¯

@n8henrie okay, probably also my way to go, thanks! :slight_smile: . Can you tell me how to “teach” HA under which new ip the esp can be found after you defined the static one?

I think I just deleted the devices and it automatically re-discovers them.