Simple Left open past certain time- But send SMS & Alexa


#1

Hey guys, I’ve got a somewhat simple piston I’m working on, and I’m getting somewhere, I think I’m just having a problem with what to put where (well I guess isn’t that most issues)

1) Give a description of the problem

When garage is open between 8:30pm & 5:30am, send text to phones (I have this working)
every 5 mins
Also have alexa speak every 5 mins that the garage is still open.

Once closed it will text us that it’s closed, then I’d like Alexa to say “Garage is now closed.”

I’m just not sure where to insert the alexa part of it. I have two sep. pistons but would like to learn to combine them into one.

I’m familiar with how to get alexa to speak, just wasn’t sure where I needed to add those lines in the same piston. Thanks for any help.


#2

I think I got this thing figured out. :slight_smile:


#3

Try this at line #25

IF Contact sensor changes to CLOSED
then
Send SMS


#4

So I’m getting somewhere, but not quite there. Ike, haven’t made that change yet, but thought maybe you’d have a thought. So pretty much all day whenever I shut or open the door it says “Thanks it’s shut now.” :slight_smile: I only need it to warn me during those hours and then say thanks when it’s shut, not all day.


#5

Then, just like your first IF block, you can use time frame as a condition

IF Contact sensor changes to CLOSED
AND
IF yime is between X and Y
then
Send SMS or speak text etc

once you get this one working, you can explore EXPRESSIONS and echo can say the exact time.
“Time is 9:38 and the garage door is shut now.”


#6

Thanks, I’ll give this a try today, appreciate your help.


#7

Got it working, thank you!


#8

if you check the box for SOLUTION, it’ll help for people looking for resolved posts…
thanks.


#9

So here’s one for you…

I’m doing some testing with my front door so I don’t have to keep opening/shutting my garage door, but I have the front door open, and had it set for 2:05 and 2:30, and expected it to alert me, but it’s not working. If I shut and reopen it works, but if I leave it open (which is the idea for the garage) Code is below


#10

Notice the only lightning bolt in your left margin is next to Sensor 2’s contact.
This means currently, (contact change) is the only thing that will execute the piston.


#11

Ahhhh…ok, dumb question, how the heck do I get the other lighting bolt.? :slight_smile: I’ll look on the help for now.


#12

Notice how line 33 is a precise moment in time, and line 18 is a vague window?

I would drop the WHILE, and change line 18 to a precise IF:

IF Sensor 2's contact CHANGES TO open
   and Time is between X & Y
      Then do cool stuff
END IF

IF Sensor 2's contact CHANGES TO closed
   and Time is between X & Y
      Then do other things
END IF

Note: If you want a repeat alert, more code would have to be added.


#13

Ok, thank you this is helpful. So, the question I have though is:

If Sensor 2 is already open (meaning the door is open let’s say at 7:30PM and 8:00 PM rolls around and it’s open (time is between 8:00PM & 5:30AM)


#14

If I focus on open doors, and temporarily ignore the repeat… I usually attack this from both angles:

IF Sensor's contact changes to open  <-- Trigger
   and Time is between X & Y         <-- Condition
      Then Send SMS
END IF

Every day at X                       <-- Trigger
   IF Sensor 2 IS open               <-- Condition
      Then Send SMS
   END IF
END EVERY
  • The top block catches new events during that time period…
  • The second block catches an already opened door at that time.

#15

Thank you, this makes sense. It’s funny, there seems to be a few ways to make these things happen. I kind of look at examples of them and try to combine them. :slight_smile: But I’m slowly learning.


#16

In essence, a piston has two parts.

(1) Is what executes the piston (trigger represented by a lightning bolt)
(2) What commands are sent afterwards

Each time a trigger fires, the entire piston runs top to bottom, and executes anything not blocked by conditions.

The exception is the EVERY block I have above. Those blocks are treated like a mini-independent-piston, and will not cross over into the rest of the piston during execution.


#17

Ok, great, thank you! Appreciate your patience and quick responses.


#18

So I rewrote the script, and here’s what I have below. Only question I have is how do I get the alerts to keep coming if it stays open for both the first part of “changes to open” and the second part of currently open? I’d like SMS and Alexa alerts every 5 mins or so.


#19

It’s looking good so far, although my apologies… I don’t usually write loops while “off the clock”. To get you started though, (now that you have solid triggers in place), you can create a new block down below (outside the other two blocks) to cycle thru whatever.

IE: Your current triggers kicks off the piston, and your new block keeps it going.


Note: You will likely need to expand your time window to be successful at this.
Also keep in mind that there is a strict daily limit on SMS messages, and anything beyond the max will be lost forever.