Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Copyright 2015 SmartThings, Modded by Knackrack615
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
- * for the specific language governing permissions and limitations under the License.
- *
- * Aeon Siren
- *
- * Author: SmartThings
- * Date: 2014-07-15
- */
- metadata {
- definition (name: "Aeon Siren (Modded for Dlink DCH-Z510)", namespace: "smartthings", author: "SmartThings", ocfDeviceType: "x.com.st.d.sensor.smoke") {
- capability "Actuator"
- capability "Alarm"
- capability "Switch"
- capability "Health Check"
- command "FireAlarm"
- command "Ambulance"
- command "PoliceCar"
- command "DoorChime"
- command "BeepCode"
- fingerprint deviceId: "0x1005", inClusters: "0x5E,0x98", deviceJoinName: "Aeotec Siren (Gen 5)"
- }
- simulator {
- // reply messages
- reply "9881002001FF,9881002002": "command: 9881, payload: 002003FF"
- reply "988100200100,9881002002": "command: 9881, payload: 00200300"
- reply "9881002001FF,delay 3000,988100200100,9881002002": "command: 9881, payload: 00200300"
- }
- tiles(scale: 2) {
- multiAttributeTile(name:"alarm", type: "generic", width: 6, height: 4){
- tileAttribute ("device.alarm", key: "PRIMARY_CONTROL") {
- attributeState "off", label:'off', action:'alarm.siren', icon:"st.alarm.alarm.alarm", backgroundColor:"#ffffff"
- attributeState "both", label:'alarm!', action:'alarm.off', icon:"st.alarm.alarm.alarm", backgroundColor:"#e86d13"
- }
- }
- standardTile("FireAlarm", "device.button", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
- state "default", label:'Fire Alarm', action:"FireAlarm", icon:"st.Outdoor.outdoor10"
- }
- standardTile("Ambulance", "device.button", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
- state "default", label:'Ambulance', action:"Ambulance", icon:"st.Transportation.transportation2"
- }
- standardTile("PoliceCar", "device.button", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
- state "default", label:'Police Car', action:"PoliceCar", icon:"st.Transportation.transportation8"
- }
- standardTile("DoorChime", "device.button", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
- state "default", label:'Door Chime', action:"DoorChime", icon:"st.Home.home30"
- }
- standardTile("BeepCode", "device.button", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
- state "default", label:'Beep Code', action:"BeepCode", icon:"st.secondary.test"
- }
- standardTile("off", "device.alarm", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
- state "default", label:'Off', action:"alarm.off", icon:"st.secondary.off"
- }
- preferences {
- // 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.
- 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
- input "volume", "number", title: "Volume (1-3)", range: "1..3" //, defaultValue: 3, required: true//, displayDuringSetup: true
- }
- main "alarm"
- details(["alarm", "FireAlarm", "Ambulance", "PoliceCar", "DoorChime", "BeepCode", "off"])
- }
- }
- def installed() {
- // Device-Watch simply pings if no device events received for 32min(checkInterval)
- sendEvent(name: "checkInterval", value: 2 * 15 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID, offlinePingable: "1"])
- // Get default values and set device to send us an update when alarm state changes from device
- response([secure(zwave.basicV1.basicGet()), secure(zwave.configurationV1.configurationSet(parameterNumber: 80, size: 1, configurationValue: [2]))])
- }
- def updated() {
- def commands = []
- // Device-Watch simply pings if no device events received for 32min(checkInterval)
- sendEvent(name: "checkInterval", value: 2 * 15 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID, offlinePingable: "1"])
- if(!state.sound) state.sound = 1
- if(!state.volume) state.volume = 3
- log.debug "settings: ${settings.inspect()}, state: ${state.inspect()}"
- Short sound = (settings.sound as Short) ?: 1
- Short volume = (settings.volume as Short) ?: 3
- if (sound != state.sound || volume != state.volume) {
- state.sound = sound
- state.volume = volume
- commands << secure(zwave.configurationV1.configurationSet(parameterNumber: 37, size: 2, configurationValue: [sound, volume]))
- commands << "delay 1000"
- commands << secure(zwave.basicV1.basicSet(value: 0x00))
- }
- // Set device to send us an update when alarm state changes from device
- commands << secure(zwave.configurationV1.configurationSet(parameterNumber: 80, size: 1, configurationValue: [2]))
- response(commands)
- }
- def parse(String description) {
- log.debug "parse($description)"
- def result = null
- if (description.startsWith("Err")) {
- if (state.sec) {
- result = createEvent(descriptionText:description, displayed:false)
- } else {
- result = createEvent(
- 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.",
- eventType: "ALERT",
- name: "secureInclusion",
- value: "failed",
- displayed: true,
- )
- }
- } else {
- def cmd = zwave.parse(description, [0x98: 1, 0x20: 1, 0x70: 1])
- if (cmd) {
- result = zwaveEvent(cmd)
- }
- }
- log.debug "Parse returned ${result?.inspect()}"
- return result
- }
- def zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {
- def encapsulatedCommand = cmd.encapsulatedCommand([0x20: 1, 0x85: 2, 0x70: 1])
- // log.debug "encapsulated: $encapsulatedCommand"
- if (encapsulatedCommand) {
- zwaveEvent(encapsulatedCommand)
- }
- }
- def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {
- log.debug "rx $cmd"
- [
- createEvent([name: "switch", value: cmd.value ? "on" : "off", displayed: false]),
- createEvent([name: "alarm", value: cmd.value ? "both" : "off"])
- ]
- }
- def zwaveEvent(physicalgraph.zwave.Command cmd) {
- createEvent(displayed: false, descriptionText: "$device.displayName: $cmd")
- }
- def on() {
- log.debug "sending on"
- [
- secure(zwave.basicV1.basicSet(value: 0xFF)),
- secure(zwave.basicV1.basicGet())
- ]
- }
- def off() {
- log.debug "sending off"
- [
- secure(zwave.basicV1.basicSet(value: 0x00)),
- secure(zwave.basicV1.basicGet())
- ]
- }
- def strobe() {
- on()
- }
- def siren() {
- on()
- }
- def both() {
- on()
- }
- def FireAlarm() {
- log.debug "Sounding Siren With Fire Alarm"
- [
- secure(zwave.notificationV3.notificationReport(event: 0x02, notificationType: 0x0A)),
- secure(zwave.basicV1.basicGet())
- ]
- }
- def Ambulance() {
- log.debug "Sounding Siren With Ambulance"
- [
- secure(zwave.notificationV3.notificationReport(event: 0x03, notificationType: 0x0A)),
- secure(zwave.basicV1.basicGet())
- ]
- }
- def PoliceCar() {
- log.debug "Sounding Siren With Police Car"
- [
- secure(zwave.notificationV3.notificationReport(event: 0x01, notificationType: 0x0A)),
- secure(zwave.basicV1.basicGet())
- ]
- }
- def DoorChime() {
- log.debug "Sounding Siren With Door Chime"
- [
- secure(zwave.notificationV3.notificationReport(event: 0x16, notificationType: 0x06)),
- secure(zwave.basicV1.basicGet())
- ]
- }
- def BeepCode() {
- log.debug "Sounding Siren With Door Chime"
- [
- secure(zwave.notificationV3.notificationReport(event: 0x16, notificationType: 0x06)),
- "delay 600",
- secure(zwave.basicV1.basicSet(value: 0x00)),
- secure(zwave.notificationV3.notificationReport(event: 0x16, notificationType: 0x06)),
- "delay 600",
- secure(zwave.basicV1.basicSet(value: 0x00)),
- secure(zwave.notificationV3.notificationReport(event: 0x16, notificationType: 0x06)),
- "delay 600",
- secure(zwave.basicV1.basicSet(value: 0x00)),
- secure(zwave.basicV1.basicGet())
- ]
- }
- private secure(physicalgraph.zwave.Command cmd) {
- zwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()
- }
- /**
- * PING is used by Device-Watch in attempt to reach the Device
- * */
- def ping() {
- secure(zwave.basicV1.basicGet())
- }
Advertisement
Add Comment
Please, Sign In to add comment