Cannot get static IP to take, still using DHCP address

i picked up two esp32 boards on amazon to start tinkering with this, and i’m getting nowhere on getting them even connected let alone into HA. i was able to get the first one flashed, but it was still saying offline even though i could see it was connected on the network. from what i read, the solution there was to change it to use a static ip…but now i can’t get it to use anything other than the DHCP it first got. my wifi section in the yaml file is correct, but it’s not changing.

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  use_address: 192.168.88.90

  manual_ip:
    static_ip: 192.168.88.90
    gateway: 192.168.88.1
    subnet: 255.255.255.0

i have been trying to tinker with the use_address option, but i honestly have no idea where to go from here. can anyone assist?

What address does it get from DHCP?

also

is the IPaddress outside the range of the DHCP server some DHCP server dont like mixing boths in the same address pool

what I do

make the DHCP server work with in the range of 10.0.0.15 to 10.0.0.240

then 1 to 14 are my switches accesspoints printer
then 240 ->255 are my static IP addresses

1 Like

192.168.88.132 is where it is every time. I can see it in the logs and on the network.

yep. DHCP range is .100-.199.

i say your DHCP is not liking the 132 as it in the range 100 - 199

You need to change it to

use_address: 192.168.88.132

use_address is the OLD address for esphome to use when it uploads the new firmware.

i’m not sure i follow. it originally got .132 since that’s in the DHCP range. i’m trying to change it to .90 but it won’t take.

i tried that too, didn’t work. i’ll give it another shot though.

edit: that worked, i can see in the logs that it’s at .90 now…but esphome still shows it as offline.

seems it’s still looking for .132…

INFO Reading configuration /config/master-bedroom.yaml...
INFO Starting log output from 192.168.88.132 using esphome API
WARNING Can't connect to ESPHome API for 192.168.88.132: Error connecting to ('192.168.88.132', 6053): [Errno 113] Connect call failed ('192.168.88.132', 6053)
INFO Trying to reconnect to 192.168.88.132 in the background

if i connect it to my computer and look at the logs, it shows .90 as the new IP but the API is still saying .132…

[C][api:025]: Setting up Home Assistant API server...
[I][app:062]: setup() finished successfully!
[I][app:102]: ESPHome version 2022.6.2 compiled on Aug  8 2022, 00:33:11
[C][wifi:491]: WiFi:
[C][wifi:353]:   Local MAC: [redacted]
[C][wifi:354]:   SSID: [redacted]
[C][wifi:355]:   IP Address: 192.168.88.90
[C][wifi:357]:   BSSID: [redacted]
[C][wifi:358]:   Hostname: 'master-bedroom'
[C][wifi:360]:   Signal strength: -56 dB ▂▄▆█
[C][wifi:364]:   Channel: 1
[C][wifi:365]:   Subnet: 255.255.255.0
[C][wifi:366]:   Gateway: 192.168.88.1
[C][wifi:367]:   DNS1: 0.0.0.0
[C][wifi:368]:   DNS2: 0.0.0.0
[C][logger:275]: Logger:
[C][logger:276]:   Level: DEBUG
[C][logger:277]:   Log Baud Rate: 115200
[C][logger:278]:   Hardware UART: UART0
[C][captive_portal:088]: Captive Portal:
[C][mdns:084]: mDNS:
[C][mdns:085]:   Hostname: master-bedroom
[C][ota:085]: Over-The-Air Updates:
[C][ota:086]:   Address: 192.168.88.132:3232
[C][ota:089]:   Using Password.
[W][ota:095]: Last Boot was an unhandled reset, will proceed to safe mode in 2 restarts
[C][api:138]: API Server:
[C][api:139]:   Address: 192.168.88.132:6053
[C][api:141]:   Using noise encryption: YES

another edit: i even just tried completely wiping out the esphome container (i’m running HA in docker) and all of its data, and starting over…it still is using the .132 address for OTA and API.

If i understand correct now device IS using new IP. So, did you delete line “use address…” from yaml and saved file? If not it will show offline. That line is to be used only once: when changing IP address!

I did. it’s still showing as offline and still showing API and OTA in the logs as the old address if I connect it to the computer and view them that way.

@myle gave very good advice: Never statically-configure a device to an IP that’s within the DHCP range used by the router.

One exception: If you have reserved (in DHCP) that same address in DHCP for your device, then you can use that address. But a DHCP-delivered reserved address is essentially the same as a static-config, but it does require the device to spend a few milliseconds re-confirming its lease with DHCP, which can affect battery life.

yes, I’m aware…and as I’ve already said, .90 (where I’m trying to put it) is not inside the DHCP range. .132 is, but that’s where the router put it on the first install.

The problem is that your DHCP server still remembers the MAC address and it assigns the IP it used for that MAC previously. Go into your router and see if you can delete or forget the association.

On the other hand, why do you even want a static IP? I have more than 60 devices in my network and manually managing that many fixed IP’s is unnecessary work and an opportunity for duplicate IP’s. My servers all have a permanent lease on my router, so they act as if they have a static IP addresses. Everything else is DHCP.

that doesn’t seem accurate either because as I also said, it’s now on the new IP. the current issue is that the old ip is still showing for the API and OTA sections in the log, and it’s still showing as offline in the esphome ui.

as to why I wanted static IP, I don’t necessarily care but when I was trying to get it to work initially I had seen posts saying that setting a static IP might resolve this issue (showing as offline). I just haven’t had any luck getting it online yet…

I would remove the static IP lines and the use_address line and get the connection fixed.

Post the whole .yaml file because the “starter” file has stuff that you probably don’t need.

How did you determine that it was connected to the network?

When you test to see if it is “on the network”, are you using its DNS name, or IP address?
Since your router’s DHCP server has seen this device, what address it serves up in response to a name query is almost anyone’s guess.
Until this mystery is clarified, reference and connect to it only by IP addr directly, don’t trust the router’s DNS to be correct, yet. It will be later, once you’ve got its address working reliably.

earlier I could ping .132, right now I can ping .90. seems like a pretty solid indicator that it’s on the network.

will post the entire yaml when I have a minute at lunch.

IP address. I haven’t even bothered trying to use the name yet.

Many routers can handle quite well static IP’s in the range of DHCP, that’s definitely not a problem. The point is that if any IP is occupied by another device then DHCP server won’t assign it to another device even if it’s in the DHCP range. But, since some old lease times can be remembered fo ra day or two, it’s a good idea to reboot a router to delete all leases.

Why static IP? Well, i hate looking for my device all over IP range, if notihing else… But i have nothing but problems when i’ve had my devices set to mDNS names…

But, you said that you can ping device on IP90. So, device IS there. You also say that ESPHome tries to connect to device on old IP (132). So, make sure that line “use_Address:…” is removed, then make sure that you corrected line

 manual_ip:
    static_ip: 192.168.88.132

into:

 manual_ip:
    static_ip: 192.168.88.90

then save the file and try to connect. If it doesn’t, try to “clean-build files”.

Also check out: Settings–>Addons–>ESPHome -->Configuration and enable “status_use_ping”. If it’s not there enable “show unused config options…” to reveal. That way online status of devices will show regarding to ping, not mDNS name.