ESP in a separate network from HA

Want a solution on how to connect an ESP in an IP network that is separate from Home Assistant

Examples HA in network 192.168.1.20/24 and ESP in network 172.16.7.93/24.

The networks have IP contact with each other.

HA can ping esp but can not connect

1 Like

You cant allow mDNS between networks (or even subnets) so you must use a static ip address and manually configure the device in HA (no discovery)

See:

https://esphome.io/guides/faq.html#notes-on-disabling-mdns

Thanks for the help!

I choose to rethink and re-evaluate my needs.

You can do this, you just need to use static IP address (or addresses reserved in DHCP) for your ESP devices and to enable ping instead of mdns online detection. Then when you want to add a new device manually select the integration in Configuration / Devices / Add Integration and specify the IP address of the device.

Hereā€™s how I solved it:

Home assistant IP 192.168.1.20
ESP32 IP 172.16.7.93
IP contact between the networks

ESP32 Configuration

wifi:
ssid: ā€œā€
password: ā€œā€
manual_ip:
static_ip: 172.16.7.93
gateway: 172.16.7.1
subnet: 255.255.255.0

Home Assistant Configuration

Configuration / Devices & Services / Add Integration ā€œesphomeā€ and specify the IP address of the device (172.16.7.93)

Device is ā€œvisibleā€ in Configuration / Devices & Services, not in ESPHome on the left side.

Ping to the device and a status interface

configuration.yaml

binary_sensor:
  - platform: ping
  host: 172.16.7.93
  name: "Remotely connected esp32"
  count: 2
  scan_interval: 10

template:

  • sensor:
    • name: ESP32 Remote
      unique_id: binary_sensor.esp32_remote
      icon: >
      {% if is_state(ā€œbinary_sensor.remotely_connected_esp32ā€, ā€œonā€) %}
      mdi:antenna
      {% else %}
      mdi:access-point-off
      {% endif %}
      state: >
      {% if is_state(ā€œbinary_sensor.remotely_connected_esp32ā€, ā€œonā€) %}
      Connected
      {% else %}
      Disconnected
      {% endif %}

Iā€™m trying to sort out the same issue.

Iā€™ve added the ping to the HA configuration.yaml, but it doesnā€™t seem to help the status in ESPHome
In mine:

HA is 10.0.0.200
ESP is 10.30.0.22
Both can interact network wise fine

Status for the binary sensor shows ā€˜Connectedā€™ as a Lovelace card.
The ESPHome Device is named esphome-web-68bdec

ESPHome Device YAML

  manual_ip:
    static_ip: 10.30.0.1
    gateway: 10.30.0.254
    subnet: 255.255.255.0

HA YAML

  - platform: ping
    host: 10.30.0.1
    name: "esphome-web-68bdec"
    count: 2
    scan_interval: 10

I have the device adopted in ESPHome (just sows offline) and can update it wirelessly just fine.
I have the device and itā€™s entities also added in. This all works fine - the statuses coming and the outputs get there without any issues. If it wasnā€™t for ESPHome just showing this is disconnected, Iā€™d quite happy with the integration.

Side Note:
Not sure why this is not done more, I personally feel people are crazy to allow IoT devices on the main network. I have all mine on a subnet that is setup so only certain devices can get to the web, none of them can get to the main network (allowing only connections to HA) and none of the IoT devices can reach each other.

Wrong ping. Ignore Premā€™s post and do this instead:

Go to Settings ā†’ Add-ons ā†’ ESPHome add-on. Click the Configuration tab at the top of the page. Turn on the ā€œUse ping for statusā€ switch.

1 Like

Well, sh*t
Youā€™re now my favorite Tom
Works great! Thanks!

1 Like

Question Tom,

This worked great for the connection and recognition of the device sitting on a different subnet, but now when I configure a new device (adding it to the same network subnet as HA is on for initial config), it never appears in ESPHome to adopt.

I can get this going by turning off the ā€œUse ping for statusā€ while adding a new ESP32, then turning it back on after I get the static IP setup.

This just the the way it is then? Just a ā€˜one or the otherā€™ type of situation?
Iā€™m happy either way as this is a minor inconvenience, just curious if Iā€™m missing something here

Add the yaml config file for the device in config/esphome.

Interesting. I will give that a try then when I add my next one.
Thanks again Tom

All your yaml files for your devices should be in there. Where are you keeping them?

You can, just not with a default ā€œhomeā€ router.
For instance, pfSense / OPNSense have the ā€œavahiā€ plug-in, which forward the mDNS packets across subnets.
Works flawlessly!

2 Likes

I canā€™t believe I completely forgot about Avahi.
I implemented that years ago in one of my client networks and it did work flawlessly.

Added it to my pfSense. Thanks JeeCee!

+1 for Avahi on pfsense. I keep all my esp devices on a subnet with just about no access to anything else, and then repeat the mdns packets to my LAN so HA can pick it up.

In my case not working what are i mising ?

HA configuration.yaml

binary_sensor:
  - platform: ping
    host: 192.168.68.105
    name: "esp32 test11"
    count: 2
    scan_interval: 10

ESPhome configuration.yaml

manual_ip:
  static_ip: 192.168.68.105
  gateway: 192.168.68.1
  subnet: 255.255.255.0

esp32 test11
Disconnected

Is this throwing an error?
Yaml looks fine.

What are you trying to accomplish here?

You may find what Tom posted as a good solution.

Apologies for resurrecting an old thread. Details have changed just a little.

I found the ā€˜Use ping for statusā€™ option helpful for an ESP on a remote site running its own WireGuard tunnel. Works nicely but the option is now hidden.

You now fing it hidden slightly deeper in Settings> Add-ons > ESPHome > Configuration > Show unused optional configuration options. Then turn on ā€˜use ping for statusā€™ and then scroll down for the save button you now (probably) canā€™t see.