Time out on motion sensor

Hi Guys,

I’ve the following template sensor to combine my motion sensors. No i want to add some logic to it

I only want to change it to false when voor 30 minutes there is no motion. Can you help me ?

Thx!

- platform: template
   sensors:
      template_motion_woonkamer: 
         value_template: '{% if (is_state("sensor.sn1_motion", "True") or is_state("binary_sensor.aeotec_zw100_multisensor_6_sensor", "on")) %}True{% else %}False{% endif %}'

I can’t think of any way to do that in a template. It might be possible to save the last motion detected time with a bunch of automations, and evaluate that in your template, but if you think about what you are trying to accomplish there is probably a much easier way.

Automation Triggers and Conditions have a built-in “FOR” clause that measures how long a sensor has been in a particular state. So if your goal was for example to turn off a light if there has been no motion for 30 minutes you could do it like this:

- alias: no motion for 30 min
  trigger:
    - platform: state
      entity_id: sensor.template_motion_woonkamer
      to: 'off'
      for: 
        minutes: 30

  action:
    service: light.turn_off
    entity_id: group.all_lights

I can use a for but how can i use a for in the automation Gui?

doesn’t look like the GUI editor supports it yet