Using last_changed in an automation to handle quickly toggling a button through a sequence of steps

I’m trying to cycle a couple lights from (off, off) -> (off, on) -> (on, on) -> (on, off) -> (off, off) when a physical switch (binary_sensor) changes states. I’ve done this using a choose action trigger and it works fine. The caveat is that if the binary_sensor hasn’t changed states in more than a second I’d like to just go to (off, off) to reset the sequence without having to toggle over to it.

I’m trying to use a template to make this decision: {{ now() - trigger.from_state.last_changed > timedelta(seconds=1) }} but it is never true when executing in the automation. I suspect it’s because the last_changed value is updated when the trigger fires, and does not contain the value from the last change that happened before the trigger fired. Is there a way around this?

Well from what I can tell it’s mostly working as I expect, despite initial testing. I wonder how reliable it is but with a buffer of a couple seconds it seems to work fine for my purposes.