HA Intermittently Changes IP Address for an ESPHome Device

Background:

My ESPHome setup has been stable for over a year, but recently (probably after an update), the Home Assistant ESPHome Integration has started intermittently changing the IP address when trying to connect to an ESPHome device. This causes the following error:

WARNING (MainThread) [aioesphomeapi.reconnect_logic] Can't connect to ESPHome API for pana-hz25tke @ 192.168.9.119: Error connecting to [AddrInfo(family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, proto=6, sockaddr=IPv4Sockaddr(address='192.168.9.119', port=6053))]: [Errno 113] Connect call failed ('192.168.9.119', 6053) (SocketAPIError)

The actual IP address for the ESPHome device is 192.168.9.106, but for some reason, Home Assistant changes it and tries to call the device using the erroneous ip address 192.168.9.119.

If I remove and then re-add the device in HA Integrations ESPHome using its correct IP address (not host name), it works but after some time, Home Assistant reverts to the incorrect address 192.168.9.119. The same behavior if recompiling the device with a clean build.

The only workaround I’ve found so far is to use the ESPHome WiFi Component configuration variable use_address, see “ESPHome Device Config Snippet” below. As soon as I remove use_address from the device config, the problem reoccurs.

Just to clarify:

  • My home network is 192.168.100.xx, where I have the HA server, but the ESPHome device is on another location with a different subnet (192.168.9.xx) without IP multicast propagation, ie there’s no mDNS discovery relay between them.
  • The IP address 192.168.9.119 has never been used before, neither by ESPHome nor by any other device on the network.
  • Since the device is on a different subnet, the ESPHome add-on is configured with the option ’status_use_ping: true’ which uses ICMP ping instead of mDNS to check if nodes are online.

Questions:

  1. Is there a way to troubleshoot why Home Assistant intermittently changes the IP address for the ESPHome device?
  2. Should I file a bug report for this issue, and if so, where?

Version Info:

  • ESPHome: 2024.10.3
  • Core: 2024.11.0
  • Supervisor: 2024.11.2
  • HA OS: 13.2
  • Frontend: 20241106.0

ESPHome Device Config Snippet:

substitutions:
  devicename: "pana-hz25tke"
  long_devicename: "Panasonic HZ25TKE"
  pcb_version: "LHA01-231102"
  
esphome:
  name: "${devicename}"
  # name_add_mac_suffix: false ## if 'false' use different names/hostnames for each device!
  comment: "${long_devicename} ${pcb_version}"
  project:
    name: "esphome.pana-climate"
    version: "${pcb_version}"

esp32:
  board: wemos_d1_mini32
  
wifi:
  manual_ip:
    static_ip: 192.168.9.106
    gateway: 192.168.9.254
    subnet: 255.255.255.0
    dns1: 192.168.9.254
  use_address: 192.168.9.106

Opened an issue on GitHub: Home Assistant Core Issue #130552.

Sometimes it is due to a mDNS record that are wrong and a device in your network will keep that wrong record and retransmit it after you have changed it manually, which reverts your changes.

I do not know if there is a way to solve it by managing the mDNS network.
Normally I tell people to shutdown all network devices and once all is down then start them up again.
mDNS is a serverless system, where the data will be reconstructed from devices that announce their presence once the devices are up again.

Also make sure that you do not have another device with that IP address, because then it can be your DHCP server/router that tries to move your device to another IP.

1 Like

Yeah, but since I’m only using regular IP addresses and not hostnames in the HA ESPHome Integration, why should HA even bother to resolve anything at all, right?

My home network is 192.168.100.xx, where I have the HA server, but the ESPHome device is on another location with a different subnet (192.168.9.xx) without IP multicast propagation, ie there’s no mDNS discovery relay between them. Also, the erroneous address 192.168.9.119 has never been used, which makes this all even a bigger mystery!

It would be interesting to see if there’s a way to troubleshoot the resolver to figure out what’s going on behind the scenes.

EDIT:
It seems like others have had similar issues, so maybe it’s worth looking into this further to get to the root cause.

Two very similar cases that remain unsolved:

Hello i think it is a mdns problem in homeassistant after an update.

1 Like