Guest User

Modded Aeon Siren DH for D-Link DCH-Z510

a guest
Feb 26th, 2018
610
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.64 KB | None | 0 0
  1. /**
  2. * Copyright 2015 SmartThings, Modded by Knackrack615
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  5. * in compliance with the License. You may obtain a copy of the License at:
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
  10. * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
  11. * for the specific language governing permissions and limitations under the License.
  12. *
  13. * Aeon Siren
  14. *
  15. * Author: SmartThings
  16. * Date: 2014-07-15
  17. */
  18. metadata {
  19. definition (name: "Aeon Siren (Modded for Dlink DCH-Z510)", namespace: "smartthings", author: "SmartThings", ocfDeviceType: "x.com.st.d.sensor.smoke") {
  20. capability "Actuator"
  21. capability "Alarm"
  22. capability "Switch"
  23. capability "Health Check"
  24.  
  25. command "FireAlarm"
  26. command "Ambulance"
  27. command "PoliceCar"
  28. command "DoorChime"
  29. command "BeepCode"
  30.  
  31. fingerprint deviceId: "0x1005", inClusters: "0x5E,0x98", deviceJoinName: "Aeotec Siren (Gen 5)"
  32. }
  33.  
  34. simulator {
  35. // reply messages
  36. reply "9881002001FF,9881002002": "command: 9881, payload: 002003FF"
  37. reply "988100200100,9881002002": "command: 9881, payload: 00200300"
  38. reply "9881002001FF,delay 3000,988100200100,9881002002": "command: 9881, payload: 00200300"
  39. }
  40.  
  41. tiles(scale: 2) {
  42. multiAttributeTile(name:"alarm", type: "generic", width: 6, height: 4){
  43. tileAttribute ("device.alarm", key: "PRIMARY_CONTROL") {
  44. attributeState "off", label:'off', action:'alarm.siren', icon:"st.alarm.alarm.alarm", backgroundColor:"#ffffff"
  45. attributeState "both", label:'alarm!', action:'alarm.off', icon:"st.alarm.alarm.alarm", backgroundColor:"#e86d13"
  46. }
  47. }
  48. standardTile("FireAlarm", "device.button", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
  49. state "default", label:'Fire Alarm', action:"FireAlarm", icon:"st.Outdoor.outdoor10"
  50. }
  51. standardTile("Ambulance", "device.button", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
  52. state "default", label:'Ambulance', action:"Ambulance", icon:"st.Transportation.transportation2"
  53. }
  54. standardTile("PoliceCar", "device.button", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
  55. state "default", label:'Police Car', action:"PoliceCar", icon:"st.Transportation.transportation8"
  56. }
  57. standardTile("DoorChime", "device.button", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
  58. state "default", label:'Door Chime', action:"DoorChime", icon:"st.Home.home30"
  59. }
  60. standardTile("BeepCode", "device.button", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
  61. state "default", label:'Beep Code', action:"BeepCode", icon:"st.secondary.test"
  62. }
  63. standardTile("off", "device.alarm", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
  64. state "default", label:'Off', action:"alarm.off", icon:"st.secondary.off"
  65. }
  66.  
  67. preferences {
  68. // PROB-1673 Since there is a bug with how defaultValue and range are handled together, we won't rely on defaultValue and won't set required, but will use the default values in the code below when needed.
  69. input "sound", "number", title: "Siren sound (1-5)", range: "1..5" //, defaultValue: 1, required: true//, displayDuringSetup: true // don't display during setup until defaultValue is shown
  70. input "volume", "number", title: "Volume (1-3)", range: "1..3" //, defaultValue: 3, required: true//, displayDuringSetup: true
  71. }
  72.  
  73. main "alarm"
  74. details(["alarm", "FireAlarm", "Ambulance", "PoliceCar", "DoorChime", "BeepCode", "off"])
  75. }
  76. }
  77.  
  78. def installed() {
  79. // Device-Watch simply pings if no device events received for 32min(checkInterval)
  80. sendEvent(name: "checkInterval", value: 2 * 15 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID, offlinePingable: "1"])
  81.  
  82. // Get default values and set device to send us an update when alarm state changes from device
  83. response([secure(zwave.basicV1.basicGet()), secure(zwave.configurationV1.configurationSet(parameterNumber: 80, size: 1, configurationValue: [2]))])
  84. }
  85.  
  86. def updated() {
  87. def commands = []
  88. // Device-Watch simply pings if no device events received for 32min(checkInterval)
  89. sendEvent(name: "checkInterval", value: 2 * 15 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID, offlinePingable: "1"])
  90.  
  91. if(!state.sound) state.sound = 1
  92. if(!state.volume) state.volume = 3
  93.  
  94. log.debug "settings: ${settings.inspect()}, state: ${state.inspect()}"
  95.  
  96. Short sound = (settings.sound as Short) ?: 1
  97. Short volume = (settings.volume as Short) ?: 3
  98.  
  99. if (sound != state.sound || volume != state.volume) {
  100. state.sound = sound
  101. state.volume = volume
  102. commands << secure(zwave.configurationV1.configurationSet(parameterNumber: 37, size: 2, configurationValue: [sound, volume]))
  103. commands << "delay 1000"
  104. commands << secure(zwave.basicV1.basicSet(value: 0x00))
  105. }
  106.  
  107. // Set device to send us an update when alarm state changes from device
  108. commands << secure(zwave.configurationV1.configurationSet(parameterNumber: 80, size: 1, configurationValue: [2]))
  109.  
  110. response(commands)
  111. }
  112.  
  113. def parse(String description) {
  114. log.debug "parse($description)"
  115. def result = null
  116. if (description.startsWith("Err")) {
  117. if (state.sec) {
  118. result = createEvent(descriptionText:description, displayed:false)
  119. } else {
  120. result = createEvent(
  121. descriptionText: "This device failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.",
  122. eventType: "ALERT",
  123. name: "secureInclusion",
  124. value: "failed",
  125. displayed: true,
  126. )
  127. }
  128. } else {
  129. def cmd = zwave.parse(description, [0x98: 1, 0x20: 1, 0x70: 1])
  130. if (cmd) {
  131. result = zwaveEvent(cmd)
  132. }
  133. }
  134. log.debug "Parse returned ${result?.inspect()}"
  135. return result
  136. }
  137.  
  138. def zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {
  139. def encapsulatedCommand = cmd.encapsulatedCommand([0x20: 1, 0x85: 2, 0x70: 1])
  140. // log.debug "encapsulated: $encapsulatedCommand"
  141. if (encapsulatedCommand) {
  142. zwaveEvent(encapsulatedCommand)
  143. }
  144. }
  145.  
  146. def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {
  147. log.debug "rx $cmd"
  148. [
  149. createEvent([name: "switch", value: cmd.value ? "on" : "off", displayed: false]),
  150. createEvent([name: "alarm", value: cmd.value ? "both" : "off"])
  151. ]
  152. }
  153.  
  154. def zwaveEvent(physicalgraph.zwave.Command cmd) {
  155. createEvent(displayed: false, descriptionText: "$device.displayName: $cmd")
  156. }
  157.  
  158. def on() {
  159. log.debug "sending on"
  160. [
  161. secure(zwave.basicV1.basicSet(value: 0xFF)),
  162. secure(zwave.basicV1.basicGet())
  163. ]
  164. }
  165.  
  166. def off() {
  167. log.debug "sending off"
  168. [
  169. secure(zwave.basicV1.basicSet(value: 0x00)),
  170. secure(zwave.basicV1.basicGet())
  171. ]
  172. }
  173.  
  174. def strobe() {
  175. on()
  176. }
  177.  
  178. def siren() {
  179. on()
  180. }
  181.  
  182. def both() {
  183. on()
  184. }
  185.  
  186. def FireAlarm() {
  187. log.debug "Sounding Siren With Fire Alarm"
  188. [
  189. secure(zwave.notificationV3.notificationReport(event: 0x02, notificationType: 0x0A)),
  190. secure(zwave.basicV1.basicGet())
  191. ]
  192. }
  193.  
  194. def Ambulance() {
  195. log.debug "Sounding Siren With Ambulance"
  196. [
  197. secure(zwave.notificationV3.notificationReport(event: 0x03, notificationType: 0x0A)),
  198. secure(zwave.basicV1.basicGet())
  199. ]
  200. }
  201.  
  202. def PoliceCar() {
  203. log.debug "Sounding Siren With Police Car"
  204. [
  205. secure(zwave.notificationV3.notificationReport(event: 0x01, notificationType: 0x0A)),
  206. secure(zwave.basicV1.basicGet())
  207. ]
  208. }
  209.  
  210. def DoorChime() {
  211. log.debug "Sounding Siren With Door Chime"
  212. [
  213. secure(zwave.notificationV3.notificationReport(event: 0x16, notificationType: 0x06)),
  214. secure(zwave.basicV1.basicGet())
  215. ]
  216. }
  217.  
  218. def BeepCode() {
  219. log.debug "Sounding Siren With Door Chime"
  220. [
  221. secure(zwave.notificationV3.notificationReport(event: 0x16, notificationType: 0x06)),
  222. "delay 600",
  223. secure(zwave.basicV1.basicSet(value: 0x00)),
  224. secure(zwave.notificationV3.notificationReport(event: 0x16, notificationType: 0x06)),
  225. "delay 600",
  226. secure(zwave.basicV1.basicSet(value: 0x00)),
  227. secure(zwave.notificationV3.notificationReport(event: 0x16, notificationType: 0x06)),
  228. "delay 600",
  229. secure(zwave.basicV1.basicSet(value: 0x00)),
  230. secure(zwave.basicV1.basicGet())
  231. ]
  232. }
  233.  
  234. private secure(physicalgraph.zwave.Command cmd) {
  235. zwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()
  236. }
  237.  
  238. /**
  239. * PING is used by Device-Watch in attempt to reach the Device
  240. * */
  241. def ping() {
  242. secure(zwave.basicV1.basicGet())
  243. }
Advertisement
Add Comment
Please, Sign In to add comment