Amend "Wait For" action to have an option to check current state

Currently the “Wait for” action needs a state change to be triggered. There should be an option for it to also check the current state.

The best way of summarising the feature request is to have the same as the option “Check against current state” which is available in the NodeRed “wait until” node.

For example wait for a motion sensor to be clear for 15 minutes before moving onto the next action.

Currently if the motion sensor is already clear but only just then the action would never fire until the timeout.

You can just about achieve a very similar outcome in a automation but you have to use a complex combination of the “Choose”, “Wait For” and “Delay”.

And if you want to “wait for” multiple entities then it becomes unmanageable.

My example is: wait for there to be no motion on all motion sensors upstairs for 15 minutes before opening the blinds and only if it’s after 8am.

Ideally you would just create an automation to fire at 8am and then have a “Wait For” action for each motion sensor which waits at each action until the “For” (x seconds, minutes, hours) condition is met, and continues immediately if it is already met.

A Wait for Trigger action can be triggered by any of the 15 different types of triggers, not just a state change. The Wait for Template action does evaluates the current state of each entity in the template immediately then re-evaluates it every time an included entity changes state.

Waits do not survive restart and , until very recently, did not survive the automations and/or script reload that would happen any time you edit an automation or script. So, extended waits have been, and still are to some extent, something to avoid.

Why would you tie up resources in a wait that could last an indefinite time? It is often best to design your automations so that the trigger is based on the event that is closest in time to the desired execution of actions as is possible. By using a group helper for your upstairs motion sensors you could acheive your example with a relatively basic automation:

  - platform: state
    entity_id: binary_sensor.upstairs_motion_group
    to: 'off'
    from: 'on'
    for: '00:15:00'
  - condition: time
    after: "08:00:00"
  - service: cover.open_cover
      entity_id: cover.upstairs_blinds

Hi Drew,

Some very good points in there, thank you for taking the time to reply.

After writing this I did actually simply things with a group helper.

The automations engine has come a long way in the last couple of years; it’s great to get some of these out of NodeRed and back into HA.

I would suggest we close this one off.