Can a device handler subscribe to events from another device?


(Eric) #1

I’ve tried the following and it doesn’t work. My guess is that I cannot do this. Basically I have a fan device type that I also want to display the room temperature on the detailed view of the device. I get the room temperature from a contact sensor.

In a device type, can I add an input

input "theSensor", "capability.temeperatureSensor", required: false

and then subscribe to it’s events

initialized() {
subscribe(temperatureSensors, "temperature", temperatureHandler)
}

and then do something with the device handler based on it’s events?

def temperatureHandler(evt) {
//Do something!!!
}


(www.rboyapps.com - Make your home your butler!) #2

No, DH’s cannot talk to other DH’s. One way to do it is to use an intermediary SmartApp and custom event attributes.

The SmartApp can subscribe to both Devices. Read the temp from the contact sensor (??) and then use sendEvent to post the temp to the Fan device which can then read it the attribute and display it.


(Eric) #3

Thanks, that is what I will do.


(Kevin) #4

How do you refer to specific devices in SmartApp?


(www.rboyapps.com - Make your home your butler!) #5

You can pick a category based on capability and then select the device you want.