Presence sensor as a trigger not a condition


#1

I was wondering if you guys could help me create a piston that when I arrive home (presence sensor) that it is on a timer in other words when I arrive home I only want the action to execute for only five minutes after arriving home more specifically when I open a door I don’t want it to execute everytime I open the door, but only the first time I open the door after arriving home via presence sensor. How would I code it?


#2

What I do is create two pistons. One to set a global variable: @arrivedHome. The other to trigger every time the door opens.

Piston 1:

If presenceSensor changes to present then
  set @arrivedHome=true
endif

Piston 2:

If door changes to open then
   if @arrivedHome is true then
       do something
       set @arrivedHome = false
   endif
endif

#3

Just to clarify a bit. SmartThings (and thereby webCoRE) is ‘Event’ based… so the piston monitoring the door’s contact will fire every time the door opens (or closes).

There is no way to prevent this.

But… as @guxdude mentions, we can program to direct the logic flow differently depending on other conditions.