Where do ESPHome devices get their IP address?

Where do ESPHome devices get their IP address?
I have a number of ESP8266 devices I made that I recently switched from my code to ESPHome. Until a couple of days ago, they all retained the IP address’ that had been previously assigned my by router.
I’m not sure what happened, but now all ESPHome devices have new IP address’.

Example:
nmap used to report

kitchen_motion.neo.rr.com (192.168.1.153)

now, ESPHome logger reports:

INFO Reading configuration /config/esphome/kitchen_motion.yaml...
INFO Starting log output from kitchen_motion.local using esphome API
INFO Connecting to kitchen_motion.local:6053 (10.42.0.218)
WARNING Initial connection failed. The ESP might not be connected to WiFi yet (Error connecting to 10.42.0.218: timed out). Re-Trying in 1 seconds

Checking the USB output from the boards with the Arduino IDE serial monitor confirms that the boards are connecting to my network at IP address’ 10.42.0.xxx

They all show as “green” on the ESPHome add-on in Homeassistant running on a “blue”.

I also have a few Sonoff’s that were converted to ESPHome and they seem to be doing the same thing.

Any help would be appreciated.
Thanks,

Depends on how you configured the ESP code. If you configured everything for DHCP, then all of your ESPHome devices are receiving their IP from your DHCP server (router). If the IP changes, then this points to a potential issue with your DHCP server such that it’s reassigning an IP when the DHCP lease expires. It’s possible when you did the code upgrade it changed an ID (not MAC) of the device and the router treated it as a new device. Because the MAC is the same as before it auto connected with the old IP, but when the lease expired the router treated it as a new device.

This is one of the reasons it is best to set a static IP on the device or set an IP reservation on your router.

Solved… not an Homeassistant or ESPHome problem.

I discovered the problem, or at least a solution.
The 10.42.0.xxx IP address’ the devices were getting were being served by my Linux laptop.
I powered down the laptop and rebooted most of the ESPHome devices and they all came back up working properly.

I don’t quite understand what happened, but it probably started the other evening with what might have been a power surge or dropout in the house.

I know the router went down.
I accidentally restarted the Home Assistant Blue when I was trying to find out what happened.
Probably the ESPHome devices were restarted.

Somehow, devices were communicating thru the router, perhaps before the router was ready to serve IP address’, and they got them from my laptop.

nmap scans showed that it wasn’t only the ESPHome devices, but a Foscam camera and a couple of Raspberry Pi’s were also showing IP’s of 10.42.0.xxx.

I corrected my laptop IPv4 config, changing from “Shared to other computers” to “Automatic (DHCP)”.
That setting was necessary when using the laptop to create a wired network to share a wifi network with other devices.

If anyone can shed light on what might have happened, I’d appreciate that…

Thanks,