Unable to get esphome loaded

Hi, very new to Home assistant…
I’m trying to add the integration esphome and failing at the 1st hurdle. I press on the button to upload the esphome integration and i’m immediately presented with a pop-up box to enter my “Host” for the esphome node. I’ve tried entering my hass ip address but that doesnt work and I do get an error saying
“Can’t connect to ESP. Please make sure your YAML file contains an ‘api:’ line.”
so I dug a bit further and added the file editor and did my 1st configuration.yaml edit and added a line with ‘api:’ (no quotes). I restarted hass but the error remains.

What am i doing wrong?

3 Likes

The api: line should be in your esphome code file yaml. Not the ha configuration.yaml file.

1 Like

I just realised I am trying to use configuration-integrations when I have not yet installed the app

…I did say i was new to this…i feel really stoooooopid!

1 Like

No worries. Huge learning curve. :grinning:

I’m having the same issue and unfortunately I still feel stupid after reading this post.

My situation is the following:

  1. I followed the instruction on https://www.home-assistant.io/docs/installation/raspberry-pi/ to install using a virtual environment on a RP 3b+. This means I’m not running Hassio and the tutorials for how to get ESPHome are not making sense to me.
  2. I’ve installed ESPHome using pip3 and I’ve started the ESPHome dashboard from the terminal. The dashboard can be accessed using http://localhost:6052/ from the RP.
  3. When I try to add ESPHome to Hass via configuration -> integrations I’m asked “Please enter connection settings of your ESPHome node.”. When I enter localhost I get the error message “Can’t connect to ESP. Please make sure your YAML file contains an ‘api:’ line.”.

To me it is not clear whether the host I should be entering is the IP-address to where the dashboard can be accessed so that it is tied into Hass as when using Hassio or whether I’m supposed to use the dashboard externally with this type of installation and only enter the IP-address to the ESPHome devices I want to add.

I would be grateful if somebody could explain in simple terms how the hole thing is supposed to hold together when not using the add-on package available in Hassio.

Warmly, Per

3 Likes

Hi, may I jump in here ?
What App are you talking about ? I have the same problem but I have the api line in the Yaml file of the new esp. The Log of the esp shows it working but the integration is not possible.
Other esps working fine but the new one runs on that error line.
So, what did you do ?
Thanks for you’re reply.

1 Like

Hi Wolfgang, too much time has passed for me to really remember. The App I’m referring to is actually the ESP home official addon. You can install this by going to Supervisor then pressing the add-on store button in the bottom right hand corner of the screen. Once this is installed you can configure under configuration-intergratons

I have the EXACT situation as you. I edit the yaml in ESPHome (supervisor) and it definitely contains an api: entry - the same as 5 other yaml files on various devices (NODEMCU, D1 mini) that work. I get the message “Can’t connect to ESP. Please make sure your YAML file contains an ‘api:’ line” when I try to get it to work in integrations. It doesn’t auto discover so I have to enter the ip address (under a new ESPHome integration) to even get the obviously BS message. It seems that there are other errors that the Home Assistant is using this message for. Of course it doesn’t help that everything gets “upgraded” almost daily and sometimes things don’t play well together anymore. In addition to restarting home assistant I have rebooted my modem; btw the modem sees the device’s IP as well as the addon saying that the device is online.
I even tried to load a different yaml I had working on another device before and it gives me the same crap. Maybe I have a bad D1 mini??? Nothing in Home Assistant or the official ESPHome addon indicates this though

I had the exact issue. Unplugged D1 mini, restarted HA, plugged in D1 mini and waited until I could ping it, went to integrations page and clicked on it. It worked perfectly.

I’m going with “bad D1 mini” since I could load the yaml on another device and it works. I de-soldered the pins on the mini and probably overheated something. Good thing they’re cheap. It’s in the trash now

I changed to nodemcev2 that seems to work, how ever the ESP log shows a distance (
D][ultrasonic.Sensor:040]: ‘Ultrasonic Sensor’ - Got distance: 1.12 m
And the device (enabled) showed up in HA as „ultrasonic sensor“ but in the entity no value. (unknown)
I am sure,I forgot something …. but have no clue, what.
Can anybody assist ?
Thank you, for you’re help.

Nobody in the community for a helping hint ?
„platform ultrasonic“ seems to be unknown …. but what does it mean ?
How to introduce a new platform to HA ?

Hi David ….
I changed the D1 mini to a new one and took care, that I didn’t overheated the pins …. same problem.
I also made a complete new installation, initializing the D1 and reinstalled a yaml file … everything along the guideline …. with a positive Log file.
The Log showes … everything is fine and I can read the distance measuring of the ultrasonic sensor in the log.
But there’s no way to have it implemented into HA.


[09:27:27][C][captive_portal:144]: Captive Portal:
[09:27:27][C][ota:082]: Over-The-Air Updates:
[09:27:27][C][ota:083]:   Address: wasserstand.local:8266
[09:27:27][C][ota:086]:   Using Password.
[09:27:27][C][api:134]: API Server:
[09:27:27][C][api:135]:   Address: wasserstand.local:6053
[09:27:27][C][api:139]:   Using noise encryption: NO
[09:27:27][C][mdns:084]: mDNS:
[09:27:27][C][mdns:085]:   Hostname: wasserstand
[09:27:28][D][ultrasonic.sensor:040]: 'Wasserstand' - Got distance: 0.40 m
[09:27:28][D][sensor:125]: 'Wasserstand': Sending state 0.40080 m with 2 decimals of accuracy
[09:27:30][D][ultrasonic.sensor:040]: 'Wasserstand' - Got distance: 0.40 m

What happens if you throw a api: (see api docs and the getting started guide) in your esphome yaml (if you haven’t already)?

You might wanna add a new esphome integration in the ha configuration and add your nodes mDNS address (wasserstand.local) in case auto discovery doesn’t find your device. If mDNS is broken on your network you could try the normal hostname (wasserstand) or the ip of the device.

Plenty of people (me included) have no problems having esphome nodes connected to ha :thinking:

This probably won’t help, but I had to reload the yaml back onto the mini because I changed modems and hadn’t set a static ip. When I did, and then tried to use configuration-integration-esphome using the new ip, it gave me the “Can’t connect to ESP. Please make sure your YAML file contains an ‘api:’ line.” again. I tried several times before I gave up. It was giving temp and humidity readings in the log. I left it plugged in and 2 days later it appeared in integrations under esphome. It has been up for a few days and hopefully it won’t disappear.

I’m stuck in the same place.
Synology with ESPHome in docker.
When I try to add integration ESPHome in HA, it asks for host computer and there I write the IP to Synology.
Still: “Can’t connect to ESP. Please make sure your YAML file contains an ‘api:’ line.”

I have looked in numerus instructions but all left this part out.

What app are You referring to in Your first post?

I had the same problem (look here). I solved it by adding a passwort to the api section:

api:
  password: "your-password-here"

What password is it?

Your password :raised_hands:

Have you ever solved the problem?

I had the same problem because I thought I had to enter the IP of my esphome (docker) instance with port 6052

But that was a fail. You have to enter the WLAN IP of the device. The port of the device will automatically be 6052 if you did not declare any other manually.

After connect you have to enter the api encryption key in home assistant that was installed on the device.

esphome_device_in_homeassistant0

e.g. my device ir-receiver.yaml from esphome after i installed it on the d1_mini

esphome:
  name: "ir-receiver"
  platform: ESP8266
  board: d1_mini

# Enable logging

logger:
  level: VERBOSE

# Enable Home Assistant API
api:
  encryption:
    key: "2MeMPEGzET8U*******GCg1lFD1y+NkNI="

ota:
  password: "bbe8d860***a6df8d2a5df0"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  manual_ip:
    static_ip: 192.168.178.91
    gateway: 192.168.178.1
    subnet: 255.255.255.0

Its a little bit different thinkin of connecting if you are used to create a controller first…

It could be quite far-fetched that in the local network the communication between the devices must be allowed. I use a Fritzbox there is such a setting but have never tried it without. Therefore here only as additional info. If the device is pingable and no ports are blocked in the local firewall, this should work fine. Some esp devices also need a little longer until they are accessible.