diff --git a/EZMultiPliDeviceType.gy b/EZMultiPliDeviceType.gy index 24b05d7..aed8153 100644 --- a/EZMultiPliDeviceType.gy +++ b/EZMultiPliDeviceType.gy @@ -3,20 +3,20 @@ // driver for SmartThings // The EZMultiPli is also known as the HSM200 from HomeSeer.com // +// v0.1.0 - DrZWave - chose better icons, Got color LED to work - first fully functional version // v0.0.9 - jrs - got the temp and luminance to work. Motion works. Debugging the color wheel. // v0.0.8 - DrZWave 2/25/2015 - change the color control to be tiles since there are only 8 colors. // v0.0.7 - jrs - 02/23/2015 - Jim Sulin metadata { definition (name: "EZmultiPli", namespace: "DrZWave", author: "Eric Ryherd", oauth: true) { - capability "Switch" capability "Motion Sensor" capability "Temperature Measurement" capability "Illuminance Measurement" - capability "Color Control" // might want to drop this... TODO - replace it with simple buttons (tiles)? + capability "Switch" + capability "Color Control" capability "Configuration" -// jrs 04/07/2015 - command "setAdjustedColor" + command "setColor" fingerprint deviceId: "0x0701", inClusters: "0x5E, 0x71, 0x31, 0x33, 0x72, 0x86, 0x59, 0x85, 0x70, 0x77, 0x5A, 0x7A, 0x73, 0xEF, 0x20" } // end definition @@ -34,9 +34,9 @@ metadata { status "luminance ${i} %": new physicalgraph.zwave.Zwave().sensorMultilevelV5.sensorMultilevelReport( scaledSensorValue: i, precision: 0, sensorType: 3).incomingMessage() } -// jrs 04/07/2015 + controlTile("rgbSelector", "device.color", "color", height: 3, width: 3, inactiveLabel: false) { - state "color", action:"setAdjustedColor" + state "color", action:"setColor" } } //end simulator @@ -47,53 +47,46 @@ metadata { 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" - state "on", label:'${name}', action:"switch.off", icon:"st.lights.philips.hue-single", backgroundColor:"#79b821" - state "off", label:'${name}', action:"switch.on", icon:"st.lights.philips.hue-single", backgroundColor:"#ffffff" + state "on", label:'${name}', action:"switch.off", icon:"st.switches.light.on", backgroundColor:"#79b821", nextState:"turningOff" + state "off", label:'${name}', action:"switch.on", icon:"st.switches.light.off", backgroundColor:"#ffffff", nextState:"turningOn" + state "turningOn", label:'${name}', icon:"st.switches.light.on", backgroundColor:"#79b821" + state "turningOff", label:'${name}', icon:"st.switches.light.off", backgroundColor:"#ffffff" } - valueTile("temperature", "device.temperature", inactiveLabel: false) { -// jrs 4/7/2015 - Null on display -// state "temperature", label:'${currentValue}° ${unit}', - state "temperature", label:'Temp\n ${currentValue}°', unit:"F", + valueTile("temperature", "device.temperature") { + state "temperature", label:'${currentValue}°', unit:"F", icon:"st.Weather.weather2", // would be better if the units would switch to the desired units of the system (imperial or metric) backgroundColors:[ - [value: 31, color: "#153591"], - [value: 44, color: "#1e9cbb"], - [value: 59, color: "#90d2a7"], - [value: 74, color: "#44b621"], - [value: 84, color: "#f1d801"], - [value: 95, color: "#d04e00"], - [value: 96, color: "#bc2323"] + [value: 0, color: "#1010ff"], // blue=cold + [value: 65, color: "#a0a0f0"], + [value: 70, color: "#e0e050"], + [value: 75, color: "#f0d030"], // yellow + [value: 80, color: "#fbf020"], + [value: 85, color: "#fbdc01"], + [value: 90, color: "#fb3a01"], + [value: 95, color: "#fb0801"] // red=hot ] - } + } // icons to use would be st.Weather.weather2 or st.alarm.temperature.normal - see http://scripts.3dgo.net/smartthings/icons/ for a list of icons valueTile("illuminance", "device.illuminance", inactiveLabel: false) { // jrs 4/7/2015 - Null on display // state "luminosity", label:'${currentValue} ${unit}' - state "luminosity", label:'Luminosity\n ${currentValue}%', unit:"%", + state "luminosity", label:'${currentValue}%', unit:"%", icon:"st.illuminance.illuminance.bright", backgroundColors:[ [value: 25, color: "#404040"], [value: 50, color: "#808080"], [value: 75, color: "#a0a0a0"], - [value: 90, color: "#f0f0f0"] + [value: 90, color: "#e0e0e0"] ] } // jrs 4/7/2015 - controlTile("rgbSelector", "device.color", "color", height: 3, width: 3, inactiveLabel: false) { + controlTile("rgbSelector", "device.color", "color", height: 1, width: 1) { state "color", action:"color control.setColor" } -// controlTile("rgbSelector", "device.color", "color", height: 3, width: 3, inactiveLabel: false) { -// state "color", action:"setAdjustedColor" -// } standardTile("configure", "device.configure", inactiveLabel: false, decoration: "flat") { state "configure", label:'', action:"configuration.configure", icon:"st.secondary.configure" } - main (["motion", "switch", "temperature"]) - details(["switch", "motion", "temperature", "illuminance", "configure", "rgbSelector"]) -// details(["motion", "switch", "temperature", "illuminance", "configure"]) + main ("motion") + details(["motion", "temperature", "illuminance", "configure", "switch", "rgbSelector"]) } // end tiles preferences { @@ -184,107 +177,30 @@ def off() { } -/** -def on() { - parent.on(this) - sendEvent(name: "switch", value: "on") -} - -def off() { - parent.off(this) - sendEvent(name: "switch", value: "off") -} - - def setColor(value) { - log.debug "setColor: ${value}, $this" -// parent.setColor(this, value) -// parent.setColor(this, value) -// if (value.hue) { sendEvent(name: "hue", value: value.hue)} -// if (value.saturation) { sendEvent(name: "saturation", value: value.saturation)} - if (value.hex) { sendEvent(name: "color", value: value.hex)} -// if (value.level) { sendEvent(name: "level", value: value.level)} - if (value.switch) { sendEvent(name: "switch", value: value.switch)} -} -**/ -def setAdjustedColor(value) { - if (value) { - log.debug "setAdjustedColor: ${value}" - def adjusted = value + [:] -// adjusted.hue = adjustOutgoingHue(value.hue) - // Needed because color picker always sends 100 - adjusted.level = null - log.debug "adjusted= ${adjusted}" - setColor(adjusted) - } -} - - -def setColor(value) { - log.debug "setColor() : ${value}" + log.debug "setColor() : ${value} and red value is= ${value.red}" 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. + def myred=value.red >128 ? 255 : 0 // the EZMultiPli has just on/off for each of the 3 channels RGB so convert the 0-255 value into 0 or 255. + def mygreen=value.green >128 ? 255 : 0 + def myblue=value.blue>128 ? 255 : 0 +// cmds << zwave.colorControlV1.stateSet(stateDataLength: 3, VariantGroup1: [0x02, myred], VariantGroup2:[ 0x03, mygreen], VariantGroup3:[0x04,myblue]).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) + cmds << zwave.basicV1.basicSet(value: 0x00).format() // As of 2015/02/23 ST is not supporting stateSet properly but found this hack that works. + if (myred!=0) { + cmds << zwave.colorControlV1.startCapabilityLevelChange(capabilityId: 0x02, startState: myred, ignoreStartState: True, updown: True).format() + cmds << zwave.colorControlV1.stopStateChange(capabilityId: 0x02).format() + } + if (mygreen!=0) { + cmds << zwave.colorControlV1.startCapabilityLevelChange(capabilityId: 0x03, startState: mygreen, ignoreStartState: True, updown: True).format() + cmds << zwave.colorControlV1.stopStateChange(capabilityId: 0x03).format() + } + if (myblue!=0) { + cmds << zwave.colorControlV1.startCapabilityLevelChange(capabilityId: 0x04, startState: myblue, ignoreStartState: True, updown: True).format() + cmds << zwave.colorControlV1.stopStateChange(capabilityId: 0x04).format() + } + delayBetween(cmds, 100) } - - def zwaveEvent(physicalgraph.zwave.Command cmd) { // Handles all Z-Wave commands we aren't interested in [:]