core: HA Intermittently Changes IP Address when calling an ESPHome Device
The problem
HA Integrations ESPHome intermittently changes the IP address when calling 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, 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 “Example YAML 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.119has 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:
- Is there a way to troubleshoot why HA Integrations intermittently changes the IP call address for the ESPHome device?
- Should I report this issue somewhere else? 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:
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
What version of Home Assistant Core has the issue?
core-2024.11.0
What was the last working version of Home Assistant Core?
core-2024.10.4
What type of installation are you running?
Home Assistant OS
Integration causing the issue
ESPHome
Link to integration documentation on our website
https://www.home-assistant.io/integrations/esphome/
Diagnostics information
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)
Example YAML 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
Anything in the logs that might be useful for us?
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)
Additional information
While the integration was acting up with the wrong IP address, the status in the ESPHome configuration always showed as ‘online.’
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 22 (2 by maintainers)
There is deffinetly a glitch in the HA/ESPHome connection. If I assign a fixed IP other than the original one HA is unable to recognize that ESP Device anymore and when trying to add it to HA devices it throughs that nonsense error of “No connection to the ESP possible. Make sure that your YAML file contains an api: line.”
When I change back to the original IP it immidiatly works and HA is able to add the device. Removing the device in HA, changing to a different IP, HA is unable to connect anymore.
NOTE ESPHome was able to connect and show online no matter which IP got assigned.