Automation with zone codition for specific timespan

Hello,

I would like to create an automation that would turn on the heating only, if the person who triggers the automation has previously been out of the home for more than 10 minutes.
In trigger I use the state change from away to home for a person.

Under condition I would not like to add the fact that this person has been away for 10 mins or longer but I cannot do this. However, I can do this under Triggers but there it would not be needed. Copying the YAML from trigger to condition results in “extra keys not allowed @ data[‘to’]”

In both the trigger and condition blocks, the for would represent that the person had been home for 10 minutes, it does not reach back to the duration of the previous state. However, the trigger variable created whenever an automation fires will contain the previous state object of the person entity and you can use the last_changed value from that:

trigger
  - platform: state
    to: home
    from: not_home
    entity_id: person.X
condition:
  - "{{ trigger.from_state.last_changed < now() - timedelta(minutes=10) }}"
action:

1 Like

thanks, I will give this a try