calberrt Posted September 7, 2015 Posted September 7, 2015 Hi Guys, I have a dog that likes to go outside at night. I have written a program that turns on the backyard lights when I open the sliding door. It works perfectly. Here it is. Backyard Lights ON - [iD 0058][Parent 0060]If Program 'Dark Outside' is True And Control 'Sliding Door Open' is switched On Then Set 'Backyard Keypad' On Set 'Landscape Lights' On Else - No Actions - (To add one, press 'Action') I would then shut the door. What I would like to do is to write another program that will automatically turn off the lights when I open the sliding door again to let him in. I cant seem to wrap my head around how to test if the door is opened within say 10 minutes of the original door being opened. If this happens, I'd like the lights to turn off. Any help would be greatly appreciated. Thanks Calberrt
g1of4 Posted September 7, 2015 Posted September 7, 2015 Logically you could use a state variable to indicate the location of the dog. When the dog is inside, going out you change the state to 1. Since it was 0 when the door was opened, you turn lights on. The next time when it is 1 and you open the door you can turn the lights off. The can be encapsulated in one program if you like, or separate programs. The challenge is if you need to open the door to yell at the dog to stop barking in between
paulbates Posted September 7, 2015 Posted September 7, 2015 (edited) Hi Calberrt One way is to make these modifications. You'll need to add a state variable (not integer) called dog_out, to keep track of whether the dog is in or out. The 10 second wait and setting the variable will keep the second program from triggering when you first let him out until you close the door after letting him out. Otherwise it will turn the light off right away when you let him out. Use a wait value that is reasonable for how long you would have the door open to let him out. These programs assume that you open the door, let him out and close the door within 10 seconds. If you let him back in within 10 seconds it might get confused. I know my dog is flaky about how long he's out. There are more potential program safeguards, like the first program turning the lights off after 10 minutes as a safeguard. However, if this is a doorwall with a screen, and you keep it open after dark in milder weather, that will get tricky. Backyard lights - Dog out If Program 'Dark Outside' is True And Control 'Sliding Door Open' is switched OnThen Set 'Backyard Keypad' On Set 'Landscape Lights' On wait 10 seconds $dog_out = 1 Backyard lights - Dog in If Program 'Dark Outside' is True And Control 'Sliding Door Open' is switched Off And $dog_out = 1Then Set 'Backyard Keypad' Off Set 'Landscape Lights' Off $dog_out = 0 I would also consider creating a scene for your keypad and and landscape lights, but after you get a solution for your initial requirement worked out Paul Edited September 7, 2015 by paulbates
calberrt Posted September 7, 2015 Author Posted September 7, 2015 Thanks so much, worked like a charm
Recommended Posts