Help with piston to auto-set Armed (Stay) mode


#1

1) Give a description of the problem
I’ve written a piston to automatically set Smartthings to Armed (Stay) mode once we’ve gone up to bed for the night. It is based on all the downstairs lights being off after sunset. Although it works, if I turn the last downstairs light off but then turn another on the 5 minute offset doesn’t get reset. That means if I spend more than 5 minutes doing something the Armed (Stay) mode will be set regardless.

2) What is the expected behaviour?
If I turn the last downstairs light off but then turn another one on, I want the 5 minute offset to reset.

3) What is happening/not happening?
As mentioned above the piston pretty much works except for the timer reset issue I described.

4) Post a Green Snapshot of the pistonimage

Would appreciate any help to tweak this piston!


#2

There are many ways to do this. I would try using a single trigger and conditions…

IF downstairsLights stays off for 5 minutes   <-- Trigger
Then
  IF
    Time is after 30 minutes past sunset      <-- Condition
    and
    SHM is Disarmed                           <-- Condition
      Then
        Set SHM to stay
        Set location mode to Night
        Send PUSH
  END IF
END IF

A problem with the above is that the trigger could fire every 5 minutes all day/night long. That may not concern you. Depending on your system, you could add other logic to prevent that.


#3

That makes sense, although yes for efficiency if I can avoid the trigger firing all day and night then I rather would. What kind of logic could I add to this to prevent that?


#4

image

I use the NOT option with time when spanning midnight. I THINK this will work. I have not tested it. Others here may have a better method.

NOTE :
Generally, I do not code “automatic” SHM changes. You might want to insert some logic to confirm that SHM is set to your specifications. Maybe an announcement that SHM is set to Stay (or similar).

Also, I am not a fan of ONLY WHEN. So, depending on your system, other logic might work better.

I’m sure that @WCmore or @orangebucket are itching to critique me here. Feel free gentlemen…


#5

Just a reminder… the Classic app and SHM will be phased out in the coming months. You may want to start looking at moving to STHM and the new app. But webcore does not control STHM directly.


#6

Actually, your first example here @Pantheon is rock solid.
(it will not keep firing every 5 minutes)

The trigger:
IF downstairsLights stays off for 5 minutes
will only fire once exactly 5 min after the last light turns off, and will reset the timer if any light comes on during that period. (just make sure to leave TCP to default)


One small note: If the user goes to bed after midnight, the first condition may need to be tweaked a bit.
pic
(as mentioned above)


#7

Great. Yes, I could not decide/remember if the trigger reset after 5 minutes. Thank you.


#8

Webcore%20Green%20Check%20II


#9

I actually went through all my pistons the other day and switched them all to use Location Mode rather than SHM status. I’ve never really used any of my ST setup as an alarm in any way as I have a dedicated alarm system. A lot of my pistons are based on whether we are home, away or in bed and I just ended up using SHM for that but realised the other day that Location Mode seemed like a better choice.


#10

Sorry, been out of it a few days. I can re-do my piston based on your suggestion but just noted the comment from @WCmore that the first condition may need to be tweaked in the scenario we go to bed after midnight…that is a possible scenario but I’m not sure exactly what to tweak. Can you help please?


#11

@Pantheon deserves the credit, but basically this:

IF ALL of downstairsLights stays off for 5 minutes      <-- Trigger
Then
  IF
    Time is NOT between sunrise and 30 min past sunset  <-- Condition
    and
    SHM is Disarmed                                     <-- Condition
      Then
        Set SHM to stay
        Set location mode to Night
        Send PUSH
  END IF
END IF

#12

Thanks. I tested the previous version of the piston last night when I went up to bed after midnight. The piston worked in terms of setting night mode but then kept sending my push notification every minute.

Anyway, I’ve now re-written the piston in line with your guidance (screenshot below). Will report back how it works…