ESPHome issue with a repeater (NAT)

Thanks, this looks like a solution. 2 questions:

  1. WAN IP of the router? Is this the gateway i.e.192.168.0.1 (for instance) or the ISP assigned external WAN IP i.e. 156.155.x.x
  2. You have used 192.168.0.144 as the WAN IP and 192.168.4.144 as the static_ip. Is the .144 significant in any way or just random?

Thanks in advance

Edit: finally got it working. Steps below:

  1. Use this for the ESP32 router (GitHub - dchristl/esp32_nat_router_extended: a simple ESP32 NAT Router with some additional features). This allows for port mapping on the ESP32 router itself. Install as per normal.
  2. Normal steps on setting up the AP settings and the STA settings
  3. I set up a static ip for the ESP32 router in my home router - in my case I set it to 192.168.0.202
  4. On the ESP32 router page (192.168.4.1) go to ā€œPortmap configurationā€ and set up 2 portmaps:
    • One for port 6053 to (in my case) 192.168.4.202 (the .202 does not have to be the same but it does
      help mapping the .0.202 on the main vlan to the .4.292 on the .4 vlan
    • One for port 8266 to (in my case) 192.168.4.202
  5. In the ESP device (that is sitting behind the ESP32 router) use the settings as above. In my case this would be:
wifi:
  ssid: xxxx #SSID of the ESP32 router
  password: yyyy #pw of the SSID of the ESP32 router
  fast_connect: true
  use_address: 192.168.0.202 #this is the WAN IP of the ESP32 router on the main vlan.    

  manual_ip:
    # Set this to the IP of the ESP device that is being connected
    static_ip: 192.168.4.202
    # Set this to the IP address of the router. Often ends with .1
    gateway: 192.168.4.1
    # The subnet of the network. 255.255.255.0 works for most home networks.
    subnet: 255.255.255.0
  1. If the ESP32 device is present in the ESPHome integration in HA then delete the device and re-add the device (ā€œ+Add Deviceā€ button in the bottom right hand corner) and use 192.168.0.202 as the IP of the device to be added. This should now show as available in the ESPHome integration with data for the sensors

This set up finally worked for me, the ESP32 device is visible. Thank for the advice in the thread

Glad it worked for you. Was trying to remember all the details as I did this long time ago and since then it was just the update to the ESPHome version that I needed to do.

Hi,

Thanks for the instructions. I works.
The log works and shows everything, but the entities are unavailable in HA.

As I wrote above I use this method to connct to ESP behind router for 3 years now.
However, last week I noticed the HA ESP integration going unavailable and staying like that indefinitely. Deleting the integration and creating it again made the integration working again. Lately I observed that this is happening after power off/on of the ESP.

So today I decided to investigate what is going on. Seems with the latest HA even though the setting of ESP integration is based on the ā€œuse_addressā€ field (in my case 192.168.0.144), HA zeroconf requests and ESP answers mDNS with the static_ip (192.168.4.144). Subsequently the HA will use this static_ip which will obviously not connect. See wireshark log below.

screenshot

A simple solution is to disable the mDNS in ESP, just add the following in the project yaml:

mdns:
  disabled: true

Hope this helps.

use_address is only supposed to be used on a one off basis when changing the IP of the esp device.

Indeed. However, the same technical mechanism happens when the ESP is run behind the router. Thatā€™s why it works.

edit to add more: The fact that I setup an ESPHome integration using IP address but HA still uses zeroconf to find the ESPā€™s IP, I consider to be a design issue or a bug. HA should just use that IP.

1 Like