I have a very strange issue for the esphome integration.
I have a m5stack atom device (ESP32 based) flashed with esphome and connected to home assistant. The device is named m5stack-atom-speaker-kit-af4e34. Previously it got an IP address 10.151.30.102. Some day I decided to reserve a new DHCP IP address 10.151.30.156 for this device with the FQDN m5stack-atom-speaker-kit-af4e34.iot.pitwinken.com from my DNS server. However, I encountered a strange problem. No matter the way I tried to let home assistant use the new IP address for the esphome device, after restart of home assistant, the configuration reverted to the old IP address on its own, making connection to the esphome device fail.
I have tried:
Deleting the device from the esphome integration page and re-adding it with the FQDN. The connection is successful afterwards. But the problem appears again after restarting home assistant
Stopping the HA container, manually editing the core.config_entries to change the old IP address to the new one, and starting the HA container again, as described in the thread titled “Device IP change - how to update in HA without having to re-add device and reconfigure scripts” (sorry can’t post too many links for a new user). The manual changes get reverted after starting the HA container.
In both cases, I can watch the relevant entry in the core.config_entries get reverted right after home assistant start-up with the linux watch command.
I am out of ideas. Anyone knows how to solve this? Thanks
System set-up
Proxmox running virtual machine with docker installed. The docker-compose file is as follows:
and reinstall m5stack-atom-speaker-kit-af4e34 thereafter.
Additionally, if you are using somerthing like Pi-Hole within your LAN check whether you have added an entry for that device within “Clients” and change the ip-address if so.
@Tamsy thanks a lot for your ideas. I have checked that my esphome config that use_address is absent. Also I use Technitium DNS instead of Pi-Hole, and I have checked that my DNS entries are correct there.
I then browsed the code for configuring devices in esphome integration (relevant code on github dot com/home-assistant/core/blob/dev/homeassistant/components/esphome/config_flow.py, have to post it like this again due to the stupid two hyperlink limit for new users on this forum), trying to gain some insights. Without understanding much what’s going on (the home assistant codebase is definitely huge), it seemed that apart from zeroconf (async_step_zeroconf function), MQTT is also used for auto-discovery (async_step_mqtt function). I then checked my MQTT broker with MQTT explorer.
Boom, that’s it. There was a lingering retained topic esphome/discover/m5stack-atom-speaker-kit-af4e34, with the wrong old IP address. I cleared that topic, restarted home assistant, and home assistant still uses the correct new address afterwards.
I have added the following entry in the esphome m5stack-atom-speaker-kit-af4e34.yml as a workaround back then. It seems that my media player refuse to work without the log being sent to somewhere. I didn’t have much time to debug the issue back then so I didn’t report it to esphome. I believe that I didn’t put discovery: false in the section under mqtt at one time, causing it to put a discovery message on the MQTT broker. The message didn’t get clear afterwards and left as is, causing the trouble.