Last active
October 24, 2018 01:56
-
-
Save mckeed/88b2560b22f9d56d2cf2 to your computer and use it in GitHub Desktop.
Aeon Siren w/sound commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Aeon Siren with Sound Commands + revert to default | |
* | |
* Author: SmartThings | |
* Date: 2014-07-15 | |
*/ | |
metadata { | |
definition (name: "Aeon Siren", namespace: "smartthings", author: "SmartThings") { | |
capability "Actuator" | |
capability "Alarm" | |
capability "Switch" | |
command "test" | |
command "sound1" | |
command "sound2" | |
command "sound3" | |
command "sound4" | |
command "sound5" | |
fingerprint deviceId: "0x1005", inClusters: "0x5E,0x98" | |
} | |
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 { | |
standardTile("alarm", "device.alarm", width: 2, height: 2) { | |
state "off", label:'off', action:'alarm.siren', icon:"st.alarm.alarm.alarm", backgroundColor:"#ffffff" | |
state "both", label:'alarm!', action:'alarm.off', icon:"st.alarm.alarm.alarm", backgroundColor:"#e86d13" | |
} | |
standardTile("test", "device.alarm", inactiveLabel: false, decoration: "flat") { | |
state "default", label:'', action:"test", icon:"st.secondary.test" | |
} | |
standardTile("off", "device.alarm", inactiveLabel: false, decoration: "flat") { | |
state "default", label:'', action:"alarm.off", icon:"st.secondary.off" | |
} | |
preferences { | |
input "sound", "number", title: "Siren sound (1-5)", defaultValue: 1, required: true//, displayDuringSetup: true // don't display during setup until defaultValue is shown | |
input "volume", "number", title: "Volume (1-3)", defaultValue: 3, required: true//, displayDuringSetup: true | |
} | |
main "alarm" | |
details(["alarm", "test", "off"]) | |
} | |
} | |
def updated() { | |
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 | |
return response([ | |
secure(zwave.configurationV1.configurationSet(parameterNumber: 37, size: 2, configurationValue: [sound, volume])), | |
"delay 1000", | |
secure(zwave.basicV1.basicSet(value: 0x00)), | |
]) | |
} | |
} | |
def parse(String description) { | |
log.debug "parse($description)" | |
def result = null | |
if (description.startsWith("Err")) { | |
result = createEvent( | |
descriptionText: "This sensor failed to complete the network security key exchange. If it is not responding properly, you must remove it from your network and add it again.", | |
eventType: "ALERT", | |
name: "secureInclusion", | |
value: "failed", | |
isStateChange: 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() { | |
state.sound = (settings.sound as Short) ?: 1 | |
state.volume = (settings.volume as Short) ?: 3 | |
log.debug "sending on" | |
[ | |
secure(zwave.configurationV1.configurationSet(parameterNumber: 37, size: 2, configurationValue: [state.sound, state.volume])), | |
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 test() { | |
on() + ["delay 3000"] + off() | |
} | |
def soundN(n) { | |
state.sound = n | |
secure(zwave.configurationV1.configurationSet(parameterNumber: 37, size: 2, configurationValue: [n, state.volume])) | |
} | |
def sound1() { soundN(1) } | |
def sound2() { soundN(2) } | |
def sound3() { soundN(3) } | |
def sound4() { soundN(4) } | |
def sound5() { soundN(5) } | |
private secure(physicalgraph.zwave.Command cmd) { | |
zwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format() | |
} |
@mckeed I tried to install this as a new SmartApp and pasted the code above in the code section and clicked create and got the following error..What am I doing wrong?
No signature of method: script1444234401525542200829.metadata() is applicable for argument types: (script1444234401525542200829$_run_closure1) values: [script1444234401525542200829$_run_closure1@75a52f2c] Possible solutions: getMetadata(), getState(), setState(java.lang.Object), metaClass(groovy.lang.Closure)
Can someone please create a protocol byte stream trace and add it to this post with a set sound and volume action. I try to create a PHP library to support this device. Still did succeed to configuration the device correct :(
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice. What amount of volume control can one get? Can it be used as a chime? I.e., non - startling