Device Type Change State If Multiple Conditions are True


(Tom Hoskinson) #1

Hi All,

I’ve been playing with a quirky tripper to see if I can use it for a hardwired smoke/co system with SM120C and C0120C. I’m currently only working with the tripper device but I’ve run into a stag on a change state of Alarm to clear when both Smoke & Carbon Monoxide are clear. I’ve re-coded the tamper sensor to smoke and the contact sensor to co. Everything appears to be working as expected minus the change state if both are clear. I’ve thought about a boelean varr for each state but wondering if there is a more elegant way to get the job done.

if (status & 0b00000001) {
	results << createEvent(getCarbonMonoxideResult('clear'))
    results << createEvent(getAlarmResult('clear'))
}
else if (~status & 0b00000001) {
	results << createEvent(getCarbonMonoxideResult('alarm'))
    results << createEvent(getAlarmResult('alarm'))
}

if (status & 0b00000100) {
	results << createEvent(getSmokeResult('clear'))
	results << createEvent(getAlarmResult('clear'))   
}
else if (~status & 0b00000100) {
	results << createEvent(getSmokeResult('alarm'))
	results << createEvent(getAlarmResult('alarm'))
}

Any help would be grateful.

Thanks.


(Tim Slagle) #2

What are the actual events names that come from the tripper when it is actuated?


(Tom Hoskinson) #3
tiles {
	standardTile("carbon-monoxide", "device.carbon-monoxide") {
		state("clear", label:'CLEAR', icon:"st.alarm.carbon-monoxide.clear")
		state("alarm", label:'CO', icon:"st.alarm.carbon-monoxide.carbon-monoxide", backgroundColor:"#ffa81e")
	}
    
	valueTile("battery", "device.battery", decoration: "flat") {
		state "battery", label:'${currentValue}% battery', unit:""
	}
    
	standardTile("smoke", "device.smoke") {
		state("clear", label:'CLEAR', icon:"st.alarm.smoke.clear")
		state("alarm", label:'SMOKE', icon:"st.alarm.smoke.smoke", backgroundColor:"#ffa81e")
	}
    
    standardTile("alarm", "device.alarm") {
    	state("clear", label:'CLEAR', icon:"st.alarm.smoke.clear")
        state("alarm", label:'ALARM', icon:"st.alarm.smoke.smoke", backgroundColor:"#ffa81e")
    }
    
	main ("alarm")
	details(["alarm","carbon-monoxide","battery","smoke"])
}

(Tom Hoskinson) #4

After looking at the debug it looks to be ‘value’ for both smoke and carbon-monoxide.


(Tim Slagle) #5

Hmmmm yeah thats not gonna help. This may not work the way you want it to. Can you debug the evt wrapper for its value?

log.debug "$evt.value"

(Tom Hoskinson) #6

Parse returned [[name:carbon-monoxide, value:clear, descriptionText:Kidde Smoke/Carbon Monoxide was cleared, isStateChange:true, displayed:true, linkText:Kidde Smoke/Carbon Monoxide], [name:alarm, value:clear, descriptionText:Kidde Smoke/Carbon Monoxide was cleared, isStateChange:true, displayed:true, linkText:Kidde Smoke/Carbon Monoxide], [name:smoke, value:alarm, descriptionText:Kidde Smoke/Carbon Monoxide was smoke detected, isStateChange:false, displayed:false, linkText:Kidde Smoke/Carbon Monoxide], [name:alarm, value:alarm, descriptionText:Kidde Smoke/Carbon Monoxide was alarmed, isStateChange:false, displayed:false, linkText:Kidde Smoke/Carbon Monoxide]]

I’m hoping my issue is basically syntax related because my coding is rusty and groovy is new to me. In the scenario above, I flipped the switch to cause “carbon-monoxide” to go “clear” but would like “alarm” to hold in “alarm” until “smoke” also goes clear. Is below possible?

carbon-monoxide goes clear
check if smoke is currently set to clear then set alarm to clear

smoke goes clear
check if carbon-monoxide is currently set to clear then set alarm to clear