Solved: Can't connect to ESP. Please make sure your YAML file contains an 'api:' line

I’m beginning to despair. I have been running a Raspberry PI 4 with HassOS for 6 months (actual version 9.5 and HA version “2023.3.5”.
Since the beginning I use the ESPHpme integration, which also ran without problems.
Until about 3 months ago. Since then I can no longer register new devices.

Versions:
Home Assistant 2023.3.5
Supervisor 2023.03.1
Operating System 9.5
Frontend 20230309.1 - latest
ESPHome-Integration: 2023.3.0

ESP appears in the integration menu

I get an error at config the ESP in HA.
Input in HA (Config Device)
Host: 192.168.1.221
Port: 6053
Error: “Can’t connect to ESP. Please make sure your YAML file contains an ‘api:’ line.”

The ESP (Wemos D1 Mini or ESP8266-01) are flashable, accessable, controllable and working problerly via IP.

Two older devives are working problerly

Config-File: ESP-001.yaml

esphome:
name: esp-001
friendly_name: esp-001

esp8266:
board: d1_mini

Enable logging

logger:
level: DEBUG

Enable Home Assistant API

api:
encryption:
key: !secret API_Key

Debug-Log - ESPHome (Wemos D1 Mini)

[I][app:102]: ESPHome version 2023.2.4 compiled on Mar 12 2023, 22:54:23
[C][wifi:504]: WiFi:
[C][wifi:362]: Local MAC: 24:A1:60:3A:4A:01
[C][wifi:363]: SSID: ‘FB1204’
[C][wifi:364]: IP Address: 192.168.1.221
[C][wifi:365]: BSSID: 12:16:16:89:0D:3E
[C][wifi:367]: Hostname: ‘ESP-001’
[C][wifi:369]: Signal strength: -63 dB ▂▄▆█
[C][wifi:373]: Channel: 1
[C][wifi:374]: Subnet: 255.255.255.0
[C][wifi:375]: Gateway: 192.168.1.4
[C][wifi:376]: DNS1: 0.0.0.0
[C][wifi:377]: DNS2: 0.0.0.0
[C][logger:293]: Logger:
[C][logger:294]: Level: DEBUG
[C][logger:295]: Log Baud Rate: 115200
[C][logger:296]: Hardware UART: UART0
[C][switch.gpio:076]: GPIO Switch ‘Light1’
[C][switch.gpio:078]: Icon: ‘mdi:key-variant’
[C][switch.gpio:098]: Restore Mode: restore defaults to OFF
[C][switch.gpio:031]: Pin: GPIO3
[C][switch.gpio:076]: GPIO Switch ‘Light2’
[C][switch.gpio:078]: Icon: ‘mdi:door-closed-lock’
[C][switch.gpio:098]: Restore Mode: restore defaults to OFF
[C][switch.gpio:031]: Pin: GPIO0
[C][captive_portal:088]: Captive Portal:
[C][web_server:151]: Web Server:
[C][web_server:152]: Address: 192.168.1.221:80
[C][mdns:108]: mDNS:
[C][mdns:109]: Hostname: ESP-001
[C][ota:093]: Over-The-Air Updates:
[C][ota:094]: Address: 192.168.1.221:8266
[C][ota:097]: Using Password.
[C][api:138]: API Server:
[C][api:139]: Address: 192.168.1.221:6053
[C][api:141]: Using noise encryption: YES
[C][sntp:053]: SNTP Time:
[C][sntp:054]: Server 1: ‘0.pool.ntp.org
[C][sntp:055]: Server 2: ‘1.pool.ntp.org
[C][sntp:056]: Server 3: ‘2.pool.ntp.org
[C][sntp:057]: Timezone: ‘CET-1CEST,M3.5.0,M10.5.0/3’
[D][api:102]: Accepted 192.168.1.130
[W][api.connection:071]: 192.168.1.130: Socket operation failed: BAD_INDICATOR errno=11
[I][ota:113]: Boot seems successful, resetting boot loop counter.

Someone experienced the same behaviour?
Thank you for support!
Roland

Solution found.
For whatever reason the subnet mask was on /32 instead of /24 in the HA.

2 Likes

Thank you so much for this. I tried to migrate to a new system and the restore didn’t seem to bring everything over and some of my EPSHome items wouldn’t load. This was my issue too.

how did you fix this in HA?

So what’s the fix?