From b7484ff0b83d8bb0a1450d851a9fc8bcfcb68792 Mon Sep 17 00:00:00 2001 From: Daniel Kurin Date: Sun, 7 Feb 2016 11:36:24 -0500 Subject: [PATCH] MSA-866: Currently, the SmartSense Moisture handles both the FortrezZ WWA01 and the '02, however the '02 sends a temperature measurement. This PR expands the existing DH to add a valueTile with that temperature data (per https://github.com/SmartThingsCommunity/SmartThingsPublic/pull/447) --- .../smartsense-moisture.groovy | 48 ++++++++++++++----- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/devicetypes/smartthings/smartsense-moisture.src/smartsense-moisture.groovy b/devicetypes/smartthings/smartsense-moisture.src/smartsense-moisture.groovy index 5483cb1..43577f1 100644 --- a/devicetypes/smartthings/smartsense-moisture.src/smartsense-moisture.groovy +++ b/devicetypes/smartthings/smartsense-moisture.src/smartsense-moisture.groovy @@ -16,6 +16,7 @@ metadata { capability "Water Sensor" capability "Sensor" capability "Battery" + capability "Temperature Measurement" fingerprint deviceId: "0x2001", inClusters: "0x30,0x9C,0x9D,0x85,0x80,0x72,0x31,0x84,0x86" fingerprint deviceId: "0x2101", inClusters: "0x71,0x70,0x85,0x80,0x72,0x31,0x84,0x86" @@ -39,17 +40,29 @@ metadata { attributeState "wet", label: "Wet", icon:"st.alarm.water.wet", backgroundColor:"#53a7c0" } } - standardTile("temperature", "device.temperature", width: 2, height: 2) { + standardTile("temperatureState", "device.temperature", width: 2, height: 2) { state "normal", icon:"st.alarm.temperature.normal", backgroundColor:"#ffffff" state "freezing", icon:"st.alarm.temperature.freeze", backgroundColor:"#53a7c0" state "overheated", icon:"st.alarm.temperature.overheat", backgroundColor:"#F80000" } + valueTile("temperature", "device.temperature", width: 2, height: 2) { + state("temperature", label:'${currentValue}°', + 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"] + ] + ) + } valueTile("battery", "device.battery", decoration: "flat", inactiveLabel: false, width: 2, height: 2) { state "battery", label:'${currentValue}% battery', unit:"" } - - main (["water", "temperature"]) - details(["water", "temperature", "battery"]) + main (["water", "temperatureState"]) + details(["water", "temperatureState", "temperature", "battery"]) } } @@ -115,7 +128,7 @@ def zwaveEvent(physicalgraph.zwave.commands.alarmv2.AlarmReport cmd) map.descriptionText = "${device.displayName} is ${map.value}" } if(cmd.zwaveAlarmType == physicalgraph.zwave.commands.alarmv2.AlarmReport.ZWAVE_ALARM_TYPE_HEAT) { - map.name = "temperature" + map.name = "temperatureState" if(cmd.zwaveAlarmEvent == 1) { map.value = "overheated"} if(cmd.zwaveAlarmEvent == 2) { map.value = "overheated"} if(cmd.zwaveAlarmEvent == 3) { map.value = "changing temperature rapidly"} @@ -129,17 +142,30 @@ def zwaveEvent(physicalgraph.zwave.commands.alarmv2.AlarmReport cmd) map } -def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) +def zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv5.SensorMultilevelReport cmd) { def map = [:] - map.name = "water" - map.value = cmd.value ? "wet" : "dry" - map.descriptionText = "${device.displayName} is ${map.value}" + if(cmd.sensorType == 1) { + map.name = "temperature" + if(cmd.scale == 0) { + map.value = getTemperature(cmd.scaledSensorValue) + } else { + map.value = cmd.scaledSensorValue + } + map.unit = location.temperatureScale + } map } +def getTemperature(value) { + if(location.temperatureScale == "C"){ + return value + } else { + return Math.round(celsiusToFahrenheit(value)) + } +} + def zwaveEvent(physicalgraph.zwave.Command cmd) { log.debug "COMMAND CLASS: $cmd" -} - +} \ No newline at end of file