ESP keeps connecting and disconnecting from HA

Attached is snippet. I tried resetting, reconnecting wifi, reuploading the file. No luck.

[15:28:11][D][api.connection:959]: Home Assistant 2023.5.4 (192.168.0.10): Connected successfully
[15:28:11][W][api.connection:087]: Home Assistant 2023.5.4 (192.168.0.10): Connection closed
[15:28:11][D][api:102]: Accepted 192.168.0.10
[15:28:11][D][api.connection:959]: Home Assistant 2023.5.4 (192.168.0.10): Connected successfully
[15:28:11][D][api:102]: Accepted 192.168.0.10
[15:28:11][W][api.connection:087]: Home Assistant 2023.5.4 (192.168.0.10): Connection closed
[15:28:11][D][api.connection:959]: Home Assistant 2023.5.4 (192.168.0.10): Connected successfully
[15:28:12][D][api:102]: Accepted 192.168.0.10
[15:28:12][W][api.connection:087]: Home Assistant 2023.5.4 (192.168.0.10): Connection closed
[15:28:12][D][api.connection:959]: Home Assistant 2023.5.4 (192.168.0.10): Connected successfully
[15:28:12][W][api.connection:087]: Home Assistant 2023.5.4 (192.168.0.10): Connection closed
[15:28:12][D][api:102]: Accepted 192.168.0.10
[15:28:12][D][api.connection:959]: Home Assistant 2023.5.4 (192.168.0.10): Connected successfully
[15:28:13][D][api:102]: Accepted 192.168.0.10
[15:28:13][W][api.connection:087]: Home Assistant 2023.5.4 (192.168.0.10): Connection closed
[15:28:13][D][api.connection:959]: Home Assistant 2023.5.4 (192.168.0.10): Connected successfully
[15:28:13][D][api:102]: Accepted 192.168.0.10
[15:28:13][W][api.connection:087]: Home Assistant 2023.5.4 (192.168.0.10): Connection closed

I had that once before and it was due to a bad ESP. I replaced it with a new one (same code, same location) and all has been fine since.

Another possible cause may be the wi-fi signal.

  • Possibly the location of your device has more physical barriers (eg line-of-sight between device and WAP going diagonally through thick walls),
  • possibly a neighbour having a strong wi-fi signal on the same (or a close) channel at that location;
  • possibly your WAP is at the limit of number of devices it can support

Was the board discovered in HA and you have completed the configuration to add it?

If you go to Devices/Services - Esphome- is your board in the list of esphome devices?

Its probably a good idea to also post your config or at the very least your wifi/networking part of the config. Is it mostly default with just ssid and password or have you messed around with the configuration options there?

Posting the log is good but what does it show? Connected…Disconnected…
Thats information but if thats all the info you can share then everyone and their brother are just going to make bling guesses and your just going to be running in circles going nowhere fast.

I had something similar when I had two devices with the same IP.

Sorry been busy with work.

Attached is the config file. I have gotten it to attach to HA. I hit the stop button before then unplug replug because non responsive. Then on reboot, it shows that connection crap. Im going to try to remove the device and reinstall then re add.

> esphome:
>   name: front-blinds

>   friendly_name: Front Blinds
> 
> esp32:
>   board: esp32dev
>   framework:
>     type: arduino
> 
> # Enable logging
> logger:
> 
> # Enable Home Assistant API
> api:
>   encryption:
>     key: "encryption_key"
> 
> ota:
>   password: "ota_password"
> 
> wifi:
>   ssid: "ssid"
>   password: "password"
>   use_address: 192.168.0.25
> 
> globals:
>    - id: blind_max
>      type: int
>      restore_value: yes
>      initial_value: '115000' #change value, 0 at top, max on bottom. Change for height for cat. 115k is the old value
>     
> sensor:
>   - platform: rotary_encoder
>     name: "Rotary Encoder"
>     pin_a: 22 #gpio5
>     pin_b: 21 #gpio4
>     id: blind_steps
> 
> switch:
>   - platform: gpio
>     pin: 19 #gray,gpio12
>     name: "Blind S2"
>     id: "blind_s2"
>     interlock: [blind_s1]
> 
>   - platform: gpio
>     pin: 18 #white,gpio14
>     name: "Blind S1"
>     id: "blind_s1"
>     interlock: [blind_s2]
> 
> cover:
>   - platform: template
>     name: "Front Blinds"
>     id: blind_cover
>     device_class: shade
>     has_position: true
> 
>     close_action:
>       - switch.turn_off: blind_s1
>       - switch.turn_on: blind_s2
>       - cover.template.publish:
>           id: blind_cover
>           current_operation: CLOSING
>           position: !lambda |-
>             float pos = id(blind_steps).state / id(blind_max);
>             return pos < 0 ? 0 : pos;
>       - wait_until: 
>           lambda: 'return id(blind_steps).state >= id(blind_max);'
>       - switch.turn_off: blind_s2
>       - cover.template.publish:
>           id: blind_cover
>           state: CLOSED
>           current_operation: IDLE
> 
>     open_action:
>       - switch.turn_on: blind_s1
>       - switch.turn_off: blind_s2
>       - cover.template.publish:
>           id: blind_cover
>           current_operation: OPENING
>           position: !lambda |-
>             float pos = id(blind_steps).state / id(blind_max);
>             return pos > 1 ? 1 : pos;           
>       - wait_until:
>           lambda: 'return id(blind_steps).state <= 0;'
>       - switch.turn_off: blind_s1
>       - cover.template.publish:
>           id: blind_cover
>           state: OPEN
>           current_operation: IDLE
>           
>     stop_action:
>       then:
>         - switch.turn_off: blind_s1
>         - switch.turn_off: blind_s2
>         - cover.template.publish:
>             id: blind_cover
>             position: !lambda 'return id(blind_steps).state / id(blind_max);' 
>             current_operation: IDLE
> 
>     position_action:
>           - if:
>               condition:
>                 lambda: 'return id(blind_steps).state / id(blind_max) < pos;'
>               else:
>                 - switch.turn_off: blind_s1
>                 - switch.turn_on: blind_s2
>                 - cover.template.publish:
>                     id: blind_cover
>                     current_operation: CLOSING
>                 - wait_until:
>                     lambda: 'return id(blind_steps).state >= pos * id(blind_max);'
>                 - switch.turn_off: blind_s2
>                 - cover.template.publish:
>                     id: blind_cover
>                     current_operation: IDLE
>                     position: !lambda 'return id(blind_steps).state / id(blind_max);'