Subnet changed and not can't update ESPHome devices

I did a major change to my network, putting my HomeAssistant on new subnet. All my devices now have new IP addresses and now don’t connect. My the only option I can see is to reflash each device but this will require me disassembling everything to then reflash each device. Is there an easier way that I can do this. I was hoping HomeAssistant would rediscover the devices with their new IPS but alas that has not happened.

I should have added that my Home Assistant server is on a different subnet to esp devices but they can be pinged from the Home Assistant subnet.

I will eventually move it across to but haven’t had a chance. I just mention this incase this might make things easier.

I am using DHCP with IP reservations.

Are there two changes here?

  1. HA now on a different subnet to the ESP devices
  2. ESP devices all have new IP addresses: why?

Yes and no. HA was always on a separate subnet to some devices. I have been in the process of trying to move HA to my IOT subnet for a while. I upgraded my firewall so devices to move all the espdevices across, as well as try and group the reservations so everything changed… I did not think it through very well… if I have to reflash so be it but I am hoping there is an easier way.

When I made an IP change on the same subnet in the past HA gave me the option to reconfigure/fix but this has not happened this time

I’d imagine mDNS isn’t working across the two subnets but without full knowledge of your setup it’s hard to say.

If you can install ESPHome standalone on the same subnet, you can reach them wirelessly. I run it as a separate Docker container, independent of HA.

I am using pFSense for my firewall/DNS etc. Just tested by ssh to an machine in another subnet and mDNS seems to be working. This said, I thought ESPHOME works off IP so DNS should not be an issue… or am I missing something? Re ESPHome on the same subnet, could I not just move HA to the same subnet and see if it discovers them?

I recently moved my esphome devices to a different subnet. All devices are using static ip. I have to add some additional firewall rules to router. I tested things a few time, rebooting router etc to see will everything works. For now this is my firewall config

iptables -D FORWARD -i br0 -o br53 -p icmp -j ACCEPT >/dev/null 2>&1
iptables -I FORWARD -i br0 -o br53 -p icmp -j ACCEPT
iptables -D FORWARD -i br53 -o br0 -p icmp -j ACCEPT >/dev/null 2>&1
iptables -I FORWARD -i br53 -o br0 -p icmp -j ACCEPT

iptables -D INPUT -i br53 -p udp --dport 5353 -j ACCEPT >/dev/null 2>&1
iptables -I INPUT -i br53 -p udp --dport 5353 -j ACCEPT
iptables -D INPUT -i br53 -p tcp --dport 5353 -j ACCEPT >/dev/null 2>&1
iptables -I INPUT -i br53 -p tcp --dport 5353 -j ACCEPT
iptables -D FORWARD -i br53 -p udp --dport 5353 -j ACCEPT >/dev/null 2>&1
iptables -I FORWARD -i br53 -p udp --dport 5353 -j ACCEPT
iptables -D FORWARD -i br53 -p tcp --dport 5353 -j ACCEPT >/dev/null 2>&1
iptables -I FORWARD -i br53 -p tcp --dport 5353 -j ACCEPT

iptables -D FORWARD -i br53 -o br0 -p udp --dport 53 -j ACCEPT >/dev/null 2>&1
iptables -I FORWARD -i br53 -o br0 -p udp --dport 53 -j ACCEPT
iptables -D FORWARD -i br53 -o br0 -p tcp --dport 53 -j ACCEPT >/dev/null 2>&1
iptables -I FORWARD -i br53 -o br0 -p tcp --dport 53 -j ACCEPT

iptables -D FORWARD -i br0 -o br53 -m state --state ESTABLISHED,RELATED -j ACCEPT >/dev/null 2>&1
iptables -I FORWARD -i br0 -o br53 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -D FORWARD -i br53 -o br0 -m state --state ESTABLISHED,RELATED -j ACCEPT >/dev/null 2>&1
iptables -I FORWARD -i br53 -o br0 -m state --state ESTABLISHED,RELATED -j ACCEPT

iptables -D FORWARD -i br0 -o br53 -p tcp --dport 6053 -j ACCEPT >/dev/null 2>&1
iptables -I FORWARD -i br0 -o br53 -p tcp --dport 6053 -j ACCEPT
iptables -D FORWARD -i br53 -o br0 -p tcp --sport 6053 -j ACCEPT >/dev/null 2>&1
iptables -I FORWARD -i br53 -o br0 -p tcp --sport 6053 -j ACCEPT

iptables -D FORWARD -i br53 -o br0 -m state --state ESTABLISHED,RELATED -j ACCEPT >/dev/null 2>&1
iptables -I FORWARD -i br53 -o br0 -m state --state ESTABLISHED,RELATED -j ACCEPT

iptables -I FORWARD -i br0 -o br53 -p tcp --dport 3232 -j ACCEPT
iptables -I FORWARD -i br53 -o br0 -p tcp --sport 3232 -j ACCEPT

I also added adition rule to avahi on router

[reflector]
enable-reflector=yes

Esphome devices can communicate with home assistant and they are available using avahi-browse -a within ha network.

It is likely to be an mDNS issue not broadcasting between subnets. If you know the IP addresses of the ESPHome nodes if you add the manual IP address to the YAML HA will use this address for OTA updates. If you do this I would add DHCP reservations for each device so your router doesn’t hand out a conflicting one via DHCP. You shouldn’t need to reflash manually as it will use the IP address assigned within the config for an OTA update.

wifi:
  # ...
  manual_ip:
    # Set this to the IP of the ESP
    static_ip: 10.0.0.42
    # Set this to the IP address of the router. Often ends with .1
    gateway: 10.0.0.1
    # The subnet of the network. 255.255.255.0 works for most home networks.
    subnet: 255.255.255.0

See WiFi Component — ESPHome

In my case it wasn’t just mdns problem. This was the first thing I tried. mdns was working. i could see devices from ha network in avahi but devices were unavailable communicate with ha. I had a lot of dropped packages in firewall when devices tried to communicate to ha ip. Firewall rules solved that problem in my case.

This is precisely why the use_address parameter is there.

1 Like

Yip you were correct about mDNS… move HA to the new subnet too and all is well again. The devices all popped up :slight_smile:

1 Like