Error changing Esphome OTA password

Help needed!

I started moving all my passwords to secrets.yaml file. I moved the wifi ssid and password and api password without any problems. But when i try to change the OTA password by following the docs i get an error.

The error shows up at ota: id line saying “ID ‘ota’ conflicts with the name of an esphome integration, please use an other id”.

According the docs id: is optional but when i remove it i get an new error. This time it’s at the lambda line. “Couldn’t find ID ‘ota’. Please check you have defined an ID with that name in your configuration”.

I tried changing the id’s to new_ota but endend up crashing home assistant… :frowning:

esphome:
  on_boot:
    - lambda: |-
        id(ota).set_auth_password(!secret ota_password);
  name: sonoff_4
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
    
  manual_ip:
    static_ip: 192.168.2.104
    gateway: 192.168.2.254
    subnet: 255.255.255.0

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: !secret api_password

ota:
  password: "Old password"
  id: ota

text_sensor:
  - platform: version
    name: sonoff_4_version
  - platform: wifi_info
    ip_address:
      name: sonoff_4_ip
    ssid:
      name: sonoff_4_ssid
    bssid:
      name: sonoff_4_bssid
  
sensor:
  # Uptime sensor
  - platform: uptime
    name: sonoff_4_uptime
    filters:
      - lambda: return x / 86400;
    unit_of_measurement: "days"

    
  # WiFi Signal sensor
  - platform: wifi_signal
    name: sonoff_4_wifi_signal
    update_interval: 60s

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
      inverted: True
    name: "sonoff_4_button"
    on_press:
      - switch.toggle: relay

  - platform: status
    name: sonoff_4_connection_state

switch:
  - platform: gpio
    name: "sonoff_4_relay"
    pin: GPIO12
    id: relay

  - platform: restart
    name: "sonoff 4 restart"

status_led:
  pin:
    number: GPIO13
    inverted: yes

Firstly ota is a reserved word on esphome and so you should use some other id as below. Not sure why has Ottowinter not mentioned this in his documentation. Secondly you cant access the secrets inside a lambda function, so you have to hardcode the password. That should be fine as you anyway have to remove this line once you have uploaded the code.

esphome:
  on_boot:
    - lambda: |-
        id(ota_id).set_auth_password("your_new_ota_password");

ota:
  password: "Old password"
  id: ota_id
1 Like

It works! Thank you :smiley:

Sorry for the confusion but i need to find a solution.
I have similar problem.
My yaml file

substitutions:
devicename: "garage_controller"

esphome:
  name: $devicename
  platform: ESP32
  board: lolin_d32
  on_boot:
    - lambda: |-
      id(ota_id).set_auth_password("V*1_pluj_na*KO");
ota:
  password: "OldPass*1"
  id: ota_id

During validation, I gets such error message

INFO Reading configuration /config/esphome/hub_d32_1.yaml...
ERROR Error while reading config: Invalid YAML syntax:

while scanning a simple key
  in "/config/esphome/hub_d32_1.yaml", line 11, column 7:
          id(ota_id).set_auth_password("V* ... 
          ^
could not find expected ':'
  in "/config/esphome/hub_d32_1.yaml", line 12, column 1:
    ota:
    ^

I took the instruction from the documentation

Again time sorry.
My fault. I set bad indent

on_boot:
    - lambda: |-
      id(ota_id).set_auth_password("V*1_pluj_na*KO");

it should be like this

on_boot:
    - lambda: |-
        id(ota_id).set_auth_password("V*1_pluj_na*KO");

Problem solved

1 Like