Triggering an automation when a state has been *from* (not "to") for X time

I want to trigger an automation whenever my device_tracker has been not home for a certain amount of time. The following does not work, because from: apparently doesn’t work with for:

    platform: state
    from: "home"
    for: "00:10:00"

I can’t use to: "not_home" (which does work with for:), because I have device trackers that report zones, and I’d rather not list all of my zones in the to: field (and in any case, if they’re moving between two zones, or between a zone and the generic not_home, I’d like to combine the times when counting how long they’ve been away from home).

Any advice?

Try this:

    platform: template
    value_template: "{{ not is_state('', 'home') }}"
    for: "00:10:00"

As the tracker does not transition to home when moving between other away zones I think it should do the trick.

1 Like

that makes a lot of sense. Thanks!

How would you put this in a template for a binary sensor? I’m trying to determine if none of my three device_trackers (actually they’re binary sensors) have changed to ‘home’ (‘on’) in the past two minutes.