I am wanting to make a virtual device which would be a virtual contact sensor (but could be a switch, or anything else).
Ideally this device would show as "Closed" when all of the contact sensors of my choice (exterior sensors) are closed, and door is locked. And would show as "Open" when any sensor is open or the door is unlocked.
I want this so I can add it to my dashboard and get a quick 1 tile view of "Is my home closed and secure".
And I know I could use HSM for this purpose but with a roommate I cannot really use HSM as we work different schedules.
What would be the easiest way to set up this virtual device. When I look in Rule Machine I see the "Set closed when all" but I cannot seem to get the "set open when any" part to work.
I have that exact rule set up, but for smoke and CO detectors. The dashboard tile reacts if any are triggered but only clears when all sensors report clear. Here's a screenshot of the rule which uses "changed" status as the triggers & conditional IF, THEN, ELSE for the actions...
Try using a "hybrid" device that is a combo of a virtual switch plus the virtual device you want... contact in this case.
Drivers of this style have logic to interconnect the two "sides"... so the switch going on/off also causes the contact to show open/closed, and vis versa.
I noticed that a "universal" driver was released recently that includes many attributes. Many of us have created similar one-off versions and I have one that is a hybrid of a switch and a presence sensor:
I do precisely that with three rules, though I use a virtual lock rather than a contact sensor. I have a virtual lock called "house" that has two functions. (1) if all outside doors are locked, it shows as locked. (2) if it shows as unlocked and you lock it from the dashboard it will lock all outside doors as long as they are lockable. One of my doors has a sensor that tells when the door is locked but because of the construction of the door and the lock I cannot lock it programmatically. I use a couple of RM global variables to keep various rules updated on the status of things, and to prevent endless loops of rules that trigger themselves and each other. I expose the virtual house lock to Echo so you can ask "Alexa, is the house locked?" or say "Alexa, lock the house."
Here are the three rules. The first updates the virtual lock "house" based on the status of the physical locks.
The second triggers an action called "lock all doors" if the house lock is locked, but also has to check to make sure the house lock was not locked programmatically otherwise you get in an endless loop of cycling locks:
And the third locks the doors that can be locked, and makes sure they do lock. It also checks to make sure they are closed Oh yeah and it notifies me via Echo and Twilio. (Echo Speaks courtesy of Anthony Santilli.)
You'll notice I also use the very handy "reliable door lock" app by Joel Wetzel. @jwetzel1492
I also have it all working with Life360 and a virtual presence sensor (all parties must agree to geofencing), and my alarm system (which is not integrated with HSM, but I fake it). The virtual presence sensor life360 integration are both from @bptworld.