Over the air updates OTA Sonoff TH

# https://github.com/somarkram/esphome-examples/blob/d316a7bf3b68ad635c96c0e74be8be6dfc326ade/sonoff-th16-si7021.yaml
substitutions:
  name: sonoff-th16-rcwl0516
  friendly_name: Sonoff TH16
esphome:
  name: $name
  comment: Sonoff TH16
  name_add_mac_suffix: true
  # This will allow for (future) project identification,
  # configuration and updates.
  project:
    name: cpyarger.sonoff-th16-rcwl0516
    version: "1.1"
esp8266:
  board: esp01_1m
dashboard_import:
  package_import_url: github://cpyarger/esphome-templates/sonoff-th16-si7021.yaml@main
# Wifi Setup
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
# Enable logging
logger:
# Enable Home Assistant API
api:
#ota:
#  - platform: esphome
#    password: "9090909090"
#    num_attempts: 3
#    safe_mode: no
status_led:
  pin:
    number: GPIO13
    inverted: True
binary_sensor:
  - platform: gpio
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
      inverted: True
    name: "Button"
    on_press: 
      then:
        - light.toggle: this_light
  - platform: status
    name: "${friendly_name} Status"
  - platform: gpio
    pin: GPIO14
    name: "MW Sensor Bathroom L1"
    id: mw_sensor_bath_L1
    device_class: motion
    filters:
      - delayed_off: 10s # wait for 10 seconds without motion to send OFF. 
      # Play with this value, to find the right balance. For bed/bathroom or office it can be much higher compare to a walk through hallway. 
output:
  - platform: gpio
    id: output_1
    pin: GPIO12
light:
  - platform: binary
    output: output_1
    name: "${friendly_name} Light"
    id: this_light
# Sensors definitions
# See https://esphome.io/components/binary_sensor/ for all config Parameters
# https://vdbrink.github.io/esphome/microwave_radar_sensor_rcwl-0516.html

this code works flawless now, thanks to @ShadowFist

Linking .pioenvs/sonoff-th16-rcwl0516/firmware.elf
RAM:   [====      ]  38.1% (used 31248 bytes from 81920 bytes)
Flash: [====      ]  37.2% (used 380875 bytes from 1023984 bytes)
Building .pioenvs/sonoff-th16-rcwl0516/firmware.bin
esp8266_copy_factory_bin([".pioenvs/sonoff-th16-rcwl0516/firmware.bin"], [".pioenvs/sonoff-th16-rcwl0516/firmware.elf"])
esp8266_copy_ota_bin([".pioenvs/sonoff-th16-rcwl0516/firmware.bin"], [".pioenvs/sonoff-th16-rcwl0516/firmware.elf"])
======================== [SUCCESS] Took 301.46 seconds ========================
INFO Successfully compiled program.
ERROR Cannot upload Over the Air as the ota configuration is not present or does not include platform: esphome

I tried to do an OTA update before installind the device into it’s not very nice to access location.
Can the sonoff TH16 receive OTA updates, it is limited regarding memory?

[quote="huramentzefixx, post:3, topic:947918"]

#ota:
#  - platform: esphome
#    password: "9090909090"
#    num_attempts: 3
#    safe_mode: no

do I invent a password or is it the one from the esphome configuration file?

Hello huramentzefixx,

Another good place to ask ESPHome questions is ESPHome

OK thank you but I am here with my question.

I am pretty new to HAS.
Thanks for the advise, I will start using ESPHome too.
I thought this question would be OK here?

I have moved it to the ESPHome category for you.

Have you tried clearing your ESPHome cache, recompiling, and uploading? You may have old obsolete code lurking that may be getting in the way.

Thanks for the hint.
I have recompiled but not deleted my esphome cash.
It’s a seperate docker in my case, I am running it on ubuntu server on docker.

[quote="huramentzefixx, post:3, topic:947918"]

#ota:
#  - platform: esphome
#    password: "9090909090"
#    num_attempts: 3
#    safe_mode: no

not sure what to do with this though.
platform OK I leave, but what would my password be?

how do I clean cash of esphome?

esphome OTA updates

ota:
  - platform: esphome
   on_begin:
      then:
        - logger.log: "OTA start"
   on_progress:
      then:
        - logger.log:
            format: "OTA progress %0.1f%%"
            args: ["x"]
   on_end:
      then:
        - logger.log: "OTA end"
   on_error:
      then:
        - logger.log:
            format: "OTA update error %d"
            args: ["x"]

results in the following output:

INFO ESPHome 2025.7.4
INFO Reading configuration /config/esphome-web-7f9f08.yaml...
ERROR Error while reading config: Invalid YAML syntax:

while parsing a block collection
  in "/config/esphome-web-7f9f08.yaml", line 28, column 3
expected <block end>, but found '<block mapping start>'
  in "/config/esphome-web-7f9f08.yaml", line 29, column 4

To clean your cache, for your ESPHome device, select the three dots on the bottom right corner (the “Overflow menu”), and then the “Clean Build Files”. This will purge the existing files, and result in a fresh download of the subroutine files needed to compile your final code, possibly eliminating conflicting version issues and corrupt files. Your next compile will take a few seconds longer while it downloads, but that is a one off, and gives you confidence you have good files. The new files are “cached” again, until they need to be overwritten, usually as part of an upgrade. Given there are upgrades of different software all the time, the chances of some being the wrong version can vary, depending on the order they are installed and the dependency lookup tables. Flush and re-download takes care of it. Use wisely, especially if having errors.

Bonus: Disk space savings as some of the old crud hangs around forever if you don’t flush it.

thank you but I have no dots, not one, not two nor three…
I am on docker not a normal installation.

[quote="huramentzefixx, post:3, topic:947918"]

#ota:
#  - platform: esphome
#    password: "9090909090"
#    num_attempts: 3
#    safe_mode: no

I am not sure how your suggestion would help me with my probem?
but you don’t knwo what you don’t know might be the answer to that?

I am trying to get my code wworking so that I can do OTA updates.
can you help me with the code?

I see some upcoming prune and no-cache searches in your docker documentation…

It won’t fix YAML code issues however.

@IOT7712 thanks for looking into this but howw would I solve this issue?