IF motion is detected, and a certain light is off, turn on this switch


#1

Hi guys- Got what I thought would be simple, and it might be for some of you, but has a few IFs and variables that I’m sure I’m just not putting the correct order.

We have a neighborhood cat that likes to visit in the middle of the night and crap on the deck and rile up our dogs. What I’d like to do I think makes sense, but it’s not working for me.

If it’s between 8:00 PM and 6:00AM, and motion is detected (with a motion sensor on the deck) turn on a switch which has a sprinkler valve connected to it. Turn sprinkler on for 10 seconds then shut off.

Here’s the other IF. When I take the dogs out, I don’t want it to fire if I have the deck lights on, so basically IF I turn on the deck light in the middle of the night to let the dogs out, and their motion sets it off they don’t get wet.

For some reason it’s not working with that deck light. I was able to get it to fire with motion during that time, but it also fires if the light is on or off. So it’s just that last light part I’m missing. Any help would be appreciated.

1) Give a description of the problem
Trying to create an automation to turn on a sprinkler if motion is detected after a certain time, IF a light switch isn’t on

2) What is the expected behaviour?
If it is between 8:00 PM and 6:00 AM
And Motion is detected
Turn on a switch (which fires a sprinkler for 10 seconds)
Turn off

Only if a certain light is not on.

3) What is happening/not happening?
Firing regardless if a switch is on or off.

4) Post a Green Snapshot of the pistonimage

5) Attach logs after turning logging level to Full
(PASTE YOUR LOGS HERE THEN HIGHLIGHT ALL OF THE LOGS AND CLICK ON THE </> ICON TO FORMAT THEM CORRECTLY)


#2

always put the trigger (yellow lightening bolt in the far left of that line indicates a trigger) first … so move Motion sensor 2’s motion changes to active to the first line


#3

Looks like it should work but drag the motion trigger up top to be the first line statement. Statements gets processed from top to bottom. Also, click the WITH and its settings, change the Task Cancelation Policy to Never so that the motion changing from active to inactive doesn’t cancel your timer.


#4

It looks like it should work. Ideally you want the motion trigger first, just because you want it to always be tested when a motion event happens. Otherwise it might not calculate changes correctly the first time you need it to. Ideally you also want the TCP set to ‘never cancel’ just to ensure the timer completes if motion goes inactive. It is quite likely your motion sensor takes longer than ten seconds to reset but sometimes events get inexplicably delayed.

Both of those are just about reliability though. You really have the opposite problem with it working when it shouldn’t. The question is, why is it not respecting the switch condition? Presumably the switch is reporting its state reliably to SmartThings? Also that the logs show the piston is indeed seeing it as off when it should be on? If so I’d suggest perhaps removing the switch from ‘Available Devices’ and the piston, then adding it back again, just to make sure it is set up correctly. On very rare occasions I’ve known that to make a difference.


#5

Thanks guys, appreciate the help.

Really the switch is acting as a check, as we tell Alexa to turn on the outside lights before we take the dogs out. That group of “outside lights” contains one of those switches which I was using, since I don’t have “outside lights” as a group in smart things, so I figured I could just pick one of the outside lights that comes on in the Alexa “outside lights” and use that as a safeguard. Meaning IF the switch is on and motion is trigger don’t turn on the sprinkler.


#6

In addition to the advice above, I would also invert the times (so as to not span midnight).

IE:

IF Sensor's motion changes to active
Then
   IF Time is NOT between 6AM and 8PM  <-- INVERTED
      and
      Switch 14 is off
   Then
      With Switch 13 (TCP set to never)
         Turn on
         Wait 10 Sec
         Turn off
   END IF
END IF

This ensures that the sprinkler is only allowed to come on 8p-6a