Sorry, I’m new to development with SmartThings, I’ve not subscribed to events from other devices, or subscribed to anything before )
I added the event handler, as you suggested, but when i turn the virtual switch on, no event is received…
The preferences section of my SmartApp does not contain the virtual switch, as it is created by the SmartApp, so my preferences looks like this:
section("Raspberry Pi Setup"){
input "piIP", "text", "title": "Raspberry Pi IP", multiple: false, required: true
input "piPort", "text", "title": "Raspberry Pi Port", multiple: false, required: true
input "theHub", "hub", title: "On which hub?", multiple: false, required: true
}
Here is the code in my SmartApp which creates the virtual switch, and subscribes to its events:
log.debug "Create a Virtual Pi Relay named $gpioName1"
def d = addChildDevice("ibeech", "Virtual Pi Relay", "relay01", theHub.id, [label:gpioName1, name:gpioName1])
subscribe(ibeech, "switch.on", switchOn)
log.debug "Subscribed to gpio1: " + d;
And here is the callback function:
def switchOn(evt){
log.debug "Switch on event!";
log.debug evt;
}
And the log output:
09:34:04: debug Subscribed to gpio1: Light
09:34:03: debug create a Virtual Pi Relay named Light
I would really appreciate any help