Changing the state of a motion sensor using an automation

Very infrequently my motion sensors don’t report that they are clear after movement. This affects automations based on movement detection. I want to reset the detection back to clear after 10 or 20 mins so that either a new detection happens, or the other automations run after a delay.

Things like motion lights trigger on detection but I do need some other automations to detect on clear

How can I use an automation(?) to change the state back to clear , my trigger is below

description: ""
mode: single
trigger:
  - platform: state
    entity_id:
      - binary_sensor.garage_z_motion_motion
    to: "on"
    for:
      hours: 0
      minutes: 1
      seconds: 0
condition: []
action: []

While you could do what you are suggesting, what if there actually IS motion when you’re trying to set it to clear?

In my mind, the only correct solutions are to either figure out why those sensors don’t work properly, or replace them with sensors that do.

Sensors that provide unreliable data are no sensors at all.

There’s no service call to set a binary_sensor’s state.

There’s a python_script available that can be used to ‘force’ an entity’s value to whatever you want but that new value doesn’t survive a restart.

How many motion detectors do you have that can fail to automatically return to ‘clear’?

1 Like

these are the upgraded sensors :smiley:

The delay for a real or forced “clear” to running any automation is much longer than the detection window, so if it isn’t actually clear everything will cope and run as intended

Reasons: crowded WIFI (100 IOT items but changing everything to ZIGBEE) , Distant zigbee hubs (need more), TUYA / Ewelink cloud API, H.A not noticing, and/or a restarted (integration on ) H.A etc

Hi, 10 sensors currently

is it possible to set up a virtual motion device that follows the binary sensor’s states but which can be set “manually” and can be used in automations in place of the real sensor

What type of sensors are these?

PIR motion (Tuya and Sonoff, )

You can create a Template Binary Sensor (for each one of your 10 motion detectors) and set its auto_off option to whatever value you feel is appropriate for your needs.

However, this isn’t useful if your motion detectors get permanently stuck on.

I think I answered it myself. I’ll set up a virtual switch. toggle it on / off when motion / clear is detected. If it has been on too long it will turn itself off. Then my automations can use the switch state instead of the motion detection state

Does that sound reasonable ?

See my post above.

can this “follow” the motion sensor state

Thank you, I’m reading up on these now.

The Template Binary Sensor will turn on when the motion detector turns on.

If the value of auto_off is 30, the Template Binary Sensor will automatically turn off after 30 seconds (even though the motion detector is stillon).

The Template Binary Sensor will turn on whenever the motion detector turns on again. In other words, when the motion detector’s state changes from off to on. If it turns on and stays that way indefinitely, then a Template Binary Sensor can’t mitigate that.

Thank you. I’ll let you know how I get on

:slight_smile: