Route ESPHome to Homeassistant via Tailscale

For a possible future deployment of ESPHomes at a different location, I wanted to know how much hassle this would be by using Tailscale to route between the two locations. I already have Raspberry PI Zeros deployed at a second location that push to my Homeassistant via tinc VPN. But there is no way to install tinc on ESPHome. Wireguard seems to be supported on ESP32s but with a few disclaimers. Currently I am mainly using Picos, but I may try Wireguard on ESP32 at some time in the future.

To get an ESPHome device routed to my Homeassistant I used the subnet option in Tailscale as described in there knowledge base. For this I used an old Raspberry PI zero as router at the different location. After enabling the IP forwarding, announcing the route, approve it and accepting it on my Homeassistant Linux everything worked as expected.

The command I called on the routing PI:

sudo tailscale up --advertise-routes=192.168.56.0/24

I tried to disable SNAT (--snat-subnet-routes=false) but this didn't help on the one issue this whole thing still has: no auto detection in Homeassistant probably because mDNS throught the subnet router doesn't work.

So after adding an ESPHome device to the routed subnet I needed my notebook the get the IP address. I watched the logs of the device with:

docker compose run --rm esphome logs pico5.yaml

The alternative would be to look on the internet router (a Fritzbox) or try a nmap broadcast to get the IP address. Adding the IP address in the Homeassistant ESPHome integration and everything works:

img1

(Automatic) changing of the IP address is an issue here. With mDNS the address will be automatically updated in Homeassistant, but without the device will not be polled after the change. I will monitor this and maybe decide that a second Homeassistant is the better alternative.