Sonoff TH 16 RCWL 0516 motion detection

I am trying to install my Sonoff TH 16 with RCWL 0516 motion detection but am running into problems:

# 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"
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
binary_sensor2:
  - 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. 
INFO ESPHome 2025.7.4
INFO Reading configuration /config/esphome-web-7f9f08.yaml...
INFO Unable to import component binary_sensor2: No module named 'esphome.components.binary_sensor2'
Failed config

binary_sensor2: [source /config/esphome-web-7f9f08.yaml:60]
  
  Component not found: binary_sensor2.
  - platform: gpio
    pin: GPIO14
    name: MW Sensor Bathroom L1
    id: mw_sensor_bath_L1
    device_class: motion
    filters: 
      - delayed_off: 10s

I can not call it “binary_sensor” because this is being called further up already.
how can I fix my issue?

You can’t just invent component names. binary_sensor let’s the code know it should use the binary sensor component. Adding 2 will cause it not to match.

Delete the binary_sensor2 line, cut everything which was below it & paste it immediately under the original binary_sensor line.

That should fix your error.

1 Like
# 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

that worked, thank you very much. I haven’t uploaded it to the sonof TH yet but will try tonight