Set wifi phy mode to 802.11b/g

Glad to thanks to all Home assistant all developer and creator for this great piece of software.

Issue:
How to set esp8266 wifi phy mode to 802.11b/g.
Due to multiple noise in 2.4ghz channel the module keep connecting and disconnecting until router assign a clear channel (1-14).
The Ap tp-link deco doesn’t have manual option to set channel width.

Goal:
Use esp8266 over 20mhz channel width which have less interference.

More info:
Sometimes deco set channel which have less interference the esp8266 get stable for 19hr.
And set channel have high interference the esp8266 keep disconnecting in every 2-30min.

stable: least interference channel
unstable: most interference channel

mod2

No connection drop and reboot when connected over least interference channel.

Pretty sure you will have to do that in a lambda using wifi_set_phy_mode

see Change Wifi standard b/g/n to make the most output power - Everything ESP8266

Can you provide yaml code, i’m new to home assistant and yaml.
By the way thanks for help.

Well automatic change of channel in Wifi AP is always a bad idea, it generates a lot more of problems than it solves :wink:

How i can add this code to esphome module.

#include <ESP8266WiFi.h>
void setup() {
    WiFi.setPhyMode(WIFI_PHY_MODE_11B);
}

This is all i want to do…

Found the solution, now the device stay connected 2hr without lose wifi connection and uptime 16hr.

cons:
now esp become power hungry.
5v 0.7a - unstable
5v 2a - stable

esphome:
  name: "l2-front"
  includes:
  # - cs_l2_front.h
  on_boot:
    priority: 600
    then:
      - lambda: WiFi.setPhyMode(WIFI_PHY_MODE_11G);