Wifi issues

Hi all

I’m new to ESPHome and testing on an ESP8266. It worked at first, but now I get this

[23:14:13][W][wifi_esp8266:212]: wifi_apply_hostname_(esp-stua): lwIP error -16 on interface st (index 0)
[23:14:13][W][wifi_esp8266:482]: Event: Disconnected ssid='xxx' bssid=[redacted] reason='Association Leave'
[23:14:13][W][wifi:536]: Error while connecting to network.

Any ideas?

1 Like

I’ve been trying to find a solution to this issue for months, I have tried absolutely everything. Seems that the ESP32 doesn’t encounter this issue to even half the severity of the ESP8266. My recommendation would be to get an ESP32 and ditch the ESP8266 unfortunately…

[W][wifi_esp8266:212]: wifi_apply_hostname_(developing): lwIP error -16 on interface st (index 0)
[W][wifi:536]: Error while connecting to network.

I’ve had decent luck getting the ESP8266 to work better when manually setting the IP and enabling fast_connect to it can repetitively attempt connections until it finally lands one.

wifi:
  ssid: "xxx"
  password: "xxx"
  fast_connect: true
  manual_ip:
    static_ip: 192.168.0.200
    gateway: 192.168.0.1
    subnet: 255.255.255.0

I wonder if you or @rkarlsba is using a DHT?

Best would be (as always) to give as much details as possible so the error can be reproduced at best.

This should at least include the full yaml you experience the problems with.

have same issue now with some modules:

WiFi ssid is a 2.4ghz connection. When unplug from power and later on back the module will connect at a certain moment.
Config file ESPHome:

esphome:
  name: meek-livingroom

esp8266:
  board: nodemcuv2

logger:

api:
  encryption:
    key: "HIDDEN"

ota:
  password: "HIDDEN"

wifi:
  ssid: HIDDEN
  password: HIDDEN
  power_save_mode: none
  reboot_timeout: 30min
  fast_connect: true

mqtt:
  broker: 192.168.100.24
  username: HIDDEN
  password: HIDDEN
  client_id: esphome-livingroom
  topic_prefix: esphome/livingroom
  discovery: true

light:
  - platform: neopixelbus
    default_transition_length: 0s
    type: GRB
    variant: 800KBPS
    pin: D4
    num_leds: 2
    name: "ESPHome livingroom - Neopixel1"
    id: neopixel
  
  - platform: partition
    name: "ESPHome Partition - neopixel1"
    default_transition_length: 1s
    id: neopixel1
    segments:
      - id: neopixel
        from: 0
        to: 0
  
  - platform: partition
    name: "ESPHome Partition - neopixel2"
    default_transition_length: 1s
    id: neopixel2
    segments:
      - id: neopixel
        from: 1
        to: 1

switch:
  - platform: gpio
    pin: D1
    name: "ESPHome livingroom - Switch 1"
    id: switch1

  - platform: gpio
    pin: D1
    name: "ESPHome livingroom - Switch 2"
    id: switch2

  # - platform: gpio
  #   pin: D1
  #   name: "ESPHome livingroom - Switch 3"
  #   id: switch3

binary_sensor:
  - platform: gpio
    pin: D5
    name: "ESPHome livingroom - Touch 1"
    on_press:
      - switch.toggle: switch1
      - if:
          condition:
            switch.is_on: switch1
          then:
            - light.turn_on: 
                id: neopixel1
                brightness: 100%
                red: 0%
                green: 100%
                blue: 0%
      - if:
          condition:
            switch.is_off: switch1
          then:
            - if:
                condition:
                  lambda: |-
                    return id(goodnight).state > 0;
                then:
                  - light.turn_on: 
                      id: neopixel1
                      brightness: 100%
                      red: 10%
                      green: 0%
                      blue: 10%
            - if:
                condition:
                  lambda: |-
                    return id(kodi).state > 0;
                then:
                  - light.turn_on: 
                      id: neopixel1
                      brightness: 100%
                      red: 93%
                      green: 0%
                      blue: 93%
            - if:
                condition:
                  lambda: |-
                    return id(daytime).state > 0;
                then:
                  - light.turn_on: 
                      id: neopixel1
                      brightness: 100%
                      red: 100%
                      green: 0%
                      blue: 0%
            - if:
                condition:
                  lambda: |-
                    return id(evening).state > 0;
                then:
                  - light.turn_on: 
                      id: neopixel1
                      brightness: 100%
                      red: 100%
                      green: 0%
                      blue: 0%
            - if:
                condition:
                  lambda: |-
                    return id(appletv).state > 0;
                then:
                  - light.turn_on: 
                      id: neopixel1
                      brightness: 100%
                      red: 55%
                      green: 55%
                      blue: 0%
            - if:
                condition:
                  lambda: |-
                    return id(tv).state > 0;
                then:
                  - light.turn_on: 
                      id: neopixel1
                      brightness: 100%
                      red: 0%
                      green: 25%
                      blue: 53%
            - if:
                condition:
                  lambda: |-
                    return id(nintendo).state > 0;
                then:
                  - light.turn_on: 
                      id: neopixel1
                      brightness: 100%
                      red: 36%
                      green: 28%
                      blue: 55%

  - platform: gpio
    pin: D7
    name: "ESPHome livingroom - Touch 2"
    on_press:
      - switch.toggle: switch2
      - if:
          condition:
            switch.is_on: switch2
          then:
            - light.turn_on: 
                id: neopixel2
                brightness: 100%
                red: 0%
                green: 100%
                blue: 0%
      - if:
          condition:
            switch.is_off: switch2
          then:
            - if:
                condition:
                  lambda: |-
                    return id(goodnight).state > 0;
                then:
                  - light.turn_on: 
                      id: neopixel2
                      brightness: 100%
                      red: 10%
                      green: 0%
                      blue: 10%
            - if:
                condition:
                  lambda: |-
                    return id(kodi).state > 0;
                then:
                  - light.turn_on: 
                      id: neopixel2
                      brightness: 100%
                      red: 93%
                      green: 0%
                      blue: 93%
            - if:
                condition:
                  lambda: |-
                    return id(daytime).state > 0;
                then:
                  - light.turn_on: 
                      id: neopixel2
                      brightness: 100%
                      red: 100%
                      green: 0%
                      blue: 0%
            - if:
                condition:
                  lambda: |-
                    return id(evening).state > 0;
                then:
                  - light.turn_on: 
                      id: neopixel2
                      brightness: 100%
                      red: 100%
                      green: 0%
                      blue: 0%
            - if:
                condition:
                  lambda: |-
                    return id(appletv).state > 0;
                then:
                  - light.turn_on: 
                      id: neopixel2
                      brightness: 100%
                      red: 55%
                      green: 55%
                      blue: 0%
            - if:
                condition:
                  lambda: |-
                    return id(tv).state > 0;
                then:
                  - light.turn_on: 
                      id: neopixel2
                      brightness: 100%
                      red: 0%
                      green: 25%
                      blue: 53%
            - if:
                condition:
                  lambda: |-
                    return id(nintendo).state > 0;
                then:
                  - light.turn_on: 
                      id: neopixel2
                      brightness: 100%
                      red: 36%
                      green: 28%
                      blue: 55%

  - platform: gpio
    pin: D7
    name: "ESPHome livingroom - Touch 3"
    on_press:
      - switch.toggle: switch3
      - if:
          condition:
            switch.is_on: switch3
          then:
            - light.turn_on: 
                id: neopixel3
                brightness: 100%
                red: 0%
                green: 100%
                blue: 0%
      - if:
          condition:
            switch.is_off: switch3
          then:
            - if:
                condition:
                  lambda: |-
                    return id(goodnight).state > 0;
                then:
                  - light.turn_on: 
                      id: neopixel3
                      brightness: 100%
                      red: 10%
                      green: 0%
                      blue: 10%
            - if:
                condition:
                  lambda: |-
                    return id(kodi).state > 0;
                then:
                  - light.turn_on: 
                      id: neopixel3
                      brightness: 100%
                      red: 93%
                      green: 0%
                      blue: 93%
            - if:
                condition:
                  lambda: |-
                    return id(daytime).state > 0;
                then:
                  - light.turn_on: 
                      id: neopixel3
                      brightness: 100%
                      red: 100%
                      green: 0%
                      blue: 0%
            - if:
                condition:
                  lambda: |-
                    return id(evening).state > 0;
                then:
                  - light.turn_on: 
                      id: neopixel3
                      brightness: 100%
                      red: 100%
                      green: 0%
                      blue: 0%
            - if:
                condition:
                  lambda: |-
                    return id(appletv).state > 0;
                then:
                  - light.turn_on: 
                      id: neopixel3
                      brightness: 100%
                      red: 55%
                      green: 55%
                      blue: 0%
            - if:
                condition:
                  lambda: |-
                    return id(tv).state > 0;
                then:
                  - light.turn_on: 
                      id: neopixel3
                      brightness: 100%
                      red: 0%
                      green: 25%
                      blue: 53%
            - if:
                condition:
                  lambda: |-
                    return id(nintendo).state > 0;
                then:
                  - light.turn_on: 
                      id: neopixel3
                      brightness: 100%
                      red: 36%
                      green: 28%
                      blue: 55%

sensor:
  # SCENES
  - platform: mqtt_subscribe
    name: "ESPHome livingroom - Daytime"
    id: daytime
    accuracy_decimals: 0
    topic: homeassistant/scenes/daytime
    on_value:
      then:
        if:
          condition:
            lambda: 'return x > 0;'
          then: 
            - light.turn_on: 
                id: neopixel
                brightness: 100%
                red: 100%
                green: 0%
                blue: 0%

  - platform: mqtt_subscribe
    name: "ESPHome livingroom - Evening"
    id: evening
    accuracy_decimals: 0
    topic: homeassistant/scenes/evening
    on_value:
      then:
        if:
          condition:
            lambda: 'return x > 0;'
          then: 
            - light.turn_on: 
                id: neopixel
                brightness: 100%
                red: 100%
                green: 0%
                blue: 0%

  - platform: mqtt_subscribe
    name: "ESPHome livingroom - Goodnight"
    id: goodnight
    accuracy_decimals: 0
    topic: homeassistant/scenes/goodnight
    on_value:
      then:
        if:
          condition:
            lambda: 'return x > 0;'
          then: 
            - light.turn_on: 
                id: neopixel
                brightness: 100%
                red: 20%
                green: 31%
                blue: 9%

  - platform: mqtt_subscribe
    name: "ESPHome livingroom - AppleTV"
    topic: homeassistant/scenes/appletv
    id: appletv
    accuracy_decimals: 0
    on_value:
      then:
        if:
          condition:
            lambda: 'return x > 0;'
          then: 
            - light.turn_on: 
                id: neopixel
                brightness: 100%
                red: 55%
                green: 55%
                blue: 0%
  
  - platform: mqtt_subscribe
    name: "ESPHome livingroom - Kodi"
    id: kodi
    accuracy_decimals: 0
    topic: homeassistant/scenes/kodi
    on_value:
      then:
        if:
          condition:
            lambda: 'return x > 0;'
          then: 
            - light.turn_on: 
                id: neopixel
                brightness: 100%
                red: 93%
                green: 0%
                blue: 93%

  - platform: mqtt_subscribe
    name: "ESPHome livingroom - Nintendo"
    id: nintendo
    accuracy_decimals: 0
    topic: homeassistant/scenes/nintendo
    on_value:
      then:
        if:
          condition:
            lambda: 'return x > 0;'
          then: 
            - light.turn_on: 
                id: neopixel
                brightness: 100%
                red: 36%
                green: 28%
                blue: 55%

  - platform: mqtt_subscribe
    name: "ESPHome livingroom - TV"
    id: tv
    accuracy_decimals: 0
    topic: homeassistant/scenes/tv
    on_value:
      then:
        if:
          condition:
            lambda: 'return x > 0;'
          then: 
            - light.turn_on: 
                id: neopixel
                brightness: 100%
                red: 0%
                green: 25%
                blue: 53%

  # MOTION
  - platform: mqtt_subscribe
    name: "ESPHome livingroom - Motion"
    id: motion
    accuracy_decimals: 0
    topic: homeassistant/motion/livingroom
    on_value:
      then:
        if:
          condition:
            lambda: 'return x > 0;'
          then: 
            - light.turn_on: 
                id: neopixel
                brightness: 100%
                red: 0%
                green: 0%
                blue: 100%
          else:
            - if:
                condition:
                  switch.is_on: switch1
                then:
                  - light.turn_on: 
                      id: neopixel1
                      brightness: 100%
                      red: 0%
                      green: 100%
                      blue: 0%
                else:
                  - if:
                      condition:
                        lambda: |-
                          return id(daytime).state > 0;
                      then:
                        - light.turn_on: 
                            id: neopixel1
                            brightness: 100%
                            red: 100%
                            green: 0%
                            blue: 0%
                  - if:
                      condition:
                        lambda: |-
                          return id(goodnight).state > 0;
                      then:
                        - light.turn_on: 
                            id: neopixel1
                            brightness: 100%
                            red: 10%
                            green: 0%
                            blue: 10%
                  - if:
                      condition:
                        lambda: |-
                          return id(evening).state > 0;
                      then:
                        - light.turn_on: 
                            id: neopixel1
                            brightness: 100%
                            red: 100%
                            green: 0%
                            blue: 0%
                  - if:
                      condition:
                        lambda: |-
                          return id(kodi).state > 0;
                      then:
                        - light.turn_on: 
                            id: neopixel1
                            brightness: 100%
                            red: 93%
                            green: 0%
                            blue: 93%
                  - if:
                      condition:
                        lambda: |-
                          return id(appletv).state > 0;
                      then:
                        - light.turn_on: 
                            id: neopixel1
                            brightness: 100%
                            red: 55%
                            green: 55%
                            blue: 0%
                  - if:
                      condition:
                        lambda: |-
                          return id(tv).state > 0;
                      then:
                        - light.turn_on: 
                            id: neopixel1
                            brightness: 100%
                            red: 0%
                            green: 25%
                            blue: 53%
                  - if:
                      condition:
                        lambda: |-
                          return id(nintendo).state > 0;
                      then:
                        - light.turn_on: 
                            id: neopixel1
                            brightness: 100%
                            red: 36%
                            green: 28%
                            blue: 55%

            - if:
                condition:
                  switch.is_on: switch2
                then:
                  - light.turn_on: 
                      id: neopixel2
                      brightness: 100%
                      red: 0%
                      green: 100%
                      blue: 0%
                else:
                  - if:
                      condition:
                        lambda: |-
                          return id(daytime).state > 0;
                      then:
                        - light.turn_on: 
                            id: neopixel2
                            brightness: 100%
                            red: 100%
                            green: 0%
                            blue: 0%
                  - if:
                      condition:
                        lambda: |-
                          return id(goodnight).state > 0;
                      then:
                        - light.turn_on: 
                            id: neopixel2
                            brightness: 100%
                            red: 10%
                            green: 0%
                            blue: 10%
                  - if:
                      condition:
                        lambda: |-
                          return id(evening).state > 0;
                      then:
                        - light.turn_on: 
                            id: neopixel2
                            brightness: 100%
                            red: 100%
                            green: 0%
                            blue: 0%
                  - if:
                      condition:
                        lambda: |-
                          return id(kodi).state > 0;
                      then:
                        - light.turn_on: 
                            id: neopixel2
                            brightness: 100%
                            red: 93%
                            green: 0%
                            blue: 93%
                  - if:
                      condition:
                        lambda: |-
                          return id(appletv).state > 0;
                      then:
                        - light.turn_on: 
                            id: neopixel2
                            brightness: 100%
                            red: 55%
                            green: 55%
                            blue: 0%
                  - if:
                      condition:
                        lambda: |-
                          return id(tv).state > 0;
                      then:
                        - light.turn_on: 
                            id: neopixel2
                            brightness: 100%
                            red: 0%
                            green: 25%
                            blue: 53%
                  - if:
                      condition:
                        lambda: |-
                          return id(nintendo).state > 0;
                      then:
                        - light.turn_on: 
                            id: neopixel2
                            brightness: 100%
                            red: 36%
                            green: 28%
                            blue: 55%