State transitions differences between simulator and Android app


#1

Hi everyone, I wonder if someone can help me understand why very basic state transitions work differently in the Android app than in the simulator.

Here is probably the simplest switch device type:

metadata {
	definition (name: "On/Off Button", namespace: "smartthings", author: "SmartThings") {
		capability "Actuator"
		capability "Switch"
		capability "Sensor"
	}

	simulator {
	}

	tiles {
		standardTile("button", "device.switch", width: 2, height: 2, canChangeIcon: true) {
			state "off", label: 'Off', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff"
			state "on", label: 'On', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#79b821"
		}
		main "button"
		details "button"
	}
}

def parse(String description) {
}

def on() {
	log.debug "on"
}

def off() {
	log.debug "off"
}

Note that there are no state transitions coded (no sendEvent statements, no nextState parameters).

When I run this device type in the simulator, it works the way I would expect: it starts in the Off state, then any click results in the on() function being called, but the state never changes, it remains Off (since there is no event that would trigger a state change)

If I create a device of this type and try the same thing in the Android app, each tap on the tile results in a state change (Off -> On -> Off -> On, etc.) This should not be the case.

Why does it work this way?

I am working on an Arduino-based Zigbee garage door opener and these transitions really make the whole thing ugly. Instead of going Closed -> Opening -> Open, I get weird transitions: Closed -> Open -> Opening -> Open. I believe the cause is the issue I described above.

Thanks!