@JohnRob Here's an example I got some help with that really clarified the process for me. I have an Insteon sensor that tucks so nicely behind a toilet, but since there's no Insteon support in HE (yet ), I had to get creative. There isn't (or wasn't at the time) a way for a virtual switch to trigger a leak notification in HSM, so it had to come from a leak sensor.
So how the Insteon part works isn't important here. What the point is, is that a virtual switch turning on triggers a leak detection via custom command and a few lines code.
/**
*/
metadata {
// Automatically generated. Make future change here.
definition (name: "Simulated Water Sensor", namespace: "smartthings/testing", author: "SmartThings") {
capability "Water Sensor"
capability "Sensor"
command "wet"
command "dry"
}
tiles {
standardTile("water", "device.water", width: 2, height: 2) {
state "dry", icon:"st.alarm.water.dry", backgroundColor:"#ffffff", action: "wet"
state "wet", icon:"st.alarm.water.wet", backgroundColor:"#00A0DC", action: "dry"
}
standardTile("wet", "device.water", inactiveLabel: false, decoration: "flat") {
state "default", label:'Wet', action:"wet", icon: "st.alarm.water.wet"
}
standardTile("dry", "device.water", inactiveLabel: false, decoration: "flat") {
state "default", label:'Dry', action:"dry", icon: "st.alarm.water.dry"
}
main "water"
details(["water","wet","dry"])
}
}
def parse(String description) {
def pair = description.split(":")
createEvent(name: pair[0].trim(), value: pair[1].trim())
}
def wet() {
log.trace "wet()"
sendEvent(name: "water", value: "wet")
}
def dry() {
log.trace "dry()"
sendEvent(name: "water", value: "dry")
}