Trying to write a rule a check door & window contact sensors and report status (Either "all closed" or identify which are open). The rule is triggered thru Alexa by a virtual lock.
2 things that I'm struggling with:
*For some reason, when a contact sensor is left open, I'm not getting a message telling me so.
*I would like to add a wait command if any are found open, (to pause the rule until the door(s) or window(s) are closed). ...then once the contact sensors are all closed, report "All closed" and proceed with the rule.
I've been mining for answers thru the documentation and this forum and I can't seem to get it.
Could someone please help...
Unfortunately, you can't speak which contacts aren't closed using %device%.
I also think you might need 2 rules:
Rule 1 checks the contacts and reports any ope and if they are enables rule 2
Rule 2 watches your contacts and speaks when all are closed after being enabled.
Rule 1:
trigger:
Whatever you want to trigger off of
2 variables:
OpenContacts string
Open contactscount number
I pretty much replicated the example provided. I tested it with a door open and it identified it. I then closed the door and it reported everything as closed.
However, when ran again, it seems to be caught in a loop, still announcing the back door is open, when in fact, it is closed.
Rule Test-1 and a snapshot of the included variable:
...and the loop grows. Now it repeats itself 5 times. I guess it adding to the variable.
I just wanted to have a "Good Night" rule that would check everything before setting the HSM. That way, I could easily correct any open contacts. It seems when catching an open contact in HSM, I have to cancel HSM, correct the contact, them arm again. A little bit of a pain that I was hoping to avoid.
Napalmcsr provided a great example that seems perfect for me. However, I probably just don't have something configured right with the variables or private boolean.
When I set the PB for Rule 2. it asked what rules it applied to. I selected rule 2 (the one that the PB was created in).
The Open "Contactcount" was set to "0" initially but changed to "1" when caught in the loop.
...and the "OpenContacts" string filed was left blank initially. It too changes when it is ran.
It seems like the both variables should be reset to their original value ("0" and empty). along with the PB. It's value has changed too.
I reset the variables in Rule 1 and will try to figure out how to reset the PB in Rule 2. It seems to be stuck in "False" and I guess should be "True" ??
Once again- Thank you for taking the time. I have to call "UNCLE"... After spending hours, I just can't make it work. I'm sure its my lack of understanding.
However, I did come up with a work around that works for me. I'll merge it into my "Good Night" routine and it will help flag open contacts before shutting down the house and arming HSM.