State trigger not launching automation when met and can't understand why

Hi everyone! I’m completely new to HA, but managed to get some automations running well with some wyze motion sensors to turn on the light when it detects motion and turn off the light after not seeing motion for a while. I wanted to combine both into an automation that would trigger when a door sensor goes from open (on) to closed (off) if it’s closed for more than 5 seconds. This is the yaml of the trigger :

platform: state
entity_id: binary_sensor.wyzesense_door2
to: 'off'
from: 'on'
for: '0:00:05'

I’ll close the door, wait for say, one minute, and nothing happens. But when I’m looking at the developper tools in the current entities list, I can see the state change from ‘on’ to ‘off’ almost immediately as I open/close the door, yet, nothing happens.

I’ve found similar threads that seemingly had an older style of yaml that was very different, or some that reported a bug where rebooting HA wouldn’t enable the automations, which isn’t my case since after a reboot other automations trigger properly, and trying to manually disable and enable this one doesn’t affect its behavior whatsoever. All other examples I’ve found have installations seemingly identical to mine, so I don’t know what I’m doing wrong.

I’m at a loss, both in the fixing the issue department as in the diagnosing the issue department. Any help to pinpoint (or better yet, fix!) the issue would be greatly appreciated! Thanks a lot!

I was at my wit’s end and tried resetting the sensors, that seems to have done the trick. I don’t know why, but hey, if you have the same issue as me, don’t let go! x)

Thanks if you read this!