I spent the evening hacking my relay to work this evening and found that there wasn’t a suitable device type which would work as a momentary switch for my garage door.
Here’s what I came up with in the hour of tinkering (I’m having to ration the time I spend tweaking my SmartThings as of late hah). This is pretty much a straight ripoff of the “Z-Wave Relay” device type but it triggers the “On” for only 30 seconds which is about how long my garage takes to open or close, keeping it on isn’t entirely necessary but it prevents someone else from hitting the button to stop it while its moving.
metadata {
definition (name: "Z-Wave Relay (momentary)", namespace: "LeBlaaanc", author: "Chris LeBlanc") {
capability "Actuator"
capability "Switch"
capability "Polling"
capability "Refresh"
capability "Sensor"
capability "Relay Switch"
fingerprint deviceId: "0x1001", inClusters: "0x20,0x25,0x27,0x72,0x86,0x70,0x85"
fingerprint deviceId: "0x1003", inClusters: "0x25,0x2B,0x2C,0x27,0x75,0x73,0x70,0x86,0x72"
}
// simulator metadata
simulator {
status "on": "command: 2003, payload: FF"
status "off": "command: 2003, payload: 00"
// reply messages
reply "2001FF,delay 100,2502": "command: 2503, payload: FF"
reply "200100,delay 100,2502": "command: 2503, payload: 00"
}
// tile definitions
tiles {
standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true) {
state "off", label: 'Toggle', action: "switch.on", icon: "st.doors.garage.garage-closed", backgroundColor: "#ffffff"
state "on", label: 'Moving', action: "switch.off", icon: "st.doors.garage.garage-closed", backgroundColor: "#79b821"
}
standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat") {
state "default", label:'', action:"refresh.refresh", icon:"st.secondary.refresh"
}
main "switch"
details(["switch","refresh"])
}
}
def installed() {
zwave.manufacturerSpecificV1.manufacturerSpecificGet().format()
}
def parse(String description) {
def result = null
def cmd = zwave.parse(description, [0x20: 1, 0x70: 1])
if (cmd) {
result = createEvent(zwaveEvent(cmd))
}
if (result?.name == 'hail' && hubFirmwareLessThan("000.011.00602")) {
result = [result, response(zwave.basicV1.basicGet())]
log.debug "Was hailed: requesting state update"
} else {
log.debug "Parse returned ${result?.descriptionText}"
}
return result
}
def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {
[name: "switch", value: cmd.value ? "on" : "off", type: "physical"]
}
def zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd) {
[name: "switch", value: cmd.value ? "on" : "off", type: "digital"]
}
def zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {
def value = "when off"
if (cmd.configurationValue[0] == 1) {value = "when on"}
if (cmd.configurationValue[0] == 2) {value = "never"}
[name: "indicatorStatus", value: value, display: false]
}
def zwaveEvent(physicalgraph.zwave.commands.hailv1.Hail cmd) {
[name: "hail", value: "hail", descriptionText: "Switch button was pressed", displayed: false]
}
def zwaveEvent(physicalgraph.zwave.Command cmd) {
// Handles all Z-Wave commands we aren't interested in
[:]
}
def on() {
delayBetween([
delayBetween([
zwave.basicV1.basicSet(value: 0xFF).format(),
zwave.basicV1.basicSet(value: 0x00).format()
], 1000),
zwave.switchBinaryV1.switchBinaryGet().format()
], 10000)
}
def off() {
delayBetween([
delayBetween([
zwave.basicV1.basicSet(value: 0xFF).format(),
zwave.basicV1.basicSet(value: 0x00).format()
], 1000),
zwave.switchBinaryV1.switchBinaryGet().format()
], 10000)
}
def poll() {
log.debug "poll()"
zwave.switchBinaryV1.switchBinaryGet().format()
}
def refresh() {
zwave.switchBinaryV1.switchBinaryGet().format()
}
If there’s a better way to do this it’d be great to know.
Also, it be great if I could incorporate my tilt sensor with this device. Is it possible to create devices that talk to one another or better yet that are almost combinations of sensors? (I’m thinking how this new “door” feature works, it’s extremely similar).