Advertisement
Guest User

Untitled

a guest
Nov 21st, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.61 KB | None | 0 0
  1. /**
  2. * Fortrezz Moisture Temp Sensor2
  3. * COMMAND CLASS: SensorMultilevelReport(precision: 0, scale: 0, scaledSensorValue: 20, sensorType: 1, sensorValue: [20], size: 1)
  4. */
  5.  
  6. metadata {
  7. // Automatically generated. Make future change here.
  8. definition (name: "Fortrezz Wetness Sensor", namespace: "whatever", author: "whoever") {
  9. capability "Water Sensor"
  10. capability "Sensor"
  11. capability "Battery"
  12. capability "Temperature Measurement"
  13.  
  14. fingerprint deviceId: "0x2001", inClusters: "0x30,0x9C,0x9D,0x85,0x80,0x72,0x31,0x84,0x86"
  15. fingerprint deviceId: "0x2101", inClusters: "0x71,0x70,0x85,0x80,0x72,0x31,0x84,0x86"
  16. }
  17.  
  18. simulator {
  19. status "dry": "command: 7105, payload: 00 00 00 FF 05 FE 00 00"
  20. status "wet": "command: 7105, payload: 00 FF 00 FF 05 02 00 00"
  21. status "overheated": "command: 7105, payload: 00 00 00 FF 04 02 00 00"
  22. status "freezing": "command: 7105, payload: 00 00 00 FF 04 05 00 00"
  23. status "normal": "command: 7105, payload: 00 00 00 FF 04 FE 00 00"
  24. for (int i = 0; i <= 100; i += 20) {
  25. status "battery ${i}%": new physicalgraph.zwave.Zwave().batteryV1.batteryReport(batteryLevel: i).incomingMessage()
  26. }
  27. }
  28. tiles {
  29. standardTile("water", "device.water", width: 2, height: 2) {
  30. state "dry", icon:"st.alarm.water.dry", backgroundColor:"#ffffff"
  31. state "wet", icon:"st.alarm.water.wet", backgroundColor:"#53a7c0"
  32. }
  33. standardTile("temperature", "device.temperature", width: 2, height: 2) {
  34. state "normal", icon:"st.alarm.temperature.normal", backgroundColor:"#ffffff"
  35. state "freezing", icon:"st.alarm.temperature.freeze", backgroundColor:"#53a7c0"
  36. state "overheated", icon:"st.alarm.temperature.overheat", backgroundColor:"#F80000"
  37. }
  38. standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat") {
  39. state "default", label:'', action:"refresh.refresh", icon:"st.secondary.refresh"
  40. }
  41. //standardTile("R2", "device.switch", inactiveLabel: false, decoration: "flat") {
  42. // state "default", label:'', action:"refresh.refresh", icon:"st.secondary.refresh"
  43. //}
  44.  
  45. valueTile("battery", "device.battery", decoration: "flat", inactiveLabel: false) {
  46. state "battery", label:'${currentValue}% battery', unit:""/*, backgroundColors:[
  47. [value: 5, color: "#BC2323"],
  48. [value: 10, color: "#D04E00"],
  49. [value: 15, color: "#F1D801"],
  50. [value: 16, color: "#FFFFFF"]
  51. ]*/
  52. }
  53. valueTile("temp", "device.temp", inactiveLabel: false) {
  54. state "temp", label:'${currentValue}°'
  55. }
  56. main (["water", "temperature", "temp"])
  57. details(["water", "temperature", "battery", "refresh", "temp"])
  58. }
  59. }
  60.  
  61. def refresh() {
  62. //zwave.wakeUpV2.wakeUpIntervalSet(seconds:4 * 3600, nodeid:zwaveHubNodeId).format()
  63. log.debug "Requesting temperature"
  64. delayBetween([
  65. zwave.sensormultilevelv1.SensorMultilevelGet().format()
  66. ])
  67. //log.debug "Sent wakeup config command for ${zwaveHubNodeId}"
  68. log.debug "Requested temperature for ${zwaveHubNodeId}"
  69. }
  70.  
  71. def parse(String description) {
  72.  
  73. def parsedZwEvent = zwave.parse(description, [0x30: 1, 0x71: 2, 0x84: 1, 0x31: 2])
  74. def zwEvent = zwaveEvent(parsedZwEvent)
  75. def result = []
  76.  
  77. log.debug "Parser description ${description}"
  78.  
  79.  
  80. result << createEvent( zwEvent )
  81.  
  82. if( parsedZwEvent.CMD == "8407" ) {
  83. if (!state.lastbatt || (new Date().time) - state.lastbatt > 24*60*60*1000) {
  84. result << response(zwave.batteryV1.batteryGet())
  85. result << response("delay 1200") // leave time for device to respond to batteryGet
  86. }
  87. result << response(zwave.wakeUpV1.wakeUpNoMoreInformation())
  88. //batt
  89. /*
  90. def lastStatus = device.currentState("battery")
  91. def ageInMinutes = lastStatus ? (new Date().time - lastStatus.date.time)/60000 : 600
  92. log.debug "Battery status was last checked ${ageInMinutes} minutes ago"
  93.  
  94. if (ageInMinutes >= 600) {
  95. log.debug "Battery status is outdated, requesting battery report"
  96. result << new physicalgraph.device.HubAction(zwave.batteryV1.batteryGet().format())
  97. //?device.currentState("battery") = new Date().time;
  98. }
  99.  
  100. result << new physicalgraph.device.HubAction(zwave.wakeUpV1.wakeUpNoMoreInformation().format())
  101. */
  102. }
  103.  
  104. log.debug "Parse returned ${result}"
  105. return result
  106. }
  107. def zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv2.SensorMultilevelReport cmd)
  108. {
  109. def map = [:]
  110. switch (cmd.sensorType) {
  111. case 1:
  112. // temperature
  113. def cmdScale = cmd.scale == 1 ? "F" : "C"
  114. map.value = convertTemperatureIfNeeded(cmd.scaledSensorValue, cmdScale, cmd.precision)
  115. map.unit = getTemperatureScale()
  116. map.name = "temp"
  117. break;
  118. //log.debug "Got temperature: $map.value"
  119. }
  120. map
  121. }
  122.  
  123. def zwaveEvent(physicalgraph.zwave.commands.wakeupv1.WakeUpNotification cmd)
  124. {
  125. [descriptionText: "${device.displayName} woke up", isStateChange: false]
  126. }
  127.  
  128. def zwaveEvent(physicalgraph.zwave.commands.sensorbinaryv1.SensorBinaryReport cmd)
  129. {
  130. def map = [:]
  131. map.name = "water"
  132. map.value = cmd.sensorValue ? "wet" : "dry"
  133. map.descriptionText = "${device.displayName} is ${map.value}"
  134. map
  135. }
  136.  
  137. def zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {
  138. def map = [:]
  139. if(cmd.batteryLevel == 0xFF) {
  140. map.name = "battery"
  141. map.value = 1
  142. map.descriptionText = "${device.displayName} has a low battery"
  143. map.displayed = true
  144. } else {
  145. map.name = "battery"
  146. map.value = cmd.batteryLevel > 0 ? cmd.batteryLevel.toString() : 1
  147. map.unit = "%"
  148. map.displayed = false
  149. }
  150. //batt
  151. state.lastbatt = new Date().time
  152.  
  153. map
  154. }
  155.  
  156. def zwaveEvent(physicalgraph.zwave.commands.alarmv2.AlarmReport cmd)
  157. {
  158. def map = [:]
  159. if (cmd.zwaveAlarmType == physicalgraph.zwave.commands.alarmv2.AlarmReport.ZWAVE_ALARM_TYPE_WATER) {
  160. map.name = "water"
  161. map.value = cmd.alarmLevel ? "wet" : "dry"
  162. map.descriptionText = "${device.displayName} is ${map.value}"
  163. }
  164. if(cmd.zwaveAlarmType == physicalgraph.zwave.commands.alarmv2.AlarmReport.ZWAVE_ALARM_TYPE_HEAT) {
  165. map.name = "temperature"
  166. if(cmd.zwaveAlarmEvent == 1) { map.value = "overheated"}
  167. if(cmd.zwaveAlarmEvent == 2) { map.value = "overheated"}
  168. if(cmd.zwaveAlarmEvent == 3) { map.value = "changing temperature rapidly"}
  169. if(cmd.zwaveAlarmEvent == 4) { map.value = "changing temperature rapidly"}
  170. if(cmd.zwaveAlarmEvent == 5) { map.value = "freezing"}
  171. if(cmd.zwaveAlarmEvent == 6) { map.value = "freezing"}
  172. if(cmd.zwaveAlarmEvent == 254) { map.value = "normal"}
  173. map.descriptionText = "${device.displayName} is ${map.value}"
  174. }
  175.  
  176. map
  177. }
  178.  
  179. def zwaveEvent(physicalgraph.zwave.Command cmd)
  180. {
  181. log.debug "COMMAND CLASS: $cmd"
  182. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement