Need help with this piston (my first)


#1

1) Give a description of the problem
I want to create three pistons to monitor and control my garage door opener

2) What is the expected behavior?
First piston: Any time, send a text notifying me when the door is opened or closed. Include a time stamp in the text message.
Second piston: Between 10pm and 6am, if the door is left open for 10 minutes, close it.
Third piston: Between 6am and 10pm, if mode is AWAY and door if left open for 10 minutes, close it.

3) What is happening/not happening?
Nothing - I don’t know how to make these pistons!

4) Post a Green Snapshot of the pistonimage
(UPLOAD YOUR IMAGE HERE)

5) Attach any logs (From ST IDE and by turning logging level to Full)
(PASTE YOUR LOGS HERE BETWEEN THE MARKS THEN HIGHLIGHT ALL OF THE LOGS SND CLICK ON THE </> ICON TO FORMAT THEM)

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

This should do everything you want in a single piston:

Select ‘+ New Piston’ and then choose ‘Restore a piston using a backup code’

Enter the code shown above (hc3z2)

Follow the wizard to select your garage door device and phone number


#3

OK that’s cool. A couple of questions if I may …

  1. What happens when you store something in Messages? Where does this show up?
  2. I actually got the notifications working on my own, with code that looks exactly like your two “if” statements #3 and #5, without wrapping them in the “on events from” and “do” clauses. What does “on events from” do, and why is it necessary? Why is the “do” clause necessary?
  3. I have some background in programming and I do digital design. I feel like I should be able to learn this, but learning by experimentation is going to be painful and inefficient. Is there an LRM out there for all of this? How would you recommend going about learning how to do this stuff?

Thanks in advance!

Joe


#4

Just means it gets listed in ‘messages’ section in the ST app (hamburger menu > Notifications > Messages)

On events isolates the two IF statements from the rest of the piston below (the stays open for 10 minutes part). On every piston run, whatever the trigger, the whole piston is evaluated. Without using ‘on events’ in this example, you would get a second ‘door is open’ message after the door stays open for 10 minutes, followed immediately by a door is closed message as the last part of the piston fires. On-events act as a completely separate piston and will only fire on that event.

If you just had the two IF’s on their own in a separate piston, without the stays open block below, then you wouldn’t need the ‘on events’.

The DO part is auto generated when choosing ‘on events’.

trial and error+ lots of forum posts.

and you could always browse the wiki https://wiki.webcore.co


#5

Cool, thanks. The messages thing makes sense … meant to check that in the app but promptly forgot. :smiley:

The events thing kind of hints at how all this is works under the hood. Can you confirm if I’m interpreting this correctly?

Since the piston is called on every trigger, it is called three times: once when the door opens, again when the timer expires, and a third time when the door closes. Without the 'on events" clause, this would result in two “door opened” notifications and a “door closed” notification. Instead, when the timer expires, since there hasn’t been a Garage Door event, you don’t get a second “door opened” notification. I assume you will still get a “door closed” notification on the automatic close, since that does generate a Garage Door event, right?

How do you get the “on events” code? I can’t see how that is generated from any of the options when I select “add a new statement”?

Thanks again!


#6

Also, when it says “memory used”, what memory is it referring to? It says the piston you shared uses 6% of memory … is that cumulative for all pistons, so I could only have 16 pistons like this?


#7

Yep.

When editing a piston, click settings (might be options lol) and tick show advanced statements.

Then when you add a new statement you get the full list of options.


#8

That’s per piston… memory consists of the piston code itself and any logs it stores when running. Older logs are automatically cleared to maintain memory below a threshold, so the bigger the piston the less logs it will store.

You don’t need to pay any attention to memory usage… it just works.


#9

Hey Robin thanks for your help and patience … I really appreciate it! Hope you don’t mind another question. I’m playing w/my options here on the best way to control the door, another thought I had for a piston is one that will send a message periodically when the door is open. I made a piston for this that says, if the door stays open for x minutes, send an SMS. Thing is, it sends a message after the door is open for x minutes, and then no more messages. I’d like it to send a message every x minutes. What am I missing here?


#10

Hey, nevermind, I think I figured it out. A while loops seems to have done the trick.


#11

Yep, loop is the way to go.

If you add {age([device name : door])} to the message text it will tell you how long the door has been in it’s current state.


#12

Thanks for that … I actually put a counter in so I could track the number of times I looped and convert that to time for the message (1 hour/loop).

Since you posted back … I was thinking it would be awesome to make my Echo’s announce that the door is still open, looks like Amazon added this for some devices but I don’t have the option to make a routine for the garage door. Any idea why?


#13

BTW don’t laugh but I’m conflicted on the best way to manage the door … I love having it close automatically but it seems like this will eventually cause a problem when it closes on an open car hatch or something. Hence I made a piston that just pings me hourly as long as it’s open. Yes, I’m probably overthinking this. But I’d be interested to hear other peoples thoughts on automating a garage door - good idea or bad idea?


#14

Alexa’s latest improvement only works with Contact Sensors or Motion Sensors. You can likely work around this by creating a SIMULATED Contact Sensor, and programming webCoRE to toggle THAT SimSensor when the Garage door does whatever. Then tell Alexa to announce a canned response when the SimSensor changes. It is kind of clunky and quite limiting, but possible… As long as you are OK with your announcement being the exact same phrase each and every time.


#15

Cool, thanks for the direction, something to play with tonight!


#16

Have 5 simulated contact sensors, each with a different phrase, and have webCoRE pick one at random each time lol

Looking forward to this feature coming to the UK… hopefully wont be too much longer!!


#17

Ahh yes, good point. Creating multiple Simulated Sensors can bypass this limitation


#18

OK one last question … maybe. :smiley: I think I’ve settled on how I want to manage the door. My new piston sends me a text whenever the door is opened or closed; it also turns the bottom LED on my HomeSeer 200+ switches red when the door is opened, and clears it to the normal state when they are closed. I like this as a subtle reminder that the door is opened and I need to close it. I also set the piston up to send a reminder every hour that the door stays open.

I’d like to add one thing to this - if the door is open after 10pm, rather than just lighting up the LED on the switched, I’d like to make it flash as a more insistent reminder to close it. So, I need an addition to the piston that will change the LED to flashing mode at 10pm if it’s already on, or just set it to flashing mode if the door is opened after 10pm. I’m not worried about returning it to steady mode at any time - if it’s still open in the morning I definitely want it to flash at me so I know to go and close it!

So, suggestions on how to code this up?


#19

Do the HomeSeer switches have a flashing mode built in or are you looking to emulate flashing via webcore?


#20

Sorry, should have included that detail. Piston is below. The command is

setStatusLed(x,y,z)

where x is the LED number (1-7), y is the color (0-7, 1 is red), and z is blink/solid (1,0)