Problem with multi-sensor


(Jeff May) #1

I have a multi-sensor that is connected to my system. When I vibrate it, I see the results in both SmartThings app and in my developer account (for acceleration).

I am trying to handle the acceleration event in a SmartApp but it doesn’t respond / see the event. I also cannot get it to see the event when I use a virtual device. This should be basic stuff, I can handle events from all my other devices.


#2

Which model? (Aeotec, Fibaro, SmartThings, ?) And which device handler?


(Tim Slagle) #3

what are you subscribing too? Can you show me that line in the code?


(Jeff May) #4

It is the SmartThings multi-sensor
Whatever handler ST defaults to.
Below is a snippet of my code. I use this same code in 3 different locations for several different devices.

preferences {
section(“Devices”) {
input “Toilet1”, “capability.waterSensor”, title:"Where ?"
input “MasterBedroomMotion”, “capability.motionSensor”, title:"Where ?"
input “MedicationBox”, “capability.accelerationSensor”, title:“Where ?”
}

}

def installed() {
log.debug “Installed with settings: ${settings}”

initialize()

}

def updated() {
log.debug “Updated with settings: ${settings}”

unsubscribe()
initialize()

}

def initialize() {
subscribe(Toilet1,“water”,dataChangeHandler)
subscribe(MasterBedroomMotion,“motion”,dataChangeHandler)
subscribe(MedicationBox,“active”,dataChangeHandler)
}

def dataChangeHandler(evt){
log.debug “$location: $evt.date - $evt.id : $evt.displayName - $evt.stringValue”
}


(Eric R) #5

This should be subscribe(MedicationBox, "acceleration.active", dataChangeHandler) if you want to subscribe to active acceleration.


(Tim Slagle) #6

yep :smile:

Your options are

(MedicationBox, “acceleration.active”, dataChangeHandler) = subscribes to only an “active” accel. event
(MedicationBox, “acceleration.inactive”, dataChangeHandler) = subscribes to only an “inactive” accel. event
(MedicationBox, “acceleration”, dataChangeHandler) = .subscribes to all accel. events.


(Jeff May) #7

Works with simulation and I assume it will work with actual sensor (will verify tonight). Thanks a LOT for your help. I really appreciate it.