Node wait until or other suggestion

Hi.
What I am doing:

When there is motion in kitchen and the kitchen lights are off and illumination is below certain number, turn on a light.
If there is no motion for 10 minutes, close the lights.
The above is working fine.

What I am trying to do:
To turn on, the same as before. So no problem here.
But, if there is no motion for 10 minutes and the TV is on, wait until the TV turns off for 5 minutes and after turn off the kitchen lights.

I can’t get the part “wait until” to work.
Any suggestion?

Have a look at "wait until" - node not working
I don’t really understand why but the solution described in Wait until strange behaviour works for me…

If I understand correctly, you are wanting to turn the light off 5 minutes after the TV is turned off. If so, use the wait until node. Set the entity id set to the tv, The wait until fields should be set to ‘state’, ‘is’, and ‘off’. The timeout set to 0. It will wait patiently until the tv is turned off. Have that feed to a delay node set to 5 minutes and then the node to turn off the light.

What I forgot to mention (added now to first post), was that I wanted to wait until the TV is off for 5 minutes and then to turn off the lights.
Having said that, @greengolfer i tried your suggestion but unfortunately didn’t work.
@SigP Yes the way you mention does work. But do you know how to do what I just mentioned? To wait until the TV is off for 5 minutes and then proceed to next node?
This is my wait until node:

The wait until node is used to wait until the tv is turned off. Use a delay node to wait 5 minutes to turn off the light.

image

In the image in your last post, change the timeout to 0.

So what node(s) should I use to have the desired result?
I remind that I want the lights to turn off if the TV is off for 5 consecutive minutes.

Let me describe how the wait until node works. Let’s assume that there has been no motion for 10 minutes, the light is on, and the tv is on. The flow would then arrive at the wait until node. The way you show it to be set up, if the tv remains on for more than 5 minutes, the flow will stop. No lights would be turned off. That is what the timeout does. The timeout defines how long the node will wait for an event to occur. It does NOT define a pause after the event.

What I think you are wanting (correct me if I’m wrong) is that if you continue to watch the tv for more than 5 minutes, the light stays on. When you want the tv off, wait 5 minutes and the light should turn off.

If that is what you are wanting, set the timeout in the wait until node to 0. Doing so will make the node wait indefinitely for the tv to turn off. When the tv turns off, the flow will continue. You need a delay node to pause the flow for 5 minutes and then turn off the light.

Thank you SigP but this is not exactly what I want.

If there is no motion for 10 minutes, check if the lights are on. If yes, check if the TV is on. If no, close the lights. But if the TV is on, wait until it is off for 5 minutes and then choose the lights.
So for example, if my kid is playing with the remote and closes the TV and I turn it on right after, then with your solution, the lights will turn off after 5 minutes. So that is why I want the TV to be off for 5 consecutive minutes and then pass to the next node.
Maybe the wait until node, cannot give me what I want and I might need another workaround…

1 Like

Yes, that is a different scenario. You could put another current state node after the delay to see if the tv is still off. If so, turn off the light. If not, return to the wait until node. That would work unless the tv was turned on and back off in the 5 minute delay. In that case, the light would turn off 5 minutes after the tv was turned off the first time.

If that is not good enough, you can set up an input boolean whose state is changed by turning off the tv and use a trigger node to reset it after 5 minutes. Then check the state of that boolean before turning off the light.

1 Like

Sorry for digging up this old tread but I just faced the same problem just now and have come up with a solution that might work for you.
Picking up an @SigP 's suggestion, you could add this to cancel the “running” delay of 5 minutes as soon as the state of the tv changes. This would look like this:

Hope this helps, even when posted a little late.

The template node has to look like this:

2Screenshot 2021-05-03 172438

Sorry for doubleposting. As a new member I only am allowed to embed 1 media file