Hi, do we have access to the existing default Virtual Device drivers? I have a virtual presence sensor that tracks my presence as arrived or departed, etc. My presence solution however generates more data, such as if I arrive at work, or depart my family's house. I could make global variables and workarounds like that, but I think I'd rather experiment with the virtual presence sensor itself to give it more commands/statuses than arrived and departed, but I don't think I have access to the starting point?
We don't have access to the built in code, but here is an example of a driver you can work with. I ripped this from my other code but should work fine. You can build from there.
metadata {
definition (name: "Virtual Presence/Switch", namespace: "GvnCampbell", author: "Gavin Campbell") {
capability "PresenceSensor"
capability "Switch"
command "arrived"
command "departed"
}
}
def setPresent() {
sendEvent(name: "presence", value: "present")
sendEvent(name: "switch", value: "on")
}
def setNotPresent() {
sendEvent(name: "presence", value: "not present")
sendEvent(name: "switch", value: "off")
}
def arrived() {
setPresent()
}
def departed() {
setNotPresent()
}
def on() {
setPresent()
}
def off() {
setNotPresent()
}
5 Likes