Setting up different motion sensor timeouts for different time of day

WebCoRE newbie. I have a piston with two motion sensors to turn off one light switch. and with Bobbles help I believe I have that working correctly. Now I am trying to figure out a way to have a different sensor timeout for different time of the day, like when we go to bed. I’ve seen examples of “Only when-time is between” but I can’t seem to locate that and how would be the best way to lay that out. This is what I am working with. Thanks

White Bulb 1 is the switch

Here is how I do what you are looking for. I have an integer variable delayHours that has a ternary expression checking the location mode. If the current mode is Sleep then the delay will be 8 otherwise it will be 4.

Below in the code it is used as wait {delayHours} hours.

1 Like

A bit complex for my level, but I will see what I can do with it.


The ternary expression is a simple IF statement.

(Condition ? True : false)
1 Like

Is this the sort of thing you mean.
Between 06:00 and 22:00 the original 2 motion sensors control shutting off the light.
Between 22:00 and 06:00 a different motion sensor controls shutting off the light.
EDIT: Do you use day and night modes.
If you do then there is another way of doing it.
EDIT2: This is a better way of doing it. :slight_smile:

And here is a way of doing it if you use modes like Day/Home or Night.

1 Like

I was thinking last night about the day and night mode, I don’t currently use modes. Also I’m having trouble finding “time is between”. I need to do a little research on how to utilize the modes.

I actually want to use the same sensors but not to have as long of timeout after we go to bed.
During the day 15 minute timeout
During bedtime, little or no timeout. The sensors have a 4 min timout

Thanks for the samples!


Does this look like a good start?

Personally I would do it the following way.
If you want a different delay time for the two scenarios then you need two turn off statements.
One for wait 10 mins between 5 and 10 and one for 5 mins between 10 and 5.
If you are using the same sensors then you can delete the second if statement and delete the time in the first if.
Lots of way to skin a cat though. :smile:

1 Like

Thanks, I’ll look at it, I’m not second guessing you, however I would of thought the “or” statements would decide the time frame timeout and send it to the off switch depending on the time. The reason I don’t have a timeout on the first argument is because the motion sensors have a 4 min timeout and that is enough for the nighttime. And from what I can tell “so far” it does seems to be working as intended. I am using the same sensor during both time frames.

I do want to thank you for all your help!

1 Like