[SOLVED] Integration give error: "Can't connect to ESP. Please make sure your YAML file contains an 'api:' line."

I am in the process of rebuilding my HA from scratch. I have the ESPHome add-on loaded and working perfectly. Currently it has no devices as I have not yet reloaded the yaml files. When I try to add the integration and add the ip address of my HA, I get the error “Can’t connect to ESP. Please make sure your YAML file contains an ‘api:’ line.”

I have no idea what ‘api’ line it is referring to.

I do not recall ever getting that error on my first build.

Thanks in advance.

You said you are rebuilding, how old was your old build?
Esphome now requires an api encryption key.

If you add the integration, you have to add the IP of your ESP device, not your HA IP address.

2 Likes

only if you use encryption, which is optional.

the the api should be activated in order to connect with it.

Ah!! Yeah, mine was about 2-3 years old

If I have no ESP Devices yet, shouldn’t I still be able to add the integration.

1 Like

No, you can’t install the integration if no ESP available.

Ah! NOW it makes sense. Thanks

I wanted to install a Seeed studio mmwave human detection sensor kit in Home Assistant, I have installed the ESPHome Device Compiler in my Home Assistant, a Home Assistant Green, the Home Assistant can discover the sensor, and asks me if I want to connect it to ESPHome, I said yes, and the dialogue box shows the Host and Port numbers, but still gives the error of "Please make sure your YAML file contains an ‘api’ line. So the Home Assistant still does not accept ESPHome devices for some reason. Any suggestion?

I tried even to reinstall the ESPHome Compiler on my Home Assistant, and now that is not successful. This ESPHome is just too much trouble for ordinary people. What is this YAML configuration line? Is it different for each bluetooth device to be added? if so, WHAT is the line and where can I add it? no answer anywhere. This is pathetic. I will have to forget about using bluetooth devices with my Home Assistant Green.

Not sure how much I can help but I will try.
In my Home Assistant, I installed ESPHome Device Builder using the “Add-ons” option. [Setting > Add-ons. Click on the “ADD-ON STORE” button and search for ESPHome. You should see the ESPHome Builder option.]

Once you have that you can install the ESPHome integration, which will connect the builder with Home Assistant. It has been too long since I installed these so I cant remember the full steps but I would think the host and port is the ip address of HA is that is where the builder is installed.

Once those are installed, you can create a new device but YOUR NEW DEVICE MUST BE CONNECTED VIA CABLE the first time. From then on it can connect wirelessly.

Hope that helps.

Authentication expired for a few nodes.

When filling in the original api key that is in the YAML file of the node I get:

The… can not connect to esp… error

I can not get my head around why updating esphome is breaking the nodes, how often did we have to change YAML’s like changing the board definitions, the order in which should be said and what not, to find out that factually it is broken now, instead of made better. Now I can not update the nodes and some I need to pull out of walls, thank you.

Is there a fix for this cause I do not see it here?

1 Like

I’m seeing the same. A few nodes needed re-authentication. Their YAML files all include a base template that has an api section w/ an encryption key. One of my nodes needs to re-authenticate but is not accepting the key with the following error:

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