@SmartHomePrimer Thanks a lot for the quick reply, I appreciate that.
I changed it as suggested but it turns itself off instantly though? It needed it to stay on it if I turn its switch on.
metadata {
definition (name: "Virtual motion with Switch", namespace: "cw", author: "cwwilson08") {
capability "Sensor"
capability "Motion Sensor"
capability "Switch"
}
}
def on() {
sendEvent(name: "motion", value: "active")
sendEvent(name: "switch", value: "on")
runIn(0, off)
}
def off() {
sendEvent(name: "motion", value: "inactive")
sendEvent(name: "switch", value: "off")
}
def installed() {
}