Can't add ESPhome integration

@orange-assistant ,
do you mean this log:

INFO Reading configuration /config/esphome/home.yaml...
INFO Configuration is valid!
esphome:
  name: home
  build_path: .esphome/build/home
  platformio_options: {}
  includes: []
  libraries: []
  name_add_mac_suffix: false
  min_version: 2022.12.6
  compile_process_limit: 1
esp32:
  board: nodemcu-32s
  framework:
    version: 2.0.5
    source: ~3.20005.0
    platform_version: platformio/espressif32 @ 5.2.0
    type: arduino
  variant: ESP32
wifi:
  manual_ip:
    static_ip: 192.168.0.229
    gateway: 192.168.0.1
    subnet: 255.255.255.0
    dns1: 0.0.0.0
    dns2: 0.0.0.0
  domain: .local
  reboot_timeout: 15min
  power_save_mode: LIGHT
  fast_connect: false
  networks:
  - ssid: TP-Link_0EEB
    password: '33810492'
    priority: 0.0
  use_address: 192.168.0.229
sensor:
- platform: bh1750
  name: BH1750 Illuminance
  address: 0x23
  update_interval: 60s
  disabled_by_default: false
  force_update: false
  unit_of_measurement: lx
  accuracy_decimals: 1
  device_class: illuminance
  state_class: measurement
- platform: bme280
  temperature:
    name: BME280 Temperature
    oversampling: 16X
    disabled_by_default: false
    force_update: false
    unit_of_measurement: °C
    accuracy_decimals: 1
    device_class: temperature
    state_class: measurement
  pressure:
    name: BME280 Pressure
    disabled_by_default: false
    force_update: false
    unit_of_measurement: hPa
    accuracy_decimals: 1
    device_class: pressure
    state_class: measurement
    oversampling: 16X
  humidity:
    name: BME280 Humidity
    disabled_by_default: false
    force_update: false
    unit_of_measurement: '%'
    accuracy_decimals: 1
    device_class: humidity
    state_class: measurement
    oversampling: 16X
  address: 0x77
  update_interval: 60s
  iir_filter: 'OFF'
i2c:
- id: bus_a
  sda: 21
  scl: 22
  scan: true
  frequency: 50000.0
logger:
  baud_rate: 115200
  tx_buffer_size: 512
  deassert_rts_dtr: false
  hardware_uart: UART0
  level: DEBUG
  logs: {}
api:
  encryption:
    key: UE+lSotmJqlgv//DgbwSiFUMYdW3+JXMbIcK8rB1o3Y=
  port: 6053
  password: ''
  reboot_timeout: 15min
ota:
  password: ec685985bf77833459e159dd5133fd9f
  safe_mode: true
  port: 3232
  reboot_timeout: 5min
  num_attempts: 10
captive_portal: {}

@tom_l
legacy format, where When I click the 3 dots all I get is Download YAML with no options on formats

There are other selections like ‘install’ ‘Show API Key’ ‘Rename’ etc, Oh and ‘Clean Build Files’

Oh you tried to upload the yaml file. That’s why the magic byte was wrong. You can’t upload yaml to the esp. it has to be complied first.

Click “upload/update” as if you were going to flash the device. Then select “manual download”. Then “legacy format”.

This should save a .bin you can use in the esp flash tool.

Ok, I have done as advised and now the file has been flashed to the board while I held the boot button down. Then I pressed the RST button on the board and the ESPHomer-Flasher started to do a scan. That finished and now it has stopped at :Using noise encryption: YES.
The led on the board is not flashing anymore
I take it it hasn’t finished yet then
thanks

no, it should say home in the yaml, but the code use that name and adds .local to it to make up the device’s mDNS address.
That home.local should be pingable from the HA installation.

How are you powering the board during the flash?
The serial port devices do usually not have enough power to do the erase part, so you need to power it from a USB port on the same device as your serial port device is connected to and make sure that the power (3V3 or 5V) is not connected on the serial port device.

@WallyR
The board is powered by a USB cable plugged into my laptop.
I thought that it stopped the process but it has suddenly restarted , but it seems to be just logs which is going up the screen.
The actual flashing was Done! flashing is complete! at around 16.43
Then it says:
Showing logs.

And now , again, it has stopped at:
17.07 esp32.preferences:142: Saving 1 preference to flash

I don’t what you mean here:
‘make sure that the power (3V3 or 5V) is not connected on the serial port device.’

USB ports normally put out no more than 5v. Now this USB port would be known as a serial port , for purposes of the esp32 board. There is actually 5.08v getting to the esp32, and if there wasn’t, I doubt it power up.

Anyway, it now looks like it is going round in a loop for some reason, and is back to the point it was earlier: showing the logs.

What is the home.local address to ping

The flashing was done, and the Showing logs has been going round in a loop for over an hour now.
How much longer do I have to wait

1- Have you configured the integration after it was discovered? During configuring, it will ask you to type the API key, only then it is added
2- Work around, just comment out the whole API: section.

I also wonder about your api lines:

api:
  encryption:
    key: UE+lSotmJqlgv//DgbwSiFUMYdW3+JXMbIcK8rB1o3Y=
  port: 6053
  password: ''
  reboot_timeout: 15min

I only use

# Enable Home Assistant API
api:
  password: ThisIsMyAPIkey123123!#

I have my key in my secrets file, (using !secret api_password) but for now, just type one here.
This will be the key you have to type in when you add the integration in HA

What does it say?

Well it only repeating what it said an hour ago
[19.22.23][D] [esp32.preferences:142]: Saving 1 preferences to flash

Oh, about 45 minutes ago it said:
Results from I2C bus scan.
that there is an unknown error at address 0x08 etc etc.

My I2C GPIO numbers are pin 21 GPIO21, and pin 22 GPIO22.
I got those from here: ESP32 Pinout and ESP-WROOM-32 Pinout | ESP32 DevKit
I have just found that the GPIO numbers I used are for the Arduino
there are that many different versions of my board and it seems that they all use different GPIO pin numbers. My board has 38 pins in total.

That’s actually only the (“old”) plain password method you are using which doesn’t offer any encryption.

If you want to have a transport encryption you need to provide a key (32-byte base64 encoded string) like described in the docs:

  • password (Optional, Deprecated, string): The password to protect the API Server with. Defaults to no password. It is recommended to use the encryptionkey above instead of the the password.

potato potata…
I do know a lot of people disagree, but encryption on your local network isn’t really a requirement, definitely not for testing.

options:
easy. just use api without password nor encryption:

api:

moderate: use it with password, but no encryption:

api:
  password: MySecretPassword4321

expert use 32 bit encryption:

api:
  encryption:
    key: oeTUWNROdQgCzP/HnSS3WCsB3oF9VkBInSo+ezXKLTs=

but still the latter 2 are both optional….even the whole usage of api is optional (but faster though)

Thanks @orange-assistant for the update though, i must have missed it when it was implemented :thinking:

My esp32-wroom-32 board used to work fine with HA for 2 years until I changed my router, so this why I had to start again. I realised after I said the GPIO pins were for the arduino, that I hav ealways used those same pins on the board.

I have just re installed the yaml file to the boar by the ESPHome Web page and AFAIK it was successful , but it still can’t be added to HA, as it says to make sure there is an API line. Apart from the one with encryption and key, what else .

When you reflash the ESP device do you then delete the ESP integration for that device and re-add it again?

There is no esphome integration, because of the error about API

Ok, try to add it manually then by simply finding ESPHome in the integration list and the type in the IP address and then the API password from your YAMl file.

We can disagree about the “expert” level here. The encryption is not only the default if you create a new esphome node with the dashboard but also is the direct successor of the password which is already deprecated as to the docs.

In any way the problem of @Rob_Heselwood doesn’t actually look be related to the api at this point. Problems are more likely the auto discovery via mDNS or other network related configurations.

That’s already something. You might want to add the web server component to cross check if you can access the esp from your browser to then troubleshoot further.

web_server:
  port: 80

Hi @Rob_Heselwood,
I just noted ESPhome has another update (2022.1.7) related to your BME280, sounds like it is related :wink:

@aceindy
thanks for that, but it now makes me ask if I should use actual pin numbers as in the link like sda 21 and scl 22, instead of GPIO21 and GPIO21