Creating a wait isn't stopping piston from re-triggering, trying to understand best way to introduce waits for piston triggers

triggers

#1

1) Give a description of the problem
Hi guys, I understand why this is happening but unsure best way to stop it. My motion sensor is re-triggering rapid restarts of my piston and canceling the wait period leading to multiple alerts too quickly over audio.

2) What is the expected behaviour?
Trying to figure out best way to re-structure my triggers so they factor in wait times. I’d like it so if someone came to the front door it said someone was there and waited 1 or 2 minutes rather than it keep saying " Someone is at the front door " every 10 secs over the speakers when the same motion triggers.

3) What is happening/not happening?
Retriggering of motion sensor every 5 seconds is restarting the piston and canceling the wait despite enabling no cancel task policy

**4) Post a Green Snapshot of the piston![

image|45x37]![

5) Attach logs after turning logging level to Full

Thanks!
REMOVE BELOW AFTER READING


#2

Yes it will say it again and again every time motion sensor changes to ACTIVE…
there are many ways of handling this. One of them is using a variable.

IF motion sensor 12 action changes to active
AND
IF front porch variable is True
then
With
Speaker 
Do
Speak "Activity in front porch detected"
Set variable to False
Wait 3 minutes
Set variable to TRUE

With this piston if motion is triggered again, since the variable is not TRUE the piston will execute but condition won’t allow speaker to say it again…
let me know if you need help with creating a variable…

Another way would be pausing the piston BUT some Pros won’t recommend pausing a piston and you will need another piston to control this piston FYI.


#3

Thanks so much, I am new to programming and was trying to figure out the best way to set up my pistons to be clean and non redundant, is variable the best way to do this? I just didn’t want to make my pistons too complicated/slow/messy. Trying to learn as I go, but I have another one that is similar. I am trying to set this one up to basically detect a change on my light sensor indoor to trigger different levels of ambient light inside using a different piston I made that has a case/switch set up based on the lux to determine the % to turn the lights. It keeps triggering every second though which is creating chaos and I think slowing down my set up. Is there a way to make it trigger every few mins or not trigger unless the change in lux is greater than say 50 or so? I cant figure out how to do expressions like this as a trigger. Thanks again for all your help, hope to get better at this the more I understand it.


#4

I’m not a coder but the one I wrote is soo simple, I doubt that it would cause any complications or slowness.

You can also create two simpler pistons and pause one of them.

About the illuminance stuff, I tried that for a while but I was extremely unhappy with the sensors. They don’t register fast, or read fast etc.
Lets say outside is 4000 (just making it up) it starts getting darker BUT my sensor is still registering 4000, finally it reads 1000 BUT a single light source, could be a car, a light bulb something, triggers the event again, though outside is dark.

let me know if you can make that one work…


#5

I would highly encourage that you keep your indoor light sensor far away from any of the lights it controls. (preferrably in another room entirely) Otherwise, low illuminance turns the bulbs brighter… which raises illuminance and lowers the bulbs… ad infinitum…

giphy


For what it’s worth, I use my illuminance sensor in the empty guest room to tweak the brightness levels in the livingroom (60 feet away & thru a closed door). If I have company sleeping over, that piston is programmed to not touch the levels, otherwise, the overhead lights there would affect the lights in the livingroom.

Also, any trigger based on:
temp
will fire **hundreds and hundreds of times each day.

I made mine to run every 15 minutes, but only if the sun is up.
This reduces the trigger event to about 50 times a day


#6

I created this switch piston to manage the fading lights, it’s been working well with my sensor as I have it pointing outside in a window sill into the backyard from upstairs. Only issue is I am trying to optimize things more so pistons don’t run unless there is a major change. Is there a way to create an expression to only run if the DELTA change in lux from the sensor is say > 100? The pre made options are great, but don’t have a delta change for the lux sensor to trigger the rest of the piston.


#7

The other piston (q9hs) will still trigger a thousand times a day.
To prevent that, I might code that piston with this basic structure:

define
    integer {currentLux} = (not set)
    integer {prevLux} = (not set)
end define

execute
    Every 15 minutes
    Set variable {currentLux} = Motion Sensor 12's illuminance
        IF {currentLux} is outside the range of {prevLux}-100 and {prevLux}+100
        Then 
            Turn on lights in other room
        END IF
    Set variable {prevLux} = {currentLux}
    END EVERY
end execute

You will likely need an additional IF to capture the days when the illuminance changes very slowly…


Honestly though, with a 15 minute timer as shown above, you can go directly into the “case” code you have above.


#8

Thank you, was wondering how to do do expressions with the lux change variable, is there a delta change expression built in?

Also for some reason my anon screen shot isn’t coming out right, it’s listing all my variable names, is that normal?


#9

All SmartThings can do is notify webCoRE upon changes.
It is up to webCoRE (and our programming) to do any math or residual comparisons.

Personally, to keep my SmartHome chatter to a minimum, I will never use illuminance as a trigger.


#10

Yes, this is normal. Variable names are usually innocent, unless you are naming devices based on names of a family member.


#11

Also keep in mind, that if your trigger is
temp
the delta won’t mean squat, since it will change (a little bit) every few moments all throughout the day


#12

Thanks for all the help guys! Much appreciated learning this stuff. This is what I’ve done so far from help. Piston 1 now should only activate if there is a large change in the delta eliminating a need for a timer!, then it triggers the second piston which controls the brightness of the light. Hopefully it works well.


#13

Please double check me, but I suspect if you turn your logging to Full on piston s5bwr, you will notice that the piston executes whenever the illuminance changes. At which point, it does the math on line 18, and determines whether to continue or not.

In other words, I think that that piston will still execute a thousand times each day.
(even though many of the triggers will cancel out shortly thereafter)

I am currently unable to test this, but I think it would be wise to confirm.


#14

Keep in mind with your current wording, you will get notifications every 100lux of change. No matter how slowly or quickly it happens.
(IE: Going from 0 to 5,000 means 50 notifications, and another 50 as nightfall approaches!)