SmartThings Multisensors - how can you set multiple capabilities

Hi all,

I’m trying to code event handlers to detect contact events and changes in temperature using the SmartThings multisensors. My code works for both capabilities separately but doesn’t work for both together as I can only apply the sensor to one capability in the preferences section when coding in the MySmartApps section. Can anyone tell me how to set two capabilities for one device in the preferences section?

I’ve trawled through the forum and all smart apps that I think would help me find a solution to no avail so any help would be gratefully received!

Andrea

which “capability” are you using?

also post the code please

I’m trying to use the capability.temperatureMeasurement and capability.contactSensor for my living_room_sensor_multisensor but I can’t assign two capabilities to the same device name and can’t attach different device names to one device…

Here’s the code I’m using:

preferences {
    section("When the temperature changes...") {
        input "living_room_sensor_multisensor", "capability.temperatureMeasurement"
        
    } 
    section("When the door opens/closes...") {
        input "living_room_sensor_multisensor", "capability.contactSensor"
    }
}

def installed() {
    subscribe(living_room_sensor_multisensor, "temperature", livingRoomTemperatureHandler)
    subscribe(living_room_sensor_multisensor, "contact", livingRoomContactHandler)
}

def updated() {
    unsubscribe()
    subscribe(living_room_sensor_multisensor, "temperature", livingRoomTemperatureHandler)
    subscribe(living_room_sensor_multisensor, "contact", livingRoomContactHandler)
}

def livingRoomTemperatureHandler(evt){
    log.debug "$evt.doubleValue"  
    log.debug sensor_name 
}


def livingRoomContactHandler(evt){
    log.debug "$evt.value"  
    log.debug sensor_name 
}

You just need to use different variable names for the two (lists of) sensors…

preferences {
    section("When the temperature changes...") {
        input "temperatureSensor", "capability.temperatureMeasurement"

} 
        section("When the door opens/closes...") {
            input "contactSensor", "capability.contactSensor"
        }
    }
    
    def installed() {
        subscribe(temperatureSensor, "temperature", livingRoomTemperatureHandler)
        subscribe(contactSensor, "contact", livingRoomContactHandler)
    }
2 Likes

What he said.


2 Likes

That’s working perfectly - thank you so much!

1 Like

Old topic I know, but according to this I could hypothetically use the accelerometer AND the contact capabilities of the ST multisensor simultaneously?

Note: my multisensor is from 2016