Hi all,
I have started to make a smart app to interface many devices with an API server. I must admit im finding the whole ST IDE a bit tricky.
Im starting small and hoping to build up but im getting stuck at the most basic level.
My code is take of the examples for a switch and looks like
preferences {
section {
input "theSwitch", "capability.switch"
}
}
def install() {
subscribe(theSwitch, "switch.on", switchOnHandler)
}
def switchOnHandler(evt) {
log.debug "switch turned on!"
}
my issue is that the log does not show “switch turned on!”. I then thought it may be the simulator as when I turn the virtual switch on the actual image does not change. So i changed my code to:
preferences {
section {
input "theSwitch", "capability.switch"
}
section {
input "otherSwitch", "capability.switch"
}
}
def installed() {
log.debug "Installed with settings: ${settings}"
subscribe(theSwitch, "switch.on", switchOnHandler)
initialize()
}
def updated() {
log.debug "Updated with settings: ${settings}"
unsubscribe()
subscribe(theSwitch, "switch.on", switchOnHandler)
initialize()
}
def initialize() {
// TODO: subscribe to attributes, devices, locations, etc.
}
// TODO: implement event handlers
def switchOnHandler(evt) {
log.debug "switch turned on!"
otherSwitch.on()
}
The goal of this test is to have a switch (theSwitch) turn on another switch (otherSwitch). This time I installed this on my app but again nothing is happening. What am I missing?