Updating to 2024.4.3 and Tuya PIR is now broken - Tuya Model RH040 - b5g40alm

Hi everyone,

Just did an update to my core Home Assistant from 2023.3.2 to 2024.4.3 – it’s quite a jump.

Once it’s upgraded, I noticed that my Tuya integration broke down – easy fix, I put in the user code id and it all works again – except – 5 Tuya PIR sensors that I have.

I have two kinds of Tuya PIR sensors:

  • Model ZG-204ZL - TS0601 | _TZE200_3towulqd - linkthis one works fine after the update – I have two and both are fine
  • Model RH040 - b5g40alm - linkthis one doesn’t show any log after the update – I have 5 of them and nothing works in HA.

Quite puzzled on what I can do here since I have tried to reset, take out the battery and put it again, restarted HA, and so on.

The interesting thing is that Smartlife app still recording motion, BUT it just not showing up on Home Assistant.

Tried to search for more information online about this issue, but it doesn’t seem that anyone experienced this before.

Any suggestions on what I should test here? Appreciate the help.

What Zigbee stack are you using, ZHA, Zigbee2mqtt or a Tuya hub?

Hey again Francis, this one use a Tuya hub. So it’s works fine under Smartlife / Tuya environment. But the weird thing is those 5 sensors won’t connect to HA although the battery shows fine.

Ok done, I’ve found a workaround on this.

It seems that 2024.2 broke Tuya PIR sensors integration (and some others too), so we have to do a workaround for cheaper PIR sensors to ‘clear’ the status after xx minutes.

Here’s some related posts:

Here’s what happened on my case:

  • The PIR sensors work fine, they send the status (motion detected) to Tuya cloud
  • Tuya cloud send status to Home Assistant (motion detected) – this is all good, at least until here
  • The PIR sensors cleared (they do not detect anyone), and send the status to Tuya cloud
  • and here’s when it starts failing down: Home Assistant failed to ‘know’ that there’s no one around and the state for the sensor stuck at ‘motion detected’ – since that, Home Assistant failed to acknowledged any new incoming motion detected, because the state never ‘cleared’

The workaround basically just ‘cleared’ the state every x minute, so it will receive new state. I’ve set it to 3 minute to follow the actual device, which will only clear after 3 minute. Ideally you would want the sensor and Home Assistant cleared the state at the same time.

alias: Sensor Reset - PIR 3
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.pir_3
condition: []
action:
  - delay:
      hours: 0
      minutes: 3
      seconds: 0
      milliseconds: 0
  - service: python_script.set_state
    metadata: {}
    data:
      entity_id: binary_sensor.pir_3
      state: "off"
mode: restart

# thanks to @astenger - https://github.com/astenger - https://github.com/home-assistant/core/issues/109972

Note:

My PIR is zigbee
It’s already on Tuya cloud using Tuya hub
It’s working on Tuya cloud / Smartlife app, but it’s not passing the right status to Home Assistant, hence the reset is needed

Also, you may need to ‘unstuck’ the state before this reset timer even works, so I have this reset YAML to run if needed:

alias: Dummy Reset - PIR 1345
description: ""
trigger:
  - platform: device
    type: turned_on
    device_id: 3fdb6be2e5ad9b89974dc960f32d42fd
    entity_id: f574e4b7da0f0f64358141e5296d1d9f
    domain: switch
condition: []
action:
  - service: python_script.set_state
    metadata: {}
    data:
      entity_id: binary_sensor.pir_1
      state: "off"
  - service: python_script.set_state
    metadata: {}
    data:
      entity_id: binary_sensor.pir_2
      state: "off"
  - service: python_script.set_state
    metadata: {}
    data:
      entity_id: binary_sensor.pir_3
      state: "off"
  - service: python_script.set_state
    metadata: {}
    data:
      entity_id: binary_sensor.pir_4
      state: "off"
  - service: python_script.set_state
    metadata: {}
    data:
      entity_id: binary_sensor.pir_5_pindah_lt_3
      state: "off"
mode: restart

Basically I pressed a trigger, and it resets all that I need.

1 Like

I’m on 2024.4.1 and have the same problem. I have 4 tuya PIR sensors that work fine in the Smartlife app but are always in the “motion detected” state in HA. And I use the same workaround for now - although with a pyscript rather than a native HA automation, but the same idea.

Hopefully we can retire this workaround soon…

Fingers crossed. It’s quite annoying because I have my HA set up ‘perfectly’, and then after updating, things start breaking down.

I did experience a 1-2 second delay with this script, and there’s a potential stuck point when someone passed by in-between the actual device MOTION CLEARED in Smartlife, and this HA reset CLEARED. I hope it’s not going to happen soon.

I didn’t see anything in the 2024.5.0 release notes about this, sadly, and the various workarounds I’ve tried don’t quite get proper motion detector behaviour back, making them useless for motion controlled lights. Time to move those automations back to Alexa, I guess… :frowning: