Connect ESP32 to server via VPN

This is probably something of a noob question. Sorry.
I have got a Lilygo S3 Display (ESP32) up and running in ESPhome/Home Assistant.
Nice.
What I can’t achieve: I want to place that Display in a remote network, which is connected via Wireguard-VPN to my home network (where the HA server is running).

As far as i researched the device recovery is done via mDNS, which doesn’t work via VPN. Both networks have a /24 netmask, let’s say:
Home Network: 192.168.1.0/24
Display in 192.168.2.0/24

I am looking for a config option to have the server directly connect to the display via IP (or does the display connect to the server? I don’t know).
manual_ip and use_address from the docs do not seem to be enough.

Is the desired setup possible without reconfiguring the networks?

OK, never mind.
I just found out I actually CAN add devices via IP in the devices & services dialog.
I thought I had to edit the esps yaml for that. :smile:

Works like a charme. :grinning:

Hmm, that was too fast.
The display is connected (it show the configured output) but is shown as offline in the ESPhome dashboard, so no (remote) updating and configuration.
So the question remains, where cann I tell the ESPhome dashboard how to connect to the display?

Can you ping the display from the homeasssistant server?

yes, every client in both networks is allowed to reach each other device (via IP).

Ok, then most probably the problem is in the domain name. Can you put a fixed IP in the config of the ESP? As an alternative (don’t know if a fixed IP works well with VPN) you can try using the “status_use_ping: true” option in the config.

Background is that Esphome determines whether an ESP is on/offline through mdns and that is quite known for issues. See: Frequently Asked Questions — ESPHome

The ESPHome ’ online’ status relies heavily on mDNS.
Since the ESPHome addon in itself has nothing to do with HA, and is only used to program it, you don’t need to worry about the status indication.

The ESPHome device can also be programmed from any other station. What is important that the ESP device can use HA API :wink:

By default. In the esphome add-on setting you can change it to use ping instead.

Did you actually try it? From my mileage as long the node is reachable and even if the dashboard shows (failsy) offline because mDNS broadcast can’t reach your remote network things like ota updates or logs do actually work.

I concur :wink:

Thank you all. It seems I got this working.
In the end the IP has to be static in that setup (I had status_use_ping already set).

My setup for this to work in multiple environments is:

wifi:
  use_address: 192.168.67.19
  networks:
    - ssid: !secret wifi_ssid
      password: !secret wifi_password
      manual_ip:
        static_ip: 192.168.7.19
        gateway: 192.168.7.1
        subnet: 255.255.255.0
    - ssid: !secret wifi_ssid2
      password: !secret wifi_password2
      manual_ip:
        static_ip: 192.168.67.19
        gateway: 192.168.67.1
        subnet: 255.255.255.0
    - ssid: !secret wifi_ssid3
      password: !secret wifi_password3
      manual_ip:
        static_ip: 192.168.14.19
        gateway: 192.168.14.1
        subnet: 255.255.255.0

Where I have to change use_address (no firmware recreation needed) whenever I move the device to another network.

This seems to work as indended.

Sadly before the last test, I somehow short-circuited my esp32-device (a screwdriver touched some pins) and it is probably bricked now (bootloop, or at least seems that way from periodic usb connected/unconnected sound).

But that is a problem out of this boards scope. So thank you all for helping my setup!

PS: Fixed the display. All is well. :slight_smile:

PPS: For others, interested in that setup:
The above setup (together with “use_ping=true”) allows the use in different remote networks. After the device connects to one of them two things have to be done in HA:

  • re-add the device with the new ip to make it show data
  • update use_address in config and recompile (the result does NOT to be actually flashed) to allow HA/ESPhome to reach it for remote flash.