copyninja
(Jason Mok)
December 24, 2014, 11:50pm
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
smart
(Ron S)
December 25, 2014, 1:26am
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.
copyninja
(Jason Mok)
December 25, 2014, 2:00am
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.
copyninja
(Jason Mok)
December 26, 2014, 5:56pm
5
Found the solution. Instead of “doorControl.open”, it needs to be “door control.open”
smart
(Ron S)
December 26, 2014, 5:57pm
6
Good for you! 20 characs.