Tilt sensor to notify after 5 minutes open


#1

Help me with this piston please. Brand new to this stuff.

I have a tilt sensor on my garage door. I have a busy house, and sometimes someone leaves it open all night. I want it to send me a notification or maybe blink a light or something if it’s been open for longer than 5 minutes. I was able to make a piston to flash a light inside when someone triggers my driveway or front door motion sensor, but not sure where to start on this one. The part that is throwing me for a loop is the don’t do anything for 5 minutes. Thanks


Best way to use a primary light as a notification light?
#2

I made this piston to notify when the garage door is left open. “Contact stays open for” might be what you are looking for.


#3

thanks, I’ll try and see if I can import that and make some adjustments.


#4

grrr… can’t figure out how to import that piston


#5

To import a piston. Click “Add a new piston” then “Restore Piston from backup code” (the orange one). There is text in the window that says it will only work for your own pistons, but I think this is the way to do it. That is how I do it.


#6

thanks!


#7

Some complicated stuff. I was able to get the text message set up haven’t figured out how to get it to flash one of my lights… gonna keep working on it


#8

not sure how to stop the light from flashing… basically I want it to flash indefinitely, until the garage door closes. But not sure how to get that in there. Idea?


#9

can’t get the ligth to stop blinking unless I manually do it. Idea’s? I changed the time to 10 seconds while I test this thing…


#10

Yeah, you want a “While” loop. And because I know the next problem you’ll run into I coded for that as well. I’m guessing you don’t want the light to stay at one of those colors the next time you use it. So I capture the current state of the light and then put it back to how it was. There’s a Wait command at the end which may or may not be needed…depends on how fast your lights get and set the command to restore. Mess around with that and see. Also you can lose the Debug statements once you verify this is working (just delete them).

I’m turning off the light at the end. But you could also capture the state “switch” and it will set that back to how it was too.


#11

Thanks a lot, I’m not at home to play with it at the moment but will be soon… I’ll let you know how it works.


#12

@Mike1616 Thanks so much! That worked like a champ. I wish I had your skills.


#13

Well, after a little more testing, it leaves the light on maybe 40% of the time. Any adjustments that I can make? I’d be fine with turning the light off when the garage door closes, even if the light was previously turned on, that would be fine. This light is mainly just a light to notify people in the house that something is going on.


#14

I tried changing the delay at the end to 3 seconds, but that doesn’t seem to matter. I’ve noticed that while my light is red, if I close the switch, (I took it off the garage door and have it next to me while testing), it almost always will leave the light on. bright white, never red, when complete. If I close the light while it’s white, it usually will turn the light off at the end when I close the switch.


#15

Alright, well this was a bit of a learning experience. After finally being able to reproduce the behavior that you were seeing it became clear to me that the piston was running itself multiple times. This was in large part due to the ridiculously small test time values that we’ve got in it right now (seconds instead of minutes). So every 2 seconds it would fire off again. That’s what was messing with the lights going back correct at the end. So I’ve made some significant changes at the top in order to try and prevent that from happening…and I believe when you plug in your real time values that this will all just work. I did have it working here though with the values that are in place now in this piston. The last condition “previousAge” is basically a time based lockout so that this thing cannot run itself again within a given amount of time. Right now it’s set for 30 seconds, but you’ll probably want to crank that up as well when you fully deploy it just to be safe. It’s a value in milliseconds, so if you want a 10 minute timeout that would be 600000.

Give this one a go, hopefully I’ve got it all sorted now. If not, well, we may have to get some of the minions to come in and assist…but hopefully that won’t be necessary.


#16

Thanks a bunch Mike. I am at work right now, so I’ll give it a whirl when I get home and let you know how it goes. I am sure it will probably work though.

Scott


#17

So the very first time I ran it it left the light on green. I might have closed the switch too soon. I’ve ran it at least 10 times afterwards and it’s worked perfectly every time.

So, I am going to get some sleep, and plug in the real world times in it this afternoon and run it a few more times… I am thinking we are golden. And you’ve some mad skill… at least by my standards :slight_smile:

Thanks for taking the time to help me with this. I am sure I’ll be back with more questions very soon. I’ve got a few more light switches coming in the mail and I am already thinking up different scenarios hehe… This crap is addicting, lol.

Scott


#18

That’s a very true statement, in so many ways…

And many thanks should go to the webCoRE team for putting this rules engine in place. It’s rather powerful.


#19

Thanks, Mike, all seems to be working good.

Can you help me understand your logic. What is the purpose of using OC_sensor vs just choosing a device?
And part two, “previousage” with it now set for 10 minutes or 600000 ms now, does that mean, if I open the garage door, and close it before the 10 minutes are up, then open and leave it open within that same 10 minutes and leave it open for 10 minutes, that it wont run?


#20

I am choosing a device, but just a device variable. The whole purpose being so that you don’t have to modify the expression in this line:

image

Personally I like device variables more than using the device name in pistons anyway. It’s more future-proof. So let’s say you later upgrade this device to one that has more features, but keep the other one. With a device variable you change one line of code versus changing (in this small case) three. That’s just one example.

Yes. So adjust that value to your liking. I was just giving you an example. it does not have to be that long by any means. That was just there to try and avoid the piston rerunning itself while it’s still in the time frame where it’s seeing if the door is still open, which it seems like it wants to do, even though I’m doubling the checks “changes to open” and then “stays open”. One minute should probably be fine (heck 0 minutes should have been fine, but it didn’t seem to work that way).