Working MIMOlite Device Type with Sensor


(Jit Jack) #1

Hi,
Just wanted to share my device type for the Fortrezz MIMO lite. I am not a developer, just good at copy/pasting so I would like for someone with proper abilities to review the code for errors.
Right now the switch is working as is the contact sensor (SIG1) so you could use the MIMO to monitor a garage door and open and close. I am planning on using it to operate a Sweat Valve to control the water in the house. A much cheaper solution than the Fortrezz water valve.
The MIMO has an alarm for low power which I haven’t been able to get working. Wouldn’t mind a hand here.
To create your device select this capabilities: Contact Sensor, Polling, Refresh, Switch.

 /**
 *  Fortrezz MIMOlite
 *
 *  Author: Based on SmartThings code
 *  Date: 2014-03-6
 */

// for the UI
metadata {
	// Automatically generated. Make future change here.
	definition (name: "Mimo lite", author: "carlos@carlossaldarriaga.com") {
		capability "Polling"
		capability "Refresh"
		capability "Switch"
		capability "Contact Sensor"
	}

	// 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"
        
		// status messages
		status "open":  "command: 2001, payload: FF"
		status "closed": "command: 2001, payload: 00"
	}

	// UI tile definitions
	tiles {
        standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true) {
			state "on", label: '${name}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#79b821"
			state "off", label: '${name}', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff"
        }
        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", inactiveLabel: false, decoration: "flat") {
			state "default", label:'', action:"refresh.refresh", icon:"st.secondary.refresh"
		}
        valueTile("alarm", "device.alarm", inactiveLabel: false) {
			state "alarm", label:'${currentValue}'
		}


		main (["switch", "contact"])
		details(["switch", "contact", "refresh", "alarm"])
	}
}

def parse(String description) {
	def result = null
	def cmd = zwave.parse(description, [0x20: 1, 0x84: 1, 0x30: 1, 0x70: 1])
	if (cmd) {
		result = createEvent(zwaveEvent(cmd))
	}
	log.debug "Parse returned ${result?.descriptionText}"
	return result
}

def sensorValueEvent(Short value) {
	if (value) {
		createEvent(name: "contact", value: "open", descriptionText: "$device.displayName is open")
	} else {
		createEvent(name: "contact", value: "closed", descriptionText: "$device.displayName is closed")
	}
}

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) {
	[name: "switch", value: cmd.value ? "on" : "off", type: "digital"]
}

def zwaveEvent(physicalgraph.zwave.commands.sensorbinaryv1.SensorBinaryReport cmd)
{
	sensorValueEvent(cmd.sensorValue)
}

def zwaveEvent(physicalgraph.zwave.commands.alarmv1.AlarmReport cmd)
{
	sensorValueEvent(cmd.sensorState)
}

def zwaveEvent(physicalgraph.zwave.Command cmd) {
	// Handles all Z-Wave commands we aren't interested in
	[:]
}

def on() {
	delayBetween([
		zwave.basicV1.basicSet(value: 0xFF).format(),
		zwave.switchBinaryV1.switchBinaryGet().format()
	])
}

def off() {
	delayBetween([
		zwave.basicV1.basicSet(value: 0x00).format(),
		zwave.switchBinaryV1.switchBinaryGet().format()
	])
}

def poll() {
	zwave.switchBinaryV1.switchBinaryGet().format()
}

def refresh() {
	zwave.switchBinaryV1.switchBinaryGet().format()
}

Mimolite input capability?
How to get contact sensor to read open when closed and vice versa
Connecting my gas fireplace
#2

Thanks @JitJack. I appreciate your efforts on the contact sensor. I’m going to use your code for my MIMOlite.

Regarding the alarm, did you check the Alarm capability when you initially created the device type? Also, to trip the alarm would you need to unplug the device?


(Kas) #3

Thanks JitJack!! This is exactly what I needed - works great!


(Jit Jack) #4

Wanted to share a variation to the previous device type. This one has a momentary switch, ideal as a garage door controller. Instructions are the same in setting the device type except you should check the MOMENTARY capability and use the following code:

/**
 *  MimoLite Momentary Contact Switch
 *
 *  Author: Based on code by SmartThings
 *  Date: 2014-03-011
 */
metadata {
	// 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"
        
		// status messages
		status "open":  "command: 2001, payload: FF"
		status "closed": "command: 2001, payload: 00"
	}

	// tile definitions
	tiles {
		standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true) {
			state "off", label: '${name}', action: "momentary.push", icon: "st.switches.switch.off", backgroundColor: "#ffffff"
			state "on", label: '${name}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#79b821"
		}
        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", inactiveLabel: false, decoration: "flat") {
			state "default", label:'', action:"refresh.refresh", icon:"st.secondary.refresh"
		}
        valueTile("alarm", "device.alarm", inactiveLabel: false) {
			state "alarm", label:'${currentValue}'
		}
        
		main (["switch", "contact"])
		details(["switch", "contact", "refresh", "alarm"])
	}
}

def parse(String description) {
	def result = null
	def cmd = zwave.parse(description, [0x20: 1, 0x84: 1, 0x30: 1, 0x70: 1])
	if (cmd) {
		result = createEvent(zwaveEvent(cmd))
	}
	log.debug "Parse returned ${result?.descriptionText}"
	return result
}

def sensorValueEvent(Short value) {
	if (value) {
		createEvent(name: "contact", value: "open", descriptionText: "$device.displayName is open")
	} else {
		createEvent(name: "contact", value: "closed", descriptionText: "$device.displayName is closed")
	}
}

def zwaveEvent(physicalgraph.zwave.commands.sensorbinaryv1.SensorBinaryReport cmd)
{
	sensorValueEvent(cmd.sensorValue)
}

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.basicv1.BasicSet cmd)
{
	sensorValueEvent(cmd.value)
}

def zwaveEvent(physicalgraph.zwave.commands.alarmv1.AlarmReport cmd)
{
	sensorValueEvent(cmd.sensorState)
}

def zwaveEvent(physicalgraph.zwave.Command cmd) {
	// Handles all Z-Wave commands we aren't interested in
	[:]
}

def push() {
	def cmds = [
		zwave.basicV1.basicSet(value: 0xFF).format(),
		zwave.switchBinaryV1.switchBinaryGet().format(),
		"delay 3000",
		zwave.basicV1.basicSet(value: 0x00).format(),
		zwave.switchBinaryV1.switchBinaryGet().format()
	]
}

def on() {
	push()
}

def off() {
	[
		zwave.basicV1.basicSet(value: 0x00).format(),
		zwave.switchBinaryV1.switchBinaryGet().format()
	]
}

def poll() {
	zwave.switchBinaryV1.switchBinaryGet().format()
}

def refresh() {
	zwave.switchBinaryV1.switchBinaryGet().format()
}

Let me know how it goes.


MIMOlite + Doorbell + SmartThings
A sometimes-silent doorbell
App that will turn off switch after a short period?
(Duffer) #5

NEWBIE here, so please bear with me. I tried the linear fs20 on my garage door and found it would open the door after power restored from a failure. So I removed it and ordered the mimolite. So reesarching the forums I found this. Do I have to put this code somewhere in order to make the mimolite work with the smartthings hub. If so, where and how to get there to do it?


(Duffer) #6

Anyone out there willing to help me get this code for mimolite working. I have tried both versions posted here and have had no luck, And no one has responded to my previous posts.


(Jit Jack) #7

Is the MimoLite working when first included in the network as a Z-wave Switch? My advice would be to have it working per defaults and then create your own device type using my code. Learn how to create your own device type in the IDE.

Hope this helps.


(Duffer) #8

yes it worked as a switch with the jumper set for momentary. I have tried both versions of the code found here used in a device type.
Neither are working for me. When I change to the device type created in ide the switch will not work. When I change back to z-wave momentary, at least I can use it to open the door.


(Andrew Urman) #9

I’ve sent a MIMOlite to @wackware to hack on. He’ll be working on getting it officially supported.


#10

Thanks Andrew!


(Todd Wackford) #11

I finished creating a fully operational Mimolite garage door opener/sensor using @jitjack’s code to start with. It’s cool!

I got the power loss alarm working and it has a state tile for that.

The main tile works as a open/closed/opening/closing actuator button.

It’s submitted to ST for final distribution process. We should see it released soon.

This thing works awesome and I just want to again say cudos to JitJack for building the initial code.

Twack


Mimolite for garage door and magnetic door contact
#12

Thanks @twack,looking forward to it. And thanks for your efforts on this.


(Todd Wackford) #13

Your welcome! We need to thank @cesaldar (JitJack) too.


(Jit Jack) #14

Thanks twack for taking the time improve upon my crude code hacking. Waiting to see how it works. One problem I am facing with my code is I am not getting updates to relay changes. I think the Mimo is not reporting the basic get or binary switch message to group 1 association. One solution would be to poll every X seconds. What do you think?


(Todd Wackford) #15

@cesaldar,

I removed the momentary out of the file and just use the basic switch and associated reporting. It works fine. You’ll need to remove the P5 jumper. I set the switch timeout to 2.5 seconds and associate it to group 3 to get the alarm function to work. I’m amazed that it has enough residual power to get off the message as it dies when power is removed.

Twack


(Beckwith) #16

@twack

I’m using MIMOlite for my garage with success. Can’t wait to get your update.

What is the purpose of power loss notification?


(Beckwith) #17

My MIMOlight no longer opens the garage door. Has anyone else seen this problem? It changes to “Opening” but I never see anything in the logs and eventually changes to Closed.

Status is correct.


(Brian) #18

It would be awesome to modify this code so that the MIMOlite can be used as a monitor for wired smoke detectors. (9v trigger)


(Jit Jack) #19

@wackware,
I can’t seem to find your submitted device type. Shouldn’t I be able to see it in existing device types?


(Jit Jack) #20

By the way, seems the new forum doesn’t format code correctly.