Arduino ThingShield custom type won't trigger commands on phone?


(Mike Macaulay) #1

Hi,

I’ve got a ThingShield hooked up to a 2 channel relay for my two garage door buttons (one for each door). I’ve made a simple device type, code follows:

metadata {
	// simulator metadata
	simulator {
	}

	// UI tile definitions
	tiles {
		standardTile("switch", "device.switch") {
			state "off", label: 'Button 1', action: "switch.push1", backgroundColor: "#ffffff", icon:"st.doors.garage.garage-open", nextState: "on"
			state "on", label: 'Button 1', action: "switch.push1", backgroundColor: "#53a7c0", icon:"st.doors.garage.garage-open", nextState: "off"
		}
        standardTile("switch2", "device.switch") {
			state "off", label: 'Button 2', action: "switch.push2", backgroundColor: "#ffffff", icon:"st.doors.garage.garage-open", nextState: "on"
			state "on", label: 'Button 2', action: "switch.push2", backgroundColor: "#53a7c0", icon:"st.doors.garage.garage-open",  nextState: "off"
		}

		main "switch"
		details (["switch","switch2"])
        
	}
}

def parse(String description) {
def value = zigbee.parse(description)?.text
	def name = value in ["on","off"] ? "switch" : null
	def result = createEvent(name: name, value: value)
	log.debug "Parse returned ${result?.descriptionText}"
	return result
}

def push1(){
	zigbee.smartShield(text: "toggle1").format()
    sendEvent(name: "Button 1", value:" has been triggered")
	
}
def push2(){
	zigbee.smartShield(text: "toggle2").format()
    sendEvent(name: "Button 1", value:" has been triggered")
	
}

This works perfectly when I debug with the IDE pointing to my actual thingShield. Hitting the buttons toggles the relay on the arduino and things look good. So I went to “My Devices” and changed the type of the device to my newly created type. It shows up on my phone just fine, but when I try to execute any of the actions, nothing happens. No events seem to get triggered. Am I missing something? Any help would be greatly appreciated!

Mike


(Todd Wackford) #2

Did you uninstall at the IDE? Try that and then reinstall or update on the phone or tablet.

Hth


(Mike Macaulay) #3

Yep, made sure I clicked the “uninstall” in the IDE. Still no interaction on the phone. Could there be an installation I’m not aware of? When in the “my device types” menu, the “sessions” column is empty. Any other ideas?


(Todd Wackford) #4

change the “switch.push2” and simular variables to simply just “push1” and “push2” and make sure that you added the “push1” and “push2” to the custom commands on the IDE device type settings. Resave and republish the device.


(Mike Macaulay) #5

Hey @wackware, I did that, still didn’t get it to work. I think I still don’t really understand the options available for device types and how they interact with attributes. Is there a tutorial out there for stuff like this or only examples and the reference documentation?