Door Control Capability Command


(Jason Mok) #1

I’m trying to leverage door control capability in my new device type. according to the [documentation][1], there’s the predefined open() and close() method.

IDE emulation works fine, but when I try to run it on my iPhone, it gives “Error: Connection Failed”. Here’s my code:

    metadata {
	definition (name: "Test Door 1", namespace: "copy-ninja", author: "Jason Mok") {
		capability "Door Control"    
	}

	simulator { }

	tiles {
		standardTile("door", "device.door", width: 2, height: 2, canChangeIcon: false) {
			state("closed", label: "closed",  action: "doorControl.open",  icon: "st.doors.garage.garage-closed",  backgroundColor: "#ffffff")
			state("open", label: "open",    action: "doorControl.close", icon: "st.doors.garage.garage-open",    backgroundColor: "#57BF17")			
		}

		main "door"
		details(["door"])
	}
}
def parse(String description) {}

def open()  { 
	log.info "open clicked.." 
    sendEvent(name: "door", value: "open", display: true, descriptionText: device.displayName + " was open")
}
def close() { 
	log.info "closed clicked.." 
	sendEvent(name: "door", value: "closed", display: true, descriptionText: device.displayName + " was closed")
}

Any ideas?
[1]: https://graph.api.smartthings.com/ide/doc/capabilities


Issue with single precision not converting (analog output / present value)
(Ron S) #2

Hey, the connection failed may not be a related issue as I get that pretty often… As it was explained to me it is when somehow your connectivity to ST servers is interrupted for some reason (???). It’s not related to your code.


(Jason Mok) #3

the problem is if I define custom command, it’ll work. This code works:

metadata {
	definition (name: "Test Door 2", namespace: "copy-ninja", author: "Jason Mok") {
		capability "Door Control"    
	    
        command "open"
        command "close"
	}

	simulator { }

	tiles {
		standardTile("door", "device.door", width: 2, height: 2, canChangeIcon: false) {
			state("closed", label: "closed",  action: "open",  icon: "st.doors.garage.garage-closed",  backgroundColor: "#ffffff")
			state("open",   label: "open",    action: "close", icon: "st.doors.garage.garage-open",    backgroundColor: "#57BF17")
		}

		main "door"
		details(["door"])
	}
}

def parse(String description) {}

def open()  { 
	log.info "open clicked.." 
    sendEvent(name: "door", value: "open", display: true, descriptionText: device.displayName + " was open")
}
def close() { 
	log.info "closed clicked.." 
	sendEvent(name: "door", value: "closed", display: true, descriptionText: device.displayName + " was closed")
}

I’m just scratching my head over the sketchy documentation.


(Ron S) #4

Right now:


(Jason Mok) #5

Found the solution. Instead of “doorControl.open”, it needs to be “door control.open”


(Ron S) #6

Good for you! :slight_smile: 20 characs.