SmartThings Community

State Changes twice or X times?

peer_support

#1

So lately I have been getting a lot of triggers from my Vibration Sensor. Single triggers possibly caused by gusts of wind? Large truck? Or so…

I plan to setup a Piston in order to take care or it. Everythjng is set up however I cannot figure out how to set it to trigger if for example the state changes 2 times of 3 times.

I see that i can use IF “Active” for 1 minute. However the way the vibration sensor works is more like bursts.


(Jason "The Enabler" as deemed so by @Smart) #2

I would use a variable. Do a search here.


#3

I am assuming but that you mean:

On state change X=X+1

If X = 2 then TRIGGER.

If after 5 minutes X is SAME then X=0.

I think its a bit of an overkill. Am i assuming wrong? Isn’t there perhaps an easier way of doing it?


(Jason "The Enabler" as deemed so by @Smart) #4

Yeah, something like that.

I don’t worry about ease of setup… What’s most reliable for the use case.


(Robin) #5

I haven’t tested it but I think something like the following would work:

If memory serves the THEN IF’s reset after about 10 seconds so should work nicely.

The above works for button presses when entering a pin code, don’t see why it won’t work for vibration.


#6

Wonderful! Thanks. Will test it soon.


#7

It didn’t work. Instead it waited until it hit 3 vibrations in a row and then it triggered. Regardless there was hours in between.

So I opted for this instead:

However I am unsure my if my logic is correct. Will it clear every 5 minutes? Or will it run every time and every time it will wait 5 minutes and clesr the variable, causing it to never trigger? Please advice. Is this the proper way to add a wait time?


#8

I didn’t work. Whatam I doing wrong? Is that not the way to clear tge variable after 5 minutes?


(Robin) #9

When using expert mode you need to avoid using triggers and conditions in the same piston (dots and circles).

Also, as CoRE calculates conditions immediately upon trigger, it will not fire the notification on 3rd vibration as the counter will still be on 2 (for another half second).

Suggest you use a global variable (put an @ symbol in front of the variable name) and then do this in two Pistons, one for the counter and one for the notification.

Notification piston could be:

IF
variable @X changes to 3
AND
Door is not open
THEN
|> Send notification
|> Set variable @X to 0

You also need to initialise the variable to 0 as it defaults to ‘null’. Null+1=null.

You can watch the Pistons working and the variable changing in real time using the CoRE web dashboard… Dashboard view is also better for screenshots of your Pistons.


#10

But what about restting it? I want to reset the variable IF there is no 3 consecutive motions in 5 minutes.


(Robin) #11

You should be able to do that as a seperate IF block in the counter piston.

IF
motion IS active
WHEN TRUE
® when variable @X is less than 3
|> set variable @X + 1

IF
motion does not change for X minutes
WHEN TRUE
|> set variable @X = 0

The reason it wasn’t working in your example above is because you mixed triggers and conditions whilst using when true (expert mode) options. Needs to be all black dots or all black circles, don’t mix.


#12

How do i setup the does NOT change?

Also lost me abit with black circles and dots lol


#13

How’s this?


#14

Should it be in an AND or perhaps in a THEN IF? The not changes part.


#15

This seems to make more sense: