Changing the IP address range of *all* IOT devices

Hi,

I know this has been asked before in one way or another, and that there have been requests to make this configurable…however I can’t quite find the answers I’m seeking…

In short I have about 80 devices (Shelly relays, climate devices, smart plugs, solar inverters, ESPs etc) that all live in a dedicated vLAN and subnet (192.168.20.0). For reasons that aren’t relevant here but that are material enough to make me flagellate myself with reconfiguration work I need to change the vLAN and IP addressing for these devices… Somewhat like the movie I’m basically changing everything, everywhere, all at once…

The required vLAN changes I have completed with no major issues, but I have yet to re-address everything. Luckily everything is on DHCP with fixed reservations and access to NTP etc is all via DNS-based hostnames to moving the devices themselves should be little more than rebooting them which I can do just by power cycling them or the circuits to which they are connected. However, in HA the IP addresses are recorded for each device and I really don’t want it to discover all ‘new’ devices…

After backing up HA (just in case) I want to:

  1. Update the subnet addressing (to 192.168.5.0)
  2. Update the DHCP reservations (e.g. 192.168.20.100 gets updated to 192.168.5.100)
  3. Power cycle the devices so that they flip over to the new addresses
  4. Watch HA re-find all the devices on the new addresses.

I think I going to crash and burn on #4.

I’ve seen suggestions to delete all the integrations so that they are re-discovered and re-added with the original names, and I’ve seen suggestions to stop HA and edit the core.config_entries file to update the addressing before restarting everything.

Is there an ‘official’ way of doing this? It seems to me that while this an edge use case from time to time some users will have to do something like this and I’m not sure HA will survive such a large shift in the device configuration…

Help? :worried:

I feel like I am just about to go through the same thing. I use the tasmota integration and I changed the ip of the mqtt server on all my IoT devices. And even though they are online (mqtt) they are still unavailable in the frontend.

Good luck man, hope it all goes well.

The way to do that is to manually edit the config file and change the ip addresses . It lives in .storage/core.config_entries

If you can do VLANs, this will be easy.

Right. I grit my teeth, took a back up, and went for it. :slight_smile:

I browsed to the files using the File Browser addon and search for files that contained references to my old IP address range: 192.168.20. and turned up three files:

core.config_entries.yml
core.device_registry.yml
core.restore_state.yml

I loaded these into Notepad ++, did a quick find and replace in each to swap “192.168.20.” for “192.168.5.”, then saved the files.

Jumped to the HA CLI, ran “ha core stop”, edited the files (now the lazy way, select all, delete, copy from Notepad++, paste, save). With the file saved time to move on to the LAN config on pfSense.

On the firewall updated the address space of the interface, applied changes, edited DHCP scope to match the new address range. Then time to change the DHCP reservations - I didn’t want to do them one at a time as there were so many, but I found I could export a backup of just the DHCP reservations…so bang them out, open the xml, quick find and replace, and load it back in as a ‘restore’. Whoop whoop…easy as!

Most of the shellies are on the lighting circuit and the rest are plugged in all over the place, so killed a few circuits at the fuse box to reboot them en-masse, then walked around the house power-cycling everything else. On pfSense I could see them all coming back so that was cool…then another walk around to get the ones I’d missed…there are too many to remember clearly!

Then back to HA, ran “sudo reboot now” to make sure she comes up clean as a whistle and then hoped for the best…

…and…

…it all came back as though nothing had happened. Literally everything just worked right away and I haven’t looked back since!

Turned out to be pretty darn easy but it was very nerve wracking as I have so many devices and so many custom configs and node red flows that I really didn’t want to be going back to the stone age.

But there you go. Game over. All went well. :slight_smile:

:stopped HA from the command line interface and then made the changes. To save hassle I cop

3 Likes

Addressing the devices by name (DNS) instead of IP would have saved the hassle…you would only have to change the dhcp scope and everything would have been fine….

as you can see below, there is no IP in my esp devices…

INFO Reading configuration /config/esphome/Midea-hvac.yaml...
INFO Detected timezone 'Europe/Amsterdam'
INFO Starting log output from mideahvac.domain.mine using esphome API
INFO Successfully connected to mideahvac.donain.mine
[07:14:35][I][app:102]: ESPHome version 2023.2.2 compiled on Feb 18 2023, 11:20:30

Just out of curiosity…why the change from 192.168.20.0 to 192.168.5.0 ?

I had to get all of my networks to 192.168.9.0 and under because there’s going to be a pile of wire guard tunnels getting built to join work and home networks together. The firewalling and routing will be hard enough as it is without have to deal with overlapping IP ranges so all parties (except for work) needed to do some shuffling… That way every site has a block of addresses to make it easier… :slight_smile:

Yes, there’s other ways of doing it but it’s the path of least pain for me…

How do I access .storage/core.config_entries?
I have renamed an ESPHome device which is still recognised as the previous name which is disabled in the config files and cannot be re-enabled.

I use WINSCP to access the files in HASS via ssh and edit them in notepad++

Thank you for your reply. I will look into that. It’s always fun to try something new.

@Clasper101
Using the SambaAddon also works fine…