Help with what should be a fairly simple rule for my kid's white noise machine

We have a white noise machine that we turn on and off everytime my daughter goes down for a nap or bed so I thought I would automate this and then tuck the white noise machine out of sight.

Here's my rule below.

Basically I want the white noise machine to turn on if the door is closed between 6:45p and 11:55p then stay on, regardless of whether the door is opened throughout the night, until 6:00am and then turn off if the door is opened after 6:00am.

It has worked reliably for the last couple of nights but this morning my daughter slept until 8am and the white noise didn't turn off when I opened the door. Checked the logs and the door opening was recognized in the logs. The white noise machine came on properly last night when I put her to bed and closed the door, just didn't turn off when I opened the door this morning.

Thanks!!

image

Was the door opened and closed during the night? I'm suspecting that the schedule for the wait was canceled because the rule was executed again. I would change it to be the following:

TRIGGER:  Door Chaning

Action:  

If Door closed and time between X and Y and Switch is Off THEN
    Turn switch on
ELSE IF Door is open and time between A and B and switch is On THEN
     Turn switch off
END-IF

That is a lot more clean that using the waits. This also means that if you turn it off by hand, it will come back on. If you want to account for that you;d have to use a variable instead of the switch state as a condition of the rule.

Thanks @Ryan780! I'll give this a try. Are wait commands not reliable? Any guesses why my rule didn't turn off the switch when the door opened at 8am?

I would need to see logs. Wait are reliable...but they can also be affected by other things. And two waits in a row with nothing in between might cause an issue. I also have not seen a wait that spanned midnight. I would have to see the rule's properties page after the door was closed between those times to see what the subscriptions were to see if the trigger would happen. If you want to leave the rule and turn on logging we can try and figure out why it didn't work.

Ok, I'd be interested to know why it didn't work as well for future reference when trying to build rules.

I'll turn on Event, Trigger and Action logging for that rule and see if we can figure it out!

Okay....but you're going to have to have it fail again in order to find that.

Agreed and unfortunately (fortunately?) it hasn't failed yet...

1 Like