Linear Z-wave Siren device type needed

Thanks the fix works

Thanks for the new device handler. I was interested in disabling the strobe light (I have my siren hidden) so that it could not be easily found on the off chance someone did break into the house. This did the trick.

I updated the handler to V4 and added Kevin’s fix to the siren time from a few days ago. However, I haven’t changed the battery routine, as mine still seems to be working without hongning’s line edit. Can someone confirm if their battery reporting is working fine with the original v3 or this new v4 code? Mine seems happy, but I almost never set the siren off so it is still reporting 100% battery. I’m testing this on a v1 hub (have a v2 hub on the way…better late than never)

/**
 *  Linear Zwave Siren v4
 *
 *  Copyright 2015 Kevin Tierney     *
 *  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.
 *  Author: Kevin Tierney
 *  Date: 2015-07-30
 *  Updates by: Mike Wilson
 *  Date: 2016-03-30
 */
metadata {
	definition (name: "Linear Z-Wave Siren v4", namespace: "tierneykev", author: "Kevin Tierney") {
		capability "Actuator"
        capability "Alarm"
        capability "Battery"
        capability "Polling"
        capability "Refresh"
        capability "Sensor"
		capability "Switch"
        command "setstrobe"
        command "setsiren"
        command "setboth"
        //Supported Command Classes
    //0x20-Basic ,0x25-Binary Switch ,0x70-Configuration , 0x72-Manufacturer Specific ,0x86-Version
//        fingerprint inClusters: "0x20,0x25,0x70,0x72,0x86"
         fingerprint deviceId:"0x1000", inClusters: "0x25,0x70,0x72,0x80,0x86"
//         0 0 0x1000 0 0 0 4 0x25 0x70 0x72 0x86
	}
	simulator {
		// reply messages
		reply "2001FF,2002": "command: 2002, payload: FF"
		reply "200100,2002": "command: 2002, payload: 00"
		reply "200121,2002": "command: 2002, payload: 21"
		reply "200142,2002": "command: 2002, payload: 42"
		reply "2001FF,delay 3000,200100,2002": "command: 2002, payload: 00"
	}
    tiles {
	standardTile("alarm", "device.alarm", width: 2, height: 2) {
    log.debug "Adjusting alarm state"
       
        state "both", label:'alarm!', action:'alarm.setsiren', icon:"st.alarm.alarm.alarm", backgroundColor:"#e86d13"
        state "siren", label:'siren!', action:'alarm.setstrobe', icon:"st.alarm.alarm.alarm", backgroundColor:"#e86d13"
        state "strobe", label:'strobe!', action:'alarm.setboth', icon:"st.alarm.alarm.alarm", backgroundColor:"#e86d13"						
	}
        standardTile("off", "device.alarm", inactiveLabel: false, decoration: "flat") {
 			state "default", label:'Off', action:"off"
        } 
        standardTile("on", "device.alarm", inactiveLabel: false, decoration: "flat") {
 			state "default", label:'On', action:"on"
        } 
        valueTile("battery", "device.battery", inactiveLabel: false, decoration: "flat") { 
			state "battery", label:'${currentValue}% battery', unit:""
		}
        standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat") {
			state "default", label:'', action:"refresh.refresh", icon:"st.secondary.refresh"
		}
       
	main "alarm"
    details(["alarm","off","on","battery","refresh"])
}

preferences {
	input "autoStopTime", "enum", title: "Disarm Time",required:true,displayDuringSetup:true, options: ["30","60","120","Infinite"],default:'30'
}
}
def updated() {
		def autoStopTimeParameter = 0
        if (autoStopTime == '30') {
        	autoStopTimeParameter = 0
        } else if( autoStopTime == '60'){
        	autoStopTimeParameter = 1
        } else if (autoStopTime == '120') {
        	autoStopTimeParameter = 2
        } else if (autoStopTime == 'Infinite') {
        	autoStopTimeParameter = 3
        }
        log.debug "AutoStopTime - ${autoStopTimeParameter}"
	    response([zwave.configurationV1.configurationSet(parameterNumber: 1, size: 1, scaledConfigurationValue: autoStopTimeParameter.toInteger()).format()])
}
//println org.codehaus.groovy.runtime.InvokerHelper.getVersion()



def setstrobe() {
	log.debug "Setting alarm to strobe."
    state.LastAlarmtype = 2
    sendEvent(name: "alarm", value: "strobe")
    zwave.configurationV1.configurationSet(parameterNumber: 0, size: 1, configurationValue: [2]).format()
     
}
def setsiren() {
    log.debug "Setting alarm to siren."
    state.LastAlarmtype = 1
   sendEvent(name: "alarm", value: "siren")
   zwave.configurationV1.configurationSet(parameterNumber: 0, size: 1, configurationValue: [1]).format()
     
}
def setboth() {
	log.debug "Setting alarm to both."
    state.LastAlarmtype = 0
    sendEvent(name: "alarm", value: "both")
	zwave.configurationV1.configurationSet(parameterNumber: 0, size: 1, configurationValue: [0]).format()
 
     
}


def off() {
	log.debug "sending off"
	[
		zwave.basicV1.basicSet(value: 0x00).format(),
		zwave.basicV1.basicGet().format()
	]
}
def on() {
	log.debug "sending on"
	[
		zwave.basicV1.basicSet(value: 0xff).format(),
		zwave.basicV1.basicGet().format()
	]
}

def both() {
	log.debug "sending alarm on via both"
	[
		zwave.basicV1.basicSet(value: 0xff).format(),
		zwave.basicV1.basicGet().format()
	]
}

def parse(String description) {
    def result = null
def cmd = zwave.parse(description)
log.debug "parse($description) - command is $cmd"
if (cmd) {
	result = createEvents(cmd)
}
log.debug "Parse returned ${result?.descriptionText}"
return result
}
def createEvents(physicalgraph.zwave.commands.basicv1.BasicReport cmd)
{
	log.debug "createEvents with cmd value {$cmd.value}, LastAlarmtype: $state.LastAlarmtype"
	def switchValue = cmd.value ? "on" : "off"
	def alarmValue 
	if (state.LastAlarmtype == 0) {
		alarmValue = "both"
	}
	else if (state.LastAlarmtype == 2) {
		alarmValue = "strobe"
	}
	else if (state.LastAlarmtype == 1) {
		alarmValue = "siren"
	}
	else {
		alarmValue = "off"
	}
	[
		createEvent([name: "switch", value: switchValue, type: "digital", displayed: false]),
		createEvent([name: "alarm", value: alarmValue, type: "digital"])
	]
}
def createEvents(physicalgraph.zwave.Command cmd) {
	log.warn "UNEXPECTED COMMAND: $cmd"
}
def zwaveEvent(physicalgraph.zwave.commands.wakeupv1.WakeUpNotification cmd)
{
	def result = [createEvent(descriptionText: "${device.displayName} woke up", isStateChange: false)]
	if (!state.lastbat || (new Date().time) - state.lastbat > 53*60*60*1000) {
		result << response(zwave.batteryV1.batteryGet())
		result << response("delay 1200")
	}
	result << response(zwave.wakeUpV1.wakeUpNoMoreInformation())
	result
}
def createEvents(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {
	def map = [ name: "battery", unit: "%" ]
	if (cmd.batteryLevel == 0xFF) {
		map.value = 1
		map.descriptionText = "$device.displayName has a low battery"
		map.isStateChange = true
	} else {
		map.value = cmd.batteryLevel
	}
	state.lastbatt = new Date().time
	[createEvent(map), response(zwave.wakeUpV1.wakeUpNoMoreInformation())]
}
def createEvents(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd)
{
    log.debug "CONFIGURATIONREPORT"
}
def poll() {
	if (secondsPast(state.lastbatt, 36*60*60)) {
		return zwave.batteryV1.batteryGet().format()
	} else {
		return null
	}
}
private Boolean secondsPast(timestamp, seconds) {
	if (!(timestamp instanceof Number)) {
		if (timestamp instanceof Date) {
			timestamp = timestamp.time
		} else if ((timestamp instanceof String) && timestamp.isNumber()) {
			timestamp = timestamp.toLong()
		} else {
			return true
		}
	}
	return (new Date().time - timestamp) > (seconds * 1000)
}
def refresh() {
	log.debug "sending battery refresh command"
	zwave.batteryV1.batteryGet().format()
}
2 Likes

Battery report was fine for me on V3

Thanks, good to hear.

I installed version 4 but now from within the app (things–>Alarm) i can’t change the setting from Alarm to Both or to Strobe. It was working ok with v3.

I have a GoControl ZM1601US I read that this handler it’s good for this model. But I can’t see the battery % or any option for selecting the light or siren control. Any advice or some other customers device handler?

Interesting Ammar…you are correct. V4 broke that toggle function. Guess I’ll take a look.

Edit: took a look…not really sure why V4 does this. Tried a number of work arounds.

One thing I never tested: did v4 actually change the alarm time? I can’t test right now (family at home…not amused with alarms going off). If I run live logging, v3 and v4 both seem to change the alarm time correctly.

awesome, will wait for a reply to test out the new version with fix once it is ready

Forgot to update, timer looks ok to me in my two tests in v4 so thanks for that
While you are it (I think it’s Christmas), I have Smartrulesapp also running separately and was trying to setup some thing with the Linear Siren to work in this way.
Upon any intrusion from any door/window or motion sensor, set a command to Linear siren to go to Strobe, start strobe for 30 seconds and then switch to Both (Siren + Strobe).
Some how i see that we are unable to change the setting to Strobe from smartrulesapp to make it strobe. It works if I go to smartthings app, under things, go to LinearV4, set to Strobe and then trigger from smartrules. That defeats the purpose of what I am trying to do.
To summarize, here is the requirement: Enabler Linear to talk to Smartrules to change modes, currently it switches on and off no problem but mode changes (Alarm, Both, Siren, Strobe etc) are not working

Hi Ammar…someone else will have to investigate your scenario. I pieced together the basic device handler, but I’m a basic coder at best and this is the only handler I’ve done. I’m just trying to figure out why v4 breaks the strobe/siren/alarm toggle. I did also check the timer…yeah, works correctly in v4, but not v3.

Does any one knows if this siren can act as chime? for example. When some door / window open make a 1 sec bip just like an ADT alarm

Hi Victor…this siren only has a “siren” sound…even if it is turned on for a second, it would be the siren (not a pleasant chime).

Quick note for folks following this thread: I’m working to fix the v4 handler…got it narrowed down but need to test it. In the meantime I’d recommend using v3 (even though the time duration function defaults to 30 secs only).

However, in the future I may redesign the handler. If I do this, I might start a new thread since I would change the look also. I’ll keep everyone posted.

2 Likes

Thanks. I appreciate all of your work on this!

2 Likes

Hey folks…I’m not sure if you’ve noticed or not, but another member of the community, Kevin LaFramboise, has created a new handler to cover this siren and other generic sirens. His handler has many options not available in mine, plus it follows the normal convention of alarm status (ie the main icon/tile shows status…not config). I’d highly suggest you take it for a test drive…it’s really nice.

Since Kevin’s device is more functional than mine, I probably won’t make any further updates. I do have a version 5 that fixes the problems in V3 (timer doesn’t work right) and V4 (config tile stopped working) that I can post…but I’d rather you take a look at Kevin’s first. BTW…Kevin, thanks for the help and the nice handler!

2 Likes

Thanks a bunch! I have used your v3 since I purchased my (2) sirens from Staples a few months ago… I appreciate you taking the time to help and thanks for the link to the updated handler from Kevin!

1 Like

This is awesome. Thank you for contributing to help everyone else. One question… How did you get it into test mode like that? :smiley:

Ok sorry 2 questions…

My motion sensor isn’t showing battery %… is this something you mentioned could take 4hrs to update?

Thanks!

If you use the latest handler from Kevin, there are “test” buttons for each mode in the mobile GUI.

My experience has been that some battery % take a while. And for the motion sensors that came with this kit…mine never showed battery (and still don’t). Not sure why, but I’ve never bothered to investigate.

Thanks to you I now have battery backup!