Zy-m100 presence detector with Tuya MCU

Use low melt solder for generally cleaner removals

@bill7531 @serialmakder Have you succeeded with the replacement? I have replaced mine with an ESP-12S module, but also get the ā€œInitialization failed. Current init_state: 0ā€ fault.

My soldering connections look alright and I have measured them from the original board connections to the new ESP-12S module and those connections are fine.

ESPHome is succesfully installed and can be updated OTA and seen in Home Assistant. Makes me wonder if there is an fault in the previously shared configs or some hardware has changed?

My code:

substitutions:
  device_ssid: "Tuya Motion Garage Achter"
  device_name: tuya-motion-garage-achter
  device_description: "Tuya ZY-M100 Motion ESP-12S"
  friendly_name: "Tuya Motion Garage Achter"
  main_device_id: "Tuya Motion Garage Achter" # Put the name that you want to see in Home Assistant.
  project_name: "tuya.zy-m100-wifi-esp-idf"
  project_version: "1.0"

esphome:
  name: ${device_name}
  comment: ${device_description}
  platformio_options:
    board_build.flash_mode: dio
  project:
    name: "${project_name}"
    version: "${project_version}"

esp8266:
  board: esp01_1m

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

# Enable logging
logger:
  baud_rate: 0

ota:
  safe_mode: true
  password: !secret ota_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  power_save_mode: none
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: ${device_ssid} AP
    password: !secret ap_password

sensor:
  # WiFi Signal sensor.
  - platform: wifi_signal
    name: ${friendly_name} Signal strength
    update_interval: 60s
    internal: true
  # Uptime Sensor
  - platform: uptime
    name: "${friendly_name} Uptime"
    id: uptime_sensor
    update_interval: 360s
    on_raw_value:
      then:
        - text_sensor.template.publish:
            id: uptime_human
            state: !lambda |-
              int seconds = round(id(uptime_sensor).raw_state);
              int days = seconds / (24 * 3600);
              seconds = seconds % (24 * 3600);
              int hours = seconds / 3600;
              seconds = seconds % 3600;
              int minutes = seconds /  60;
              seconds = seconds % 60;
              return (
                (days ? to_string(days) + "d " : "") +
                (hours ? to_string(hours) + "h " : "") +
                (minutes ? to_string(minutes) + "m " : "") +
                (to_string(seconds) + "s")
              ).c_str();
# Light Sensor
  - platform: tuya
    name: "${friendly_name} Light Intensity"
    id: light_intensity
    sensor_datapoint: 104
    unit_of_measurement: "lux"
    icon: "mdi:brightness-5"
    device_class: "illuminance"
    state_class: "measurement"
# Distance from Detected Object
  - platform: "tuya"
    name: "${friendly_name} Target Distance"
    id: target_distance
    sensor_datapoint: 9
    unit_of_measurement: "cm"
    icon: "mdi:eye"
    device_class: "distance"
    state_class: "measurement"
# Self Check Number
  - platform: "tuya"
    name: "Self Check Number"
    id: selfcheck
    sensor_datapoint: 6
    internal: True

text_sensor:
  # Expose WiFi information as sensors.
  - platform: wifi_info
    ip_address:
      name: ${friendly_name} IP
    ssid:
      name: ${friendly_name} SSID
    bssid:
      name: ${friendly_name} BSSID
  # Expose Uptime
  - platform: template
    name: ${friendly_name} Uptime Human Readable
    id: uptime_human
    icon: mdi:clock-start
  - platform: template
    name: "${friendly_name} Self Check Result"
    icon: mdi:eye
    lambda: |-
      if (id(selfcheck).state == 0) {
        return {"Checking"};
      }
      else if (id(selfcheck).state == 1) {
        return {"Check Success"};
      }
      else if (id(selfcheck).state == 2) {
        return {"Check Failure"};
      }
      else if (id(selfcheck).state == 3) {
        return {"Others"};
      }
      else if (id(selfcheck).state == 4) {
        return {"Comm Fault"};
      }
      else if (id(selfcheck).state == 5) {
        return {"Radar Fault"};
      }
      else return {"Unknown"};

switch:
  # this provides for a possibility to restart from the web console or Home automation should we ever need it
  - platform: restart
    name: "${friendly_name} Restart"
  - platform: safe_mode
    name: "${friendly_name} Restart (Safe Mode)"

uart:
  rx_pin: GPIO3
  tx_pin: GPIO1
  baud_rate: 115200

# Register the Tuya MCU connection
tuya:

number:
  - platform: "tuya"
    name: "${friendly_name} Sensitivity"
    number_datapoint: 2
    min_value: 0
    max_value: 9
    step: 1
    icon: "mdi:ray-vertex"
  - platform: "tuya"
    name: "${friendly_name} Near Detection"
    number_datapoint: 3
    min_value: 0
    max_value: 1000
    step: 1
    mode: slider
    unit_of_measurement: "cm"
    icon: "mdi:signal-distance-variant"
  - platform: "tuya"
    name: "${friendly_name} Far Detection"
    number_datapoint: 4
    min_value: 0
    max_value: 1000
    step: 1
    mode: slider
    unit_of_measurement: "cm"
    icon: "mdi:signal-distance-variant"
  - platform: "tuya"
    name: "${friendly_name} Detection Delay"
    number_datapoint: 101
    min_value: 0
    max_value: 100
    step: 1
    unit_of_measurement: "s"
    mode: slider
    icon: "mdi:clock"
  - platform: "tuya"
    name: "${friendly_name} Fading Time"
    number_datapoint: 102
    min_value: 0
    max_value: 1500
    step: 1
    unit_of_measurement: "s"
    mode: slider
    icon: "mdi:clock"

binary_sensor:
  - platform: status
    name: "${friendly_name} Status"
  - platform: "tuya"
    name: "${friendly_name} Presence State"
    sensor_datapoint: 1
    device_class: motion

Yes no luck. I tried 3 of them. In fact I thought it was because the sensor was a newer revision and just by luck had one thatā€™s identical to the guides (white board instead of black and corrugated casing instead of flat) but still no dice.

Also tried ceiling mount thinking I might have burned the wall mount version trying desolder the chip. The ceiling mount uses an adapter board and can be desoldered with just wick which means no heat is applied to the actual sensor board itself but again no dice.

All of these are zigbee and I ordered a wifi. I havenā€™t tried that. Will report back as soon as I do though.

Hi, any luck with the esphome transplant? Looks like I am in the same boat with the

Initialization failed at init_state 0

Iā€™m still unable to get this to work. I think Iā€™m going to remove these sensors as theyā€™re spamming my Zigbee network like no tomorrow :(.

Anybody got this working on the zigbee variants?

Any luck with this. I have the same issue. I have managed to change the controller on the side wall presence sensor and it is working fine. With the ceiling mount it is not working out at all and keeps giving me the same message: Initialization failed at init_state 0. I tried everything. Changing datapoints, baud rate, you name it. No luck to get this working.

I would also be interested to hear if anybody managed to get this working. I have a ceiling mount version and replaced the WBR3 (not entirely sure - went into the trash already) with an ESP8266. No luck activating tuya in the ESPHome config either :frowning:

@serialmakder Did you manage to get it working? It seems you have the same ceiling-mounted sensor.