esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
411 stars 26 forks source link

EspHome enabled wifi range extender, but missing nat #2196

Open Samu84 opened 1 year ago

Samu84 commented 1 year ago

Describe the problem you have/What new integration you would like It would be nice to enable a range extender using and esp8266 and esp8285, by pressing one GPIO, i am able to enable the function, but without NAT option, there are not data, is only connecting, i found this way to enable range extender studing arduino code. On platformio.io there is the library and there is on github also the file used to enable it on arduino: https://github.com/esp8266/Arduino/blob/master/tools/sdk/lwip2/include/lwip/napt.h Tasmota and arduino are able to enable an esp as wifi range extender, it would be nice if also esphome is able to do it, i setup a lot of esp with esphome, is more simple to program and you can do everything you need. that's why i decided to move from arduino ide to esphome, arduino was taking a lot of time to make all the code, esphome is much faster.

Please describe your use case for this integration and alternatives you've tried: binary_sensor:

Additional context

nagyrobi commented 1 year ago

Using "range extenders" is usually a cheap and bad practice, because they being all independent from the "master" AP, they increase noise and interference and in the end, you get with worse results than you had before, without any extension. Not to speak about the performance loss caused by an ESP MCU thin data throughtput, and the side effect of RF frames hitting the master ap etc.

There are proper solutions (see spec 802.11r) with multiple interconnected APs where channel negotiations are being coordinated and clients roaming from one AP to another is equally implemented. An ESP82xx doesn't have the power to do all that.

Samu84 commented 1 year ago

i think is nice to have it when you need to extend the range between more esp in a big house, avoiding to buy Wifi range extender, if is about internet navigation, yes that's right is not so good, is only about 5Mbit speed, at the moment i am using 2 with tasmota and 3 with arduino (Connected in series), this way i am able to arrive to almost 1km of distance ( no walls), sometimes some of them lose connection but is only about 5s 2 max 3 times day, same problems, sometimes worse, performance i would have with an AsusRange extender or also D-link, both when they start to lose signal can happens 20 times in 5minutes, and honestly i have more stability using tasmota or arduino

nagyrobi commented 1 year ago

Asus/DLink etc such range extenders are just as weak, forget them.

Samu84 commented 1 year ago

yes but better performance i have with esp tasmota or arduino

nagyrobi commented 1 year ago

You misunderstand. All domestic range extenders (including Asus/DLink/Tasmota/Arduino etc) make more bad than good on long term, increasing interference and making APs "fighting with each other". You shouldn't look on individual results, but overall solution. You'll end up in devices randomly connecting to one and another decreasing stability and reliability. And not only for you, but also for your neighbors.

Proper Wi-Fi coverage needs coordinated access points, where they are aware of each other etc.

Samu84 commented 1 year ago

Ok now i understand, but it would be nice this option when i need to test esphome to someone else and have temporary coverage where the wifi is missing

Regdr commented 1 year ago

wow this is a subject i am interested too, at the moment, between the router I have an esp8285 then the esp32, but the esp32 is not receiving signal because is too far, so i needed to make it completely independent from HA, MQTT, etc.., I tried to program the esp8285 with tasmota range extender, with this option the esp32 is working, but I do not like it, because I need to make all the automations for the esp8285 on HA, instead with esphome i can create all the automations and use HA just to monitor it, if the esp8285 would be able to operate like normally with the esphome plus the range extender would be perfect, so the esp32 can take the wifi signal and send the data to HA.

Jan3726 commented 1 year ago

Describe the problem you have/What new integration you would like It would be nice to enable a range extender using and esp8266 and esp8285, by pressing one GPIO, i am able to enable the function, but without NAT option, there are not data, is only connecting, i found this way to enable range extender studing arduino code. On platformio.io there is the library and there is on github also the file used to enable it on arduino: https://github.com/esp8266/Arduino/blob/master/tools/sdk/lwip2/include/lwip/napt.h Tasmota and arduino are able to enable an esp as wifi range extender, it would be nice if also esphome is able to do it, i setup a lot of esp with esphome, is more simple to program and you can do everything you need. that's why i decided to move from arduino ide to esphome, arduino was taking a lot of time to make all the code, esphome is much faster.

Please describe your use case for this integration and alternatives you've tried: binary_sensor:

* platform: gpio
  name: WiFi Extender
  internal: false
  pin:
  number: GPIO01
  inverted: true
  mode:
  input: true
  pullup: true
  on_press:
  then:
  lambda: |-
  WiFi.setPhyMode(WIFI_PHY_MODE_11N); enable wifi to N
  WiFi.mode(WIFI_AP_STA); Enable AP and STA
  WiFi.softAPConfig(
  IPAddress(192, 168, 4, 1),
  IPAddress(192, 168, 4, 1),
  IPAddress(255, 255, 255, 0)); Config IP, Gateway and Subnet
  WiFi.softAP("APtest"); Give a name to AP (optional also password)
  on_release:
  then:
  lambda: |-
  WiFi.mode(WIFI_STA); Disable AP

Additional context

OMG. that's a nice idea i am looking from really a lot of time, I tried to use your way, but yes, there is the problem with NAT, but I think some files need to be added on esphome, I tried with the files that are needed for Arduino to work like RE, using includes: on esphome, but are giving a lot of errors ESP8266WiFi.h - I think is included in ESPHOME ESP8266WebServer.h - I think is included in ESPHOME probably used for the web component used to watch the stats of sensors, to change the settings, probably need some text box or just configure wifi repeater name and pwd, when creating the binary, instead to connect to the ap is enought the captive_portal: lwip/napt.h - needs to be included in ESPHOME lwip/dns.h - needs to be included in ESPHOME LwipDhcpServer.h - needs to be included in ESPHOME

Really hope there will be some solution, I am using Tasmota too and i do not have problems at all, and honestly i do not have the problem about "decreasing stability and reliability" or with neighbors, i think my neighbors are creating problems, also because some individual (my neighbor) from one modem, has something like 3 2.4ghz wifi and 2 5ghz (Vodafone has already 4 by default in italy and some people don't know this (vodafone-wifi where is coming from?)) in 50Mq of house and when he is looking the football all my wifi goes down about -20% of signal (my RE is not in the plug), and someone have 3 wifi from one router, so if we are here to think about problems of one esp8285 used like RE, probably people should know that there are worse things in the air around us

mag1024 commented 1 year ago

@nagyrobi, you're right that many people have unrealistic expectations of what repeaters can accomplish, but the question is not whether they are the best solution, but rather whether they are a useful capability. If my sprinkler controller is having wifi issues, I could add an extra access point for the sake of this one device, or I could use a nearby esp32 to relay the minimal amount of bandwidth required from around the corner.

Anyway, I hacked up something that seems to kinda work: mag1024/esphome-nat-ap. Caveat emptor.

Regdr commented 1 year ago

Hello that's nice, at the moment i would want to try but the sp32 is in another home, now i am using an esp8285 (sonoff mini) because is included power supply and everything in a really small space, so i can hide behind a plug, this evening i try to include all the *.h required inside nat-ap.h

Many thanks for this help mag1024

nagyrobi commented 1 year ago

How do you forward the port back towards HA, if the client is also an ESPHome node?

mag1024 commented 1 year ago

How do you forward the port back towards HA, if the client is also an ESPHome node?

I haven't tried it, but ip_portmap_add() looks like it should do the trick.

nagyrobi commented 1 year ago

With static lease + port forwading configurable, this could be a viable option. But bridge mode would be even better.

Jan3726 commented 1 year ago

OMG!!! finally some good news, I am using and esp8285 too (because of the same reasons, power suplply and small space), i tried every way to make it work but i got the same problem like Regdr, then i tried also to add the *.h files one by one, but some file is not possible to find in some repository

Jan3726 commented 1 year ago

Till now i tried every way to make this function work, but there is no way to exit, unfortunately i am using already 75 esp8285 and esp8266 and move from those to esp32, it would take a looot of time to solder new board and update HomeAssistant