Specifically, I want to create an arduino-based Thing that can access and trigger events on other devices, much like the mobile apps.
You would probably need to create a SmartApp middleman. A SmartApp is (currently) the only way to get access to what is happening on other devices.
Thank you. I just found their SmartApp example for toggling a switch with an http call, and that appears to show how it might be done.
Can I access a smartApp directly from device code? That is, can I write something in a device handler that accesses a smartApp?
@ultralame Wow, I just opened a thread about this exact same thing. I’ve gotten the app to work pretty smoothly it’s just not the most efficient way (some times there are delays).
I did it by subscribing to the attribute from Arduino. From there I triggered an event within the app calling a command on a secondary device (in my case fake devices).
def initialize() {
// TODO: subscribe to attributes, devices, locations, etc.
subscribe(shield, "hallMotion", hallMotion)
}
def hallMotion(evt) {
//log.debug "${shield.label ?: shield.name} has motion"
//log.debug shield.latestValue("hallMotion")
//log.debug zone4.latestValue("motionSensor")
if (evt.value == "Active") {
//log.info "Motion Active"
zone4.Active()
}
else if (evt.value == "inActive") {
//log.info "delay ${motionDelay}"
zone4.semiActive()
runIn ( motionDelay, motionInActive, [overwrite: true]) // Schedule to lock the door
}
}