Struggling at stage 1 to create piston using Presence, Lights and door contact


#1

2) What is the expected behaviour?
I would to create a piston to do the following when I arrive home :

A. upon arrival to home, Driveway lights turn ON in the evening
B. Driveway lights stay ON while Frontdoor OPENS
C. Driveway lights TURN OFF 1 minutes after Frontdoor then closes.

I’m ok with part A and the initial trigger, however I can’t get my head around the logic for B & C. Thanks for looking.


#2

Perhaps something like this?

if presence changes to present            <--- trigger
   and 
   $hour24 is greater than 18                <--- condition
then
   turn on driveway lights
end if
if front door contact changes to closed        <---- trigger
   and
  driveway lights is on                                   <-- condition
then
   wait 1 minute
   turn off driveway lights
end if

#3

I would also consider adding a “safety net” to catch unintentional presence changes.

For example, you could be sitting on your couch at 9pm, and your location will jump away and back home… Thereby turning on your lights, and not turning them off until (potentially) the next day when the door opens and closes.


If you use @guxdude’s piston above, you can create a simple safety net (in a separate piston):

IF Driveway's switch stays on for 15 minutes
    Then Turn off Driveway 
END IF

#4

Thank you for your replies, I’ll have a go and feedback here later.


#5

Wow…worked exactly as I needed… simple when you know how… :slight_smile:

Thank you.

I thought I needed nested IF’s… Please could briefly explain circumstances where nested IF’s or separate IF statements are best suited?


#6

@wcmore may be better at explaining but if you have more complex logic, you would put your trigger in the top level if and then the nested ifs would be conditions to fine tune. an example might be within your piston above, you don’t care who comes to turn the light to go on. But maybe once you are inside, you want to add a greeting. So it might look like this:

if presence changes to present            <--- trigger
      save matching device to whoCameHome          <--need to define this device variable
   and 
   $hour24 is greater than 18                <--- condition
then
   turn on driveway lights
end if
if front door contact changes to closed        <---- trigger
   and
  driveway lights is on                                   <-- condition
then
   wait 1 minute
   turn off driveway lights
   if whoCameHome is equal to Roger's device
   then
       with echo
          speak "Welcome home, Roger"
       end with
    end if
    if whoCameHome is equal to someone else
        with echo
            speak "Welcome's home someone else"
         end with
     end if
end if
IF Driveway's switch stays on for 15 minutes
    Then Turn off Driveway 
END IF

#7

Good description, @guxdude

For what it’s worth, I would highly recommend keeping those last 3 lines in a separate piston.

IF Driveway's switch stays on for 15 minutes
    Then Turn off Driveway 
END IF

Otherwise, doors opening / closing or GPS jumping can mess with that timer.


#8

Thanks to you both once again. It’s becoming more clear day by day.


#9

As these automations get more and more complex, how do you personally manage having multiple pistons for sorta the same task. Seems like it would make troubleshooting a nightmare.


#10

It all falls down to two practices:

  • The naming structure… (they are sorted alphabetically) …and
  • The category they are stored in (which can be re-ordered)

#11

Sorry, I know I’ve pulled this offtopic…

I assume that you must have quite a few pistons, so you’ve already figured this out. I’ve really struggled with the proper way to order my chaos. Could you give a few examples?


#12

Have you seen these two posts?