Here's another variant of that virtual driver... useful if you're looking to grow your groovy knowledge:
A lot of virtual drivers have been coded over the years that interlock two dissimilar virtual devices. I remember one of the first I wrote was for a Presence + Switch. The driver above takes that concept up 10x.
For real Sensors (Door/Window, Leak, Presence, etc.) you cannot set them. The device itself does the setting.. for example, you have a door sensor and the door is open, You can't click on a button and have that door change to closed. You have to physically walk over and close the door, But for virtual devices, there's no physical to move. Thus a switch is interlocked to the sensor. You change the virtual switch and it changes the virtual Sensor too.