I modified a DTH from @jscgs350 for the MimoLite relay that has a presence sensor input. I have this connected to a driveway gate so that when I close the relay on the zwave Mimolite relay it opens my driveway gate. This DTH was showing as a switch only in smart apps and routines, so I rearranged the capabilities in the definition to be a garage door first so I could include the “Driveway Gate” under Garage Doors for automation purposes in Core and Routines.
I also had to reverse the presence sensor direction so that ST thinks my gate is open when the two halves of my presence sensor touch and my gate is closed when the two halves of my presence sensor are apart. I modified def sensorValueEvent Lines 116-125, essentially reversing the logic.
The device works when I manually fire it, and the presence sensor works. But when I execute a routine to open the gate, it does not open. Can anyone tell me what I would have done to broken routine automation?
/**
* MIMOlite device type for garage door button, including power failure indicator. Be sure mimolite has jumper removed before
* including the device to your hub, and tap Config to ensure power alarm is subscribed.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
* Version: v4.1
*
* Updates:
* -------
* 02-18-2016 : Initial commit
* 03-05-2016 : Changed date format to MM-dd-yyyy h:mm a
* 03-11-2016 : Due to ST's v2.1.0 app totally hosing up SECONDARY_CONTROL, implemented a workaround to display that info in a separate tile.
* 08-27-2016 : Modified the device handler for my liking, primarly for looks and feel.
*
*/
metadata {
// Automatically generated. Make future change here.
definition (name: "My MIMOlite Garage Door Controller", namespace: "jscgs350", author: "SmartThings") {
capability "Garage Door Control"
capability "Momentary"
capability "Relay Switch"
capability "Polling"
capability "Refresh"
capability "Switch"
capability "Sensor"
capability "Contact Sensor"
capability "Configuration"
capability "Actuator"
capability "Door Control"
attribute "powered", "string"
attribute "contactState", "string"
command "on"
command "off"
}
// UI tile definitions
tiles(scale: 2) {
multiAttributeTile(name:"switch", type: "lighting", width: 6, height: 4){
tileAttribute ("device.switch", key: "PRIMARY_CONTROL") {
attributeState "doorClosed", label: "Closed", action: "push", icon: "st.doors.garage.garage-closed", backgroundColor: "#79b821", nextState:"openingdoor"
attributeState "doorOpen", label: "Open", action: "push", icon: "st.doors.garage.garage-open", backgroundColor: "#ffa81e", nextState:"closingdoor"
attributeState "closingdoor", label:'Closing', icon:"st.doors.garage.garage-closing", backgroundColor:"#ffd700"
attributeState "openingdoor", label:'Opening', icon:"st.doors.garage.garage-opening", backgroundColor:"#ffd700"
}
tileAttribute ("statusText", key: "SECONDARY_CONTROL") {
// attributeState "statusText", label:'${currentValue}'
attributeState "statusText", label:''
}
}
standardTile("contact", "device.contact", inactiveLabel: false) {
state "open", label: '${name}', icon: "st.contact.contact.open", backgroundColor: "#ffa81e"
state "closed", label: '${name}', icon: "st.contact.contact.closed", backgroundColor: "#79b821"
}
standardTile("refresh", "device.switch", width: 2, height: 2, inactiveLabel: false, decoration: "flat") {
state "default", label:'Refresh', action:"refresh.refresh", icon:"st.secondary.refresh-icon"
}
standardTile("powered", "device.powered", width: 2, height: 2, inactiveLabel: false) {
state "powerOn", label: "Power On", icon: "st.switches.switch.on", backgroundColor: "#79b821"
state "powerOff", label: "Power Off", icon: "st.switches.switch.off", backgroundColor: "#ff0000"
}
standardTile("configure", "device.configure", width: 2, height: 2, inactiveLabel: false, decoration: "flat") {
state "configure", label:'', action:"configuration.configure", icon:"st.secondary.configure"
}
standardTile("blankTile", "statusText", inactiveLabel: false, decoration: "flat", width: 1, height: 1) {
state "default", label:'', icon:"http://cdn.device-icons.smartthings.com/secondary/device-activity-tile@2x.png"
}
valueTile("statusText", "statusText", inactiveLabel: false, decoration: "flat", width: 5, height: 1) {
state "statusText", label:'${currentValue}', backgroundColor:"#ffffff"
}
main (["switch", "contact"])
details(["switch", "blankTile", "statusText", "powered", "refresh", "configure"])
}
}
def parse(String description) {
log.debug "description is: ${description}"
def result = null
def cmd = zwave.parse(description, [0x72: 1, 0x86: 1, 0x71: 1, 0x30: 1, 0x31: 3, 0x35: 1, 0x70: 1, 0x85: 1, 0x25: 1, 0x03: 1, 0x20: 1, 0x84: 1])
log.debug "command value is: $cmd.CMD"
if (cmd.CMD == "7105") { //Mimo sent a power loss report
log.debug "Device lost power"
sendEvent(name: "powered", value: "powerOff", descriptionText: "$device.displayName lost power")
} else {
sendEvent(name: "powered", value: "powerOn", descriptionText: "$device.displayName regained power")
}
if (cmd) {
result = createEvent(zwaveEvent(cmd))
}
log.debug "Parse returned ${result?.descriptionText}"
def statusTextmsg = ""
def timeString = new Date().format("MM-dd-yy h:mm a", location.timeZone)
statusTextmsg = "${device.currentState('contactState').value}\nLast updated: "+timeString
sendEvent("name":"statusText", "value":statusTextmsg)
return result
}
def sensorValueEvent(Short value) {
if (value) {
sendEvent(name: "contact", value: "closed")
sendEvent(name: "switch", value: "doorClosed")
sendEvent(name: "contactState", value: "Tap to open")
}
else {
sendEvent(name: "contact", value: "open")
sendEvent(name: "switch", value: "doorOpen")
sendEvent(name: "contactState", value: "Tap to close")
}
}
def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {
// [name: "switch", value: cmd.value ? "on" : "off", type: "physical"]
}
def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd)
{
sensorValueEvent(cmd.value)
}
def zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd) {
// def doorState = device.currentValue('contact')
// if ( doorState == "closed")
// [name: "switch", value: cmd.value ? "on" : "doorOpening", type: "digital"]
// else
// [name: "switch", value: cmd.value ? "on" : "doorClosing", type: "digital"]
}
def zwaveEvent(physicalgraph.zwave.commands.sensorbinaryv1.SensorBinaryReport cmd)
{
sensorValueEvent(cmd.sensorValue)
}
def zwaveEvent(physicalgraph.zwave.commands.alarmv1.AlarmReport cmd)
{
log.debug "We lost power" //we caught this up in the parse method. This method not used.
}
def zwaveEvent(physicalgraph.zwave.Command cmd) {
// Handles all Z-Wave commands we aren't interested in
[:]
}
def on() {
open()
}
def off() {
close()
}
def open() {
if (device.currentValue("contact") != "open") {
log.debug "Sending ACTUATE event to open door"
push()
}
else {
log.debug "Not opening door since it is already open"
}
}
def close() {
if (device.currentValue("contact") != "closed") {
log.debug "Sending ACTUATE event to close door"
push()
}
else {
log.debug "Not closing door since it is already closed"
}
}
def push() {
log.debug "Executing ACTUATE for garage car door per user request"
delayBetween([
zwave.basicV1.basicSet(value: 0xFF).format(),
zwave.switchBinaryV1.switchBinaryGet().format(),
zwave.sensorBinaryV1.sensorBinaryGet().format(),
zwave.basicV1.basicGet().format(),
zwave.alarmV1.alarmGet().format()
],100)
}
def poll() {
refresh()
}
def refresh() {
log.debug "Executing Refresh/Poll for garage car door per user request"
delayBetween([
zwave.switchBinaryV1.switchBinaryGet().format(),
zwave.sensorBinaryV1.sensorBinaryGet().format(),
zwave.basicV1.basicGet().format(),
zwave.alarmV1.alarmGet().format()
],100)
}
def configure() {
log.debug "Configuring...." //setting up to monitor power alarm and actuator duration
delayBetween([
zwave.associationV1.associationSet(groupingIdentifier:3, nodeId:[zwaveHubNodeId]).format(),
zwave.configurationV1.configurationSet(configurationValue: [25], parameterNumber: 11, size: 1).format(),
zwave.configurationV1.configurationGet(parameterNumber: 11).format()
])
}