I'm not sure where to find documentation (or even just a forum post is fine!) of all the possible device types, and methods for those devices. See the error when I figured I would try to set the virtual contact state above.
Here you go! Devices are defined by their "Capabilities". Capabilities include the Commands and Attributes a device must implement if it chooses to use that capability.
Virtual Devices are special, as they need an alternate method of receiving commands versus the typical 'parse()' command.
So, a Virtual Contact Sensor has two additional (somewhat non-standard) commands added to it. These would be typically 'open()' and 'close()' (or maybe 'closed()'). You can see these commands exposed as buttons on the Device Details page for that virtual contact sensor.
But it is a little weird, because a virtual Presence device has "arrived()" and "departed()", whereas the status values for the presence attribute are 'present' and 'not present'
This issue really only impact Virtual 'Sensor' devices. These devices usually have no commands associated with them, as they receive updates via parse() from physical devices. Whereas a virtual 'Switch' just uses its 'on()' and 'off()' commands to update its own status via sendEvent().
Here is the start of my hack at the example. So far it's not working to set the virtual contact sensor to open if I add a few other contact sensors that are open. Something must be wrong with 'areAnyOpen()'
Add some log.debug statements to see what is going on in the Live Logs. That usually helps pinpoint the issue.
Usually, I would use the "evt" data returned in the 'handler' to determine whether or not to update the child. I see what you're doing, though... and it seems like it should still work...
Some of this is just how Groovy/Java works. I am definitely not an expert. The SmartThings Classic Documentation is a decent reference guide. Hubitat based much of their design on the ST Groovy model. This makes porting code easier.
EXCELLENT! Thank you so much @ogiewon!!! I hope to soon have my first true app, I've forked the hubitat public, so I can push it back once I have it working. I think it will be a good example to show notifications, and some other stuff.
Ok, I started my own little area for my apps for now. I will put them in the community when they're fully functional/baked.
But at least for now I have this door checker working pretty well. It has a stubbed out timer and notification. I need a way to "snooze" or cancel the repeat other than the doors all being closed as well.
Looks like the official notification app recently added this repeating as well, but for whatever reason my version of that official app seems old/stale/broken?