Can't add ESPhome integration

After I installed the yaml file to my esp32dev board, I then went add the ESPhome integration.
I filled the host details and pressed ‘Submit’ , then I got this error: On that page to add the esp32dev board, It also asks to ‘Please enter the connection settings’. My board is ESP32-WROOM-32, so what should I have for the board name.

Can’t connect to ESP. Please make sure your YAML file contains an ‘api:’ line.
The esp32dev board is connected to my laptop by usb cable.

The said file does have an ‘api’ line, unless there is something wrong with it.

esphome:
  name: home
  platform: ESP32
  board: esp32dev

wifi:
  ssid: "xxxxxxxxx"
  password: "xxxxxxxxx"
  
 
# Enable Home Assistant API
api:
  port: 6053
  password: ''
  reboot_timeout: 15min

ota:
  safe_mode: true
  port: 3232
  password: ''
  
i2c:
  sda: 21
  scl: 22
  scan: True
  id: bus_a
sensor:
  - platform: bme280
    temperature:
      name: "Lounge Temperature"
      oversampling: 16x
    pressure:
      name: "Lounge Pressure"
    humidity:
      name: "Lounge Humidity"
    address: 0x76
    update_interval: 60s
    
  - platform: bh1750
    name: "BH1750 Illuminance"
    address: 0x23
    update_interval: 60s
  

  # Enable fallback hotspot (captive portal) in case wifi connection fails
#ap:
 #   ssid: "Home Fallback Hotspot"
#    password: "ZfMkVWyPrmBn"

captive_portal:

# Enable logging
logger:

Did you try without any attributes under the api: line?

api:

Just tried it and no still the same .
Does the api need some key

Not that I’m aware of although I have set encryption and password requirements. Here’s the start of code I’m using;

#Define Project Deatils and ESP Board Type
esphome:
  name: irrigation-valve-ctrl-unit
  platform: ESP32
  board: nodemcu-32s
  comment: Eight Valve Irrigation Control
  project:
    name: Robert.Eight Valve Irrigation Control
    version: Eight Valve Irrigation Ctrl, 01.01.23
  on_boot:
    priority: -100
    then:
      # Set default state for Valve Status
      - text_sensor.template.publish:
          id: valve_status
          state: "Idle"
      # Set multiplier to 60, convert seconds to minutes
      - sprinkler.set_multiplier:
          id: $devicename
          multiplier: 60

# WiFi connection, replace these with values for your WiFi.
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

# Enable logging
logger:
  
# Enable over-the-air updates.
ota:
  password: !secret ota_password

# Enable Web server.
web_server:
  port: 80

# Sync time with Home Assistant.
time:
  - platform: homeassistant
    id: homeassistant_time

api:
  encryption:
    key: !secret api_encryption
  password: !secret api_password

text_sensor:
  # Expose ESPHome version as sensor.
  - platform: version
    name: Version

  # Expose WiFi information as sensor.
  - platform: wifi_info
    ip_address:
      name: IP
    ssid:
      name: SSID
    bssid:
      name: BSSID
    mac_address:
      name: WiFi MAC

I still can’t add esphome to the Home page of HA, even tho’ there is an api line with an api key
This what I have now:

esphome:
  name: home
  platform: ESP32
  board: nodemcu-32s

wifi:
  ssid: "xxxxxxxx"
  password: "xxxxxxxx"

sensor:
  - platform: bh1750
    name: "BH1750 Illuminance"
    address: 0x23
    update_interval: 60s

  
  - platform: bme280
    temperature:
      name: "BME280 Temperature"
      oversampling: 16x
    pressure:
      name: "BME280 Pressure"
    humidity:
      name: "BME280 Humidity"
    address: 0x77
    update_interval: 60s

       
i2c:
  - id: bus_a
    sda: GPIO4
    scl: GPIO5
    scan: true

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "UE+lSotmJqlgv//DgbwSiFUMYdW3+JXMbIcK8rB1o3Y="

ota:
  password: "ec685985bf77833459e159dd5133fd9f"


  # Enable fallback hotspot (captive portal) in case wifi connection fails
  #ap:
    #ssid: "Home Fallback Hotspot"
    #password: "xmEduWaUi5Fv"

captive_portal:
    

Check the DHCP logs on your router to see if the ESP device have acquired an IP address.

I have already done that and gave it a reserved IP address
Thanks

Can you ping it and if you can, then can open the webpage on that IP address with the port you gave in the config?

I can ping the ip address it has but not able to open a webpage with the said port number 6053

I wouldn’t mind but all the other integrattions I have in HA were all added automatically, but not this one

How did you install the firmware to the ESP device?
If it was with a serial port, then try to hook it up when the device boots up and see what it says.

And just some random checks.

  • Can you ping it when it is powered off also? Just to see that you have the right device.
  • Is the device and your HA in the same IP range? If not then you might have to open up something in the firewall and maybe also NAT table to enable access and routing.
  • Can you do a port scan of the device? I use Advanced IP Scanner to scan a IP range and Advanced Port Scanner to scan port on a device.

And unless you want to use different password and encryption keys for your devices, then I suggest you move them to the secrets file in the top right corner of the ESPHome screen.

api:
  password: !secret api_pass
  encryption:
    key: !secret api_key

Your secrets file would then look something like this:

api_key: "RTuFGBNfertyDFG57DF4564DFGdyuiYUIGHJRTDFGD="
api_pass: "SecretPassword"

Please post the ESPHome log for the device.

The esb32 board is connected to my laptop, and the led is flashing

INFO Reading configuration /config/esphome/home.yaml...
WARNING GPIO4 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
WARNING GPIO4 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
INFO Starting log output from home.local using esphome API
WARNING Can't connect to ESPHome API for home.local: Error resolving IP address: [Errno -5] No address associated with hostname
INFO Trying to reconnect to home.local in the background

Can you post the full log please?

I would if there was anymore, but after 20 minutes that was all there was

Use another pin than GPIO4, see here for which ones to use: ESP32 Pinout Reference: Which GPIO pins should you use? | Random Nerd Tutorials

I am also a bit puzzled about the home.local address.
Can you ping that one and is it the same IP as the homeassistant.local?

I think I have made some error with the GPIO pin naming connections now after looking on here

My original pin connections are correct, but I did not correct them in the yaml file, as I just took what the example lines for I2C as granted…doh!

No the homeassistant local:8123 address is 192.xxx.xxx.110, and the the IP address of the board is: 192.xxx.xxx.229. Is that the same as the home.local address. If not I don’t know.

Correcting the GPIO pins in the yaml file didn’t make any difference to adding the integration.

`INFO Reading configuration /config/esphome/esphome.yaml…
INFO Starting log output from esphome.local using esphome API
WARNING Can’t connect to ESPHome API for esphome.local: Error resolving IP address: [Errno -5] No address associated with hostname
INFO Trying to reconnect to esphome.local in the background
``

You seem to have some issues with the mDNS setup.
mDNS is controlled by a mDNS master that is selected automatically between the available clients and then the hosts are populated by that master.
This means the .local domain can not be used as your local DNS domain name.
Not sure if this is the case here, but could be.