I was wondering if someone could help me with the following logic? I don’t know for certain that PLEG is the right choice for what I am trying to accomplish, but as a long time reader of this forum, I know there’s not much it can’t accomplish and most answers to semi-complex questions are “use PLEG”…
I have a basement stairway door that I want to monitor with a door sensor and announce, repeatedly until it is closed, that the door is open. My reason for wanting this is that my 4 yr old often runs down to play leaving the door open for my 1 yr old to find and decide he wants to play too and then tumble down the stairs. (Yes we have gates and have diligently child-proofed the house but there are multiple ways to get to the basement stairway and my older one does need a bit of “freedom”)
I have a few Sonos Play 1s around the house and was thinking if the door was left open for more than 20 seconds, I could somehow use the Sonos plug-in to repeatedly fire off a Sonos ‘Say Text’ message “The basement door is open” until I close the door and the sensor is de-activated.
I’ve read through lots of PLEG posts and through the excellent PLEG guide a couple times. In my non-programmer mind, I think the ‘Simple Alarm Using a State Variable’ is very close to what I want to do, but I want to make the Say Text part repeat. I can’t grasp whether that needs additional Lua logic like a counter or while loop or if some sort of PLEG re-trigger after 5 seconds or so would work. I see other examples where a condition keeps a light on (or rather does not turn it off), but the part I don’t understand how to do is making the TTS repeat.
A state variable is way to complex for your simple need.
You need an input trigger: GateOpen When the gate indicates it’s open
You need an input timer: AnnouceTimer On Type - Retrigger, OFF Type - Interval 5:00 minutes
In this case I assumed 5:00 minutes as the interval between alerts.
You Need a condition; InitialGateOpen GateOpen AnnountTimeout GateOpen and (GateOpen; !AnnouceTimer)
Actions: InitialGateOpen
StartTimer AnnounceTimer
Optionally Say - Gate Was just opened, AnnountTimeout
StartTimer AnnounceTimer
Say Gate is still opened.
[hr]
You can have different times for the initial alert and the repeated alerts … just specify the appropriate time on the StartTimer commands for the two conditions. If not specified … it used the default interval defined by the timer.
Thanks much for the quick reply. I was wondering whether you or Rex would answer first!
I’m trying to understand the conditions a bit more…
You Need a condition;
InitialGateOpen GateOpen I understand this
AnnountTimeout GateOpen and (GateOpen; !AnnouceTimer) is this, in English, saying the gate is open and the gate is (was) open(ed) before the timer expired? Or, before the timer even existed?
Also, I think an initial announcement and a repeat set at the same time are fine, but to try to understand PLEG more (and use it more) are you saying I would create two input timers and then call those in the appropriate action
Again, many thanks for your help…I have another simple PLEG setup (Garage Door AutoClose) but have been hesitant to do more with it because of the intimidation factor. Rex’s guide and your assistance may just get me over the hump!
Sequence expressions are one of the most powerful aspects of PLEG … It allows you put requirements on the order that things happen.
In the case:
GateOpen and (GateOpen; !AnnouceTimer)
Two things have to be true for this to happen.
(1) The Gate has to be open
(2) The Announce Timer (5 minute timer) must turn OFF after the Gate is Open
I was able to get this setup and working - with your help of course. Thank you!
I do have one more question, that I may have not communicated very clearly initially. I am wondering if there is a way to make this announcement repeat over and over until I close the door?
I setup the timer for 20 seconds and when the door is opened I get an immediate ‘Say’ announcement that the door is now open. 20 seconds later, it says “the door is still open”. I was expecting it to repeat that again in another 20 seconds…basically annoying me into closing the door. Is this possible? I assumed that is was the self re-trigger option did, but I have confirmed I set that
Sorry to be a pest…I just cannot seem to get this to work the way I want. I have completely deleted the PLEG instance for this and rebooted my VeraLite and started over. I’m at a point where the following occurs
I open the door and hear the initial announcement
I then hear the “still open” announcement. it seems to be a bit longer than my timer setting of 20 seconds, but not much and could be Sonos TTS related
I then hear the “still open” announcement repeated immediately over and over forever
Closing the door does NOT stop the announcement. The only way I could stop it was to reboot my Vera.
I’ve attached screenshots of my entire PLEG setup, hoping you can see if I’ve made some sort of rookie mistake.
continuation of my previous reply… my previous post would only let me attach 4 screenshots. Attached are the remaining two
P.S. - You should use your registration site to implement a virtual tip jar so people who wish to do so can tip you for your assistance. Since that isn’t available, I bought two PLEG licenses. I don’t know if I will ever need 8 PLEG instances going at once, but I do appreciate your time and help so please consider that as payment for those.
You do not need all of those windows …
You only need/and should post the output of the Status command.
The status command shows all of the above info + the timestamps that shows how your logic is working.
Ok…I will post that tonight. Is the proper sequence to trigger it by opening the door and that it go through at least one or two cycles of the unstoppable repeated ‘Say’?
Is there another way to cancel it besides rebooting? Closing the door does not shut her (the google woman) up!
Attached are two screenshots of the status screen. i have left them labeled as the screenshot time. I opened the door as soon as I saw the Vera time go to 17:56. I then waited about 15-20 seconds and took a screenshot. Then I waited until 17:57 and closed the door and took another screen shot.
The “door is still open” message repeats every 5 seconds…as soon as it can say the phrase again. And it does NOT stop when I close the door. A Vera reboot is the only thing that kills it
The problem is probably with the Sonos Say command.
The PLEG will only trigger every 20 seconds …
And now that the door is closed … it will not trigger again…
You can verify this:
Close the Gate
Open the PLEG Actions Tab.
For the AnnounceTimeOut … click the Do It Now
This will cause it send the Say Command. It will also restart the timer … but that does not matter because the Gate is closed.
If it keeps repeating … then it’s a Sonos Plugin issue.
so, can i “hack” this by doing AnnounceTimer1, AnnounceTimer2, and AnnounceTimer3 with 20, 40 and 60 sec. intervals, respectively without the repeat set and have my two actions call those timers? That will give me an initial door open announcement and 3 more over the course of a minute, right?