Skip to content

Commit

Permalink
Update EZMultiPliDeviceType.gy
Browse files Browse the repository at this point in the history
Jim Sulins updates - color now appears to be working if you send in "red" or "green" to the color command.
  • Loading branch information
Eric Ryherd committed Feb 25, 2015
1 parent 4a97101 commit e270d62
Showing 1 changed file with 213 additions and 50 deletions.
263 changes: 213 additions & 50 deletions EZMultiPliDeviceType.gy
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
// Express Controls EZMultiPli Multi-sensor driver for SmartThings
// The EZMultiPli is also known as the HSM200 - it's the same device.
// v0.0.7 - jrs - 02/23/2015 - Improved version by Jim Sulin

metadata {
definition (name: "EZmultiPli", namespace: "DrZWave", author: "Eric Ryherd", oauth: true) {
capability "Motion Sensor"
capability "Temperature Measurement"
capability "Illuminance Measurement"
capability "Color Control"
capability "Configuration"

fingerprint deviceId: "0x0701", inClusters: "0x5E, 0x71, 0x31, 0x33, 0x72, 0x86, 0x59, 0x85, 0x70, 0x77, 0x5A, 0x7A, 0x73, 0xEF, 0x20"
}
definition (name: "EZmultiPli", namespace: "DrZWave", author: "Eric Ryherd", oauth: true) {
capability "Switch"
capability "Motion Sensor"
capability "Temperature Measurement"
capability "Illuminance Measurement"
capability "Color Control"
capability "Configuration"

fingerprint deviceId: "0x0701", inClusters: "0x5E, 0x71, 0x31, 0x33, 0x72, 0x86, 0x59, 0x85, 0x70, 0x77, 0x5A, 0x7A, 0x73, 0xEF, 0x20"
} // end definition

simulator {
// messages the device returns in response to commands it receives
Expand All @@ -21,22 +23,26 @@ metadata {
status "temperature ${i}F": new physicalgraph.zwave.Zwave().sensorMultilevelV5.sensorMultilevelReport(
scaledSensorValue: i, precision: 1, sensorType: 1, scale: 1).incomingMessage()
}


for (int i = 0; i <= 100; i += 20) {
status "luminance ${i} %": new physicalgraph.zwave.Zwave().sensorMultilevelV5.sensorMultilevelReport(
scaledSensorValue: i, precision: 0, sensorType: 3).incomingMessage()
}

}
} //end simulator

tiles {
standardTile("motion", "device.motion", width: 2, height: 2, canChangeIcon: true, canChangeBackground: true) {
state "active", label:'motion', icon:"st.motion.motion.active", backgroundColor:"#53a7c0"
state "inactive", label:'no motion', icon:"st.motion.motion.inactive", backgroundColor:"#ffffff"
}
standardTile("switch", "device.switch", canChangeIcon: true) {
state "on", label:'${name}', action:"switch.off", icon:"st.switches.switch.on", backgroundColor:"#79b821", nextState:"turningOff"
state "off", label:'${name}', action:"switch.on", icon:"st.switches.switch.off", backgroundColor:"#ffffff", nextState:"turningOn"
state "turningOn", label:'${name}', icon:"st.switches.switch.on", backgroundColor:"#79b821"
state "turningOff", label:'${name}', icon:"st.switches.switch.off", backgroundColor:"#ffffff"
}
valueTile("temperature", "device.temperature", inactiveLabel: false) {
state "temperature", label:'${currentValue} ${unit}',
state "temperature", label:'${currentValue}° ${unit}',
backgroundColors:[
[value: 31, color: "#153591"],
[value: 44, color: "#1e9cbb"],
Expand All @@ -56,18 +62,31 @@ metadata {
[value: 90, color: "#f0f0f0"]
]
}
controlTile("rgbSelector", "device.color", "color", height: 3, width: 3, inactiveLabel: false) {
state "color", action:"color control.setColor"
}
standardTile("configure", "device.configure", inactiveLabel: false, decoration: "flat") {
state "configure", label:'', action:"configuration.configure", icon:"st.secondary.configure"
}

main "motion"
details(["motion", "temperature", "illuminance", "configure"])
}
}
main (["motion", "switch", "temperature"])
details(["switch", "motion", "temperature", "illuminance", "configure", "rgbSelector"])
// details(["motion", "switch", "temperature", "illuminance", "configure"])
} // end tiles

preferences {
input "OnTime", "number", title: "No Motion Interval", description: "N minutes lights stay on after no motion detected [0, 1-127]", defaultValue: 10, displayDuringSetup: true, required: false
input "OnLevel", "number", title: "Dimmer Onlevel", description: "Dimmer OnLevel for associated node 2 lights [0, 1-99, -1]", defaultValue: -1, displayDuringSetup: true, required: false
input "LiteMin", "number", title: "Luminance Report Frequency", description: "Luminance report sent every N minutes", defaultValue: 60, displayDuringSetup: true, required: false
input "TempMin", "number", title: "Temperature Report Frequency", description: "Temperature report sent every N minutes", defaultValue: 60, displayDuringSetup: true, required: false
input "TempAdj", "number", title: "Temperature Calibration", description: "Adjust temperature up/down N degrees F [(-127)-(+128)]", defaultValue: 0, displayDuringSetup: true, required: false
}

} // end metadata

// Parse incoming device messages to generate events
def parse(String description)
{

// Parse incoming device messages from device to generate events
def parse(String description){
def result = []
def cmd = zwave.parse(description, [0x31: 5]) // 0x31=SensorMultilevel which we force to be version 5
if (cmd) {
Expand All @@ -77,66 +96,210 @@ def parse(String description)
return result
}

// Event Generation

def zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv5.SensorMultilevelReport cmd)
{
// Event Generation
def zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv5.SensorMultilevelReport cmd){
def map = [:]
switch (cmd.sensorType) {
case 0x01: // SENSOR_TYPE_TEMPERATURE_VERSION_1
// temperature
case 0x01: // SENSOR_TYPE_TEMPERATURE_VERSION_1
def cmdScale = cmd.scale == 1 ? "F" : "C"
map.value = convertTemperatureIfNeeded(cmd.scaledSensorValue, cmdScale, cmd.precision)
map.unit = getTemperatureScale()
map.name = "temperature"
log.debug "Temperature report"
log.debug "Temperature report"
break;
case 0x03 : // SENSOR_TYPE_LUMINANCE_VERSION_1
// luminance
case 0x03 : // SENSOR_TYPE_LUMINANCE_VERSION_1
map.value = cmd.scaledSensorValue.toInteger().toString()
map.unit = "%"
map.name = "illuminance"
log.debug "Luminance report"
log.debug "Luminance report"
break;
}
map
return map
}


def zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd) {
def map = [:]
if (cmd.notificationType==0x07) { // NOTIFICATION_TYPE_BURGLAR
if (cmd.event==0x07 || cmd.event==0x08) {
if (cmd.notificationType==0x07) { // NOTIFICATION_TYPE_BURGLAR
if (cmd.event==0x07 || cmd.event==0x08) {
map.name = "motion"
map.value = "active"
map.value = "active"
map.descriptionText = "$device.displayName motion detected"
log.debug "motion recognized"
log.debug "motion recognized"
} else if (cmd.event==0) {
map.name = "motion"
map.value = "inactive"
map.value = "inactive"
map.descriptionText = "$device.displayName no motion detected"
log.debug "No motion recognized"
}
}
log.debug "No motion recognized"
}
}
if (map.name != "motion") {
log.debug "unmatched parameters for cmd: ${cmd.toString()}}"
}
map
log.debug "unmatched parameters for cmd: ${cmd.toString()}}"
}
return map
}

/*
def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {
[name: "switch", value: cmd.value ? "on" : "off", type: "digital"]
}


def on() {
log.debug "Turning Light 'on'"
delayBetween([
zwave.basicV1.basicSet(value: 0xFF).format(),
zwave.basicV1.basicGet().format()
], 500)
}

def off() {
log.debug "Turning Light 'off'"
delayBetween([
zwave.basicV1.basicSet(value: 0x00).format(),
zwave.basicV1.basicGet().format()
], 500)
}

def setColor(value) {
log.debug "setColor() : ${value}"
def cmds = []
def colorid = 0
def curCapId = 0
switch (value) {
case "black":
colorid = 0
cmds << off()
break
case "white":
colorid = 1
cmds << off()
cmds << on()
break
case "red":
colorid = 2
// cmds << zwave.colorControlV1.stateSet(stateDataLength: 3, VariantGroup1: [0x02, 0xff], VariantGroup2:[ 0x03, 0], VariantGroup3:[0x04,0]).format() // ST support for this command as of 2015/02/23 does not support the color IDs so this command cannot be used.
// So instead we'll use these commands to hack around the lack of support of the above command
cmds << zwave.basicV1.basicSet(value: 0x00).format() // Not the cleanest way to set the color but it works - better to just use stateSet but as of 2015/02/23 ST is not supporting stateSet properly.
cmds << zwave.colorControlV1.startCapabilityLevelChange(capabilityId: colorid, startState: 0x55, ignoreStartState: True, updown: True).format()
cmds << zwave.colorControlV1.stopStateChange(capabilityId: colorid).format()
break
case "green":
colorid = 3
cmds << zwave.basicV1.basicSet(value: 0x00).format() // Not the cleanest way to set the color but it works - better to just use stateSet but as of 2015/02/23 ST is not supporting stateSet properly.
cmds << zwave.colorControlV1.startCapabilityLevelChange(capabilityId: colorid, startState: 0x55, ignoreStartState: True, updown: True).format()
cmds << zwave.colorControlV1.stopStateChange(capabilityId: colorid).format()
break
case "blue":
colorid = 4
cmds << zwave.basicV1.basicSet(value: 0x00).format() // Not the cleanest way to set the color but it works - better to just use stateSet but as of 2015/02/23 ST is not supporting stateSet properly.
cmds << zwave.colorControlV1.startCapabilityLevelChange(capabilityId: colorid, startState: 0x55, ignoreStartState: True, updown: True).format()
cmds << zwave.colorControlV1.stopStateChange(capabilityId: colorid).format()
break
case "aqua":
cmds << zwave.basicV1.basicSet(value: 0x00).format() // Not the cleanest way to set the color but it works - better to just use stateSet but as of 2015/02/23 ST is not supporting stateSet properly.
cmds << zwave.colorControlV1.startCapabilityLevelChange(capabilityId: 3, startState: 0x55, ignoreStartState: True, updown: True).format()
cmds << zwave.colorControlV1.stopStateChange(capabilityId: 3).format()
cmds << zwave.colorControlV1.startCapabilityLevelChange(capabilityId: 4, startState: 0x55, ignoreStartState: True, updown: True).format()
cmds << zwave.colorControlV1.stopStateChange(capabilityId: 4).format()
break
case "pink":
cmds << zwave.basicV1.basicSet(value: 0x00).format() // Not the cleanest way to set the color but it works - better to just use stateSet but as of 2015/02/23 ST is not supporting stateSet properly.
cmds << zwave.colorControlV1.startCapabilityLevelChange(capabilityId: 2, startState: 0x55, ignoreStartState: True, updown: True).format()
cmds << zwave.colorControlV1.stopStateChange(capabilityId: 2).format()
cmds << zwave.colorControlV1.startCapabilityLevelChange(capabilityId: 4, startState: 0x55, ignoreStartState: True, updown: True).format()
cmds << zwave.colorControlV1.stopStateChange(capabilityId: 4).format()
break
case "yellow":
cmds << zwave.basicV1.basicSet(value: 0x00).format() // Not the cleanest way to set the color but it works - better to just use stateSet but as of 2015/02/23 ST is not supporting stateSet properly.
cmds << zwave.colorControlV1.startCapabilityLevelChange(capabilityId: 2, startState: 0x55, ignoreStartState: True, updown: True).format()
cmds << zwave.colorControlV1.stopStateChange(capabilityId: 2).format()
cmds << zwave.colorControlV1.startCapabilityLevelChange(capabilityId: 3, startState: 0x55, ignoreStartState: True, updown: True).format()
cmds << zwave.colorControlV1.stopStateChange(capabilityId: 3).format()
break
default:
colorid = 1 // bad color entry, go with default
}

delayBetween(cmds, 100)
}


def zwaveEvent(physicalgraph.zwave.Command cmd) {
log.debug "Catchall reached for cmd: ${cmd.toString()}}"
// Handles all Z-Wave commands we aren't interested in
[:]
}
*/
def configure() { // TODO need to change these to allow the user to set each value to their desired setting
delayBetween([
zwave.configurationV1.configurationSet(parameterNumber: 1, size: 1, scaledConfigurationValue: 5).format(), // set the OnTime to 5 min for quicker testing

zwave.configurationV1.configurationSet(parameterNumber: 3, size: 1, scaledConfigurationValue: 10).format(), // send a luminance reading every 10 min
// ensure we are passing acceptable param values for LiteMin & TempMin configs
def checkLiteTempInput(value) {
def liteTempVal = value.toInteger()
switch (liteTempVal) {
case { it < 0 }:
return 60 // bad value, set to default
break
case { it > 127 }:
return 127 // bad value, greater then MAX, set to MAX
break
default:
return liteTempVal // acceptable value
}
}

zwave.configurationV1.configurationSet(parameterNumber: 4, size: 1, scaledConfigurationValue: 6).format(), // send a temperature reading every 6 min
])
// ensure we are passing acceptable param value for OnTime config
def checkOnTimeInput(value) {
def onTimeVal = value.toInteger()
switch (onTimeVal) {
case { it < 0 }:
return 10 // bad value set to default
break
case { it > 127 }:
return 127 // bad value, greater then MAX, set to MAX
break
default:
return onTimeVal // acceptable value
}
}

// ensure we are passing acceptable param value for OnLevel config
def checkOnLevelInput(value) {
def onLevelVal = value.toInteger()
switch (onLevelVal) {
case { it < -1 }:
return -1 // bad value set to default
break
case { it > 99 }:
return 99 // bad value, greater then MAX, set to MAX
break
default:
return onLevelVal // acceptable value
}
}


// ensure we are passing an acceptable param value for TempAdj configs
def checkTempAdjInput(value) {
def tempAdjVal = value.toInteger()
switch (tempAdjVal) {
case { it < -127 }:
return 0 // bad value, set to default
break
case { it > 128 }:
return 128 // bad value, greater then MAX, set to MAX
break
default:
return tempAdjVal // acceptable value
}
}


def configure() {
def cmd = delayBetween([
zwave.configurationV1.configurationSet(parameterNumber: 1, size: 1, configurationValue: [checkOnTimeInput(settings.OnTime)]).format(),
zwave.configurationV1.configurationSet(parameterNumber: 2, size: 1, configurationValue: [checkOnLevelInput(settings.OnLevel)]).format(),
zwave.configurationV1.configurationSet(parameterNumber: 3, size: 1, configurationValue: [checkLiteTempInput(settings.LiteMin)]).format(),
zwave.configurationV1.configurationSet(parameterNumber: 4, size: 1, configurationValue: [checkLiteTempInput(settings.TempMin)]).format(),
zwave.configurationV1.configurationSet(parameterNumber: 5, size: 1, configurationValue: [checkTempAdjInput(settings.TempAdj)]).format()
], 100)
log.debug cmd
cmd
}

0 comments on commit e270d62

Please sign in to comment.