Little Help on Trigger/Timing/Wait Event please :-)

I have some actions I'm triggering from a virtual switch ("All Awake") which you guessed it, is to be turned on when everyone's awake. The rule I have pasted is to turn the switch on when we all are out of bed and my son's door has been opened - and can stay that way until confirmed we're in bed, turn it back off.

I only created it yesterday and turned it on manually and this rule successfully turned it off, but oddly not until 01:17 am, after us going to bed around 2230. Of course it's waiting for both bed sensors to be closed for 10 minutes, but I'd think it would have happened sooner so curious if my trigger is set on the wrong thing.

Ideas?! Thanks in advance for thoughts/opinions/suggestions :slight_smile:

The biggest help would probably be turning on logs for the rule. I'd enable all of trigger, action and event logging, then you can check Logs (current logs or past logs) to see for yourself why what is happening is--and when. Less guessing that way. :smiley:

Off hand, the main thing I can think of is that any trigger event firing will cause any waits to be cancelled (and everything after them, which is what I mean with cancellation). Whether this is a problem or not depends on what you want and when your devices generate these events, though it doesn't look like it should be a disaster to me unless one of the sensors doesn't remain as "closed" when someone has, in fact, been in bed that whole time. Device event history can help figure some of this out, but...rule logs are probably better.

Also, be sure to end each IF THEN with an END-IF. You're missing two at the end of your rule. This won't cause a problem (at least not in this case; it's not needed for the structure since you have nothing else after either), but it's a good habit to remember for when it does.

1 Like

logs would definitely be helpful. turn on the logs for the individual sensors so you can see when they trigger or not. it is possible one person could've been tossing in their bed and triggering the bed sensor open/closed. since you're waiting for each sensor to be open for 10 minutes, if one person shifts and resets it, this will reset your wait for event

2 Likes

Thanks to both of you for the input.. and I can tell you right now that I know the sensors tend to open/close frequently. I could have made the wait for event less than 10 minutes, but sort of trying to find a 'definite' way to confirm it.

So to your points about resetting the timers, what's the best way to handle that? I mean in layman's terms, something that would equate to "if both sensors are closed for most of the time, we're in bed"

Does it ever report as closed when you are not in bed?

No, and it takes some fine tuning lol.
The bed sensors are pressure mats that I've connected to the ecolink contact sensors. It really is a great automation, one of my favorites.
But the sensor will show open/close often as we move. Can't believe how well the batteries last considering that but they do.

But to answer your question, no when no one is in the bed, both sensors are reliably and consistently open.

Nice setup!

It should be easy to determine when everyone is in bed then (closed = in bed). As for getting up, it could be a combination of factors.

For that one, I would probably start with open for X minutes and see if it works. Could also be something like: After time X, when open, wait for motion is a closet or bathroom - whatever makes more sense. Then assume that the person which shows open is out of bed.

1 Like

I do a similar automation with a motion zone for a bunch of motion sensors. If time is between a certain range and no motion for 20 minutes i switch to night mode.

2 Likes

It looks like everything should have been in alignment here but the switch did not turn on. Hudson's for has been open for a couple hours at this point and all sensors have been open for more than 10 minutes.. :thinking:

Could this be it? "Wait for event" needs the event to happen before it starts counting the "stays" time (or just moves on if you don't use that feature). "Wait for Condition" will check the states at that time or wait for the state to become true (basically also the result of an event). Not sure if that would be what you want logically, but it should work if so.

3 Likes

Bingo, that was it! Just tested and it worked exactly as intended. Thanks to you all for helping me iron this out!!

1 Like

Download the Hubitat app