Siren *beep* capability


(Eduardo Veras) #1

is there any zwave siren that suports a beep to be played during entry and exit delay for an alarm? im planing to use smartthings wiht smartAlarm and it would be very usefull to have a beep every second with the entry and exit delay :smile:


#2

I looked into this in April and did not find an alarm with this functionality. I bought a Fortrezz SSA-01 and tried to program the alarm to beep. There is no volume control for this alarm that I am aware of. What I ended up with was an alarm that chirps, at full volume, for 1250 ms. If I set the chirp interval any lower, the alarm fails to chip most of the time. At an interval of 1250ms the alarm chirps about 90% of the time. I use the beep to indicate that a countdown timer has started before the system switches to away mode.

private beepAlarm(numBeeps) {
def onFor = 1250
def offFor = 1250

log.debug "beeping $numFlashes times"
def delay = 1L
numBeeps.times {
	log.trace "alarm on after $delay msec"
	alarms?.both(delay: delay)
	delay += onFor
	log.trace "alarm off after $delay msec"
	alarms?.off(delay: delay)
	delay += offFor
   }
}

(Dylan R) #3

Trying to make this work with a linear siren but my coding skills are subpar. Is this function added to the device handler or a smartapp? If added to the device handler, am I correct to assume that I also need to add code to call the function from the UI?


#4

This was part of a SmartApp. You can call this function in response to some event.


(Dylan R) #5

Great, is that smart app available by chance?


#6

The app is a hack-up of someone elseโ€™s program.
I used an aeon mini-mote to set an away mode after playing short beep, blinking some lights and then waiting for some seconds. See line ~260 marked โ€œ//// see here ---- >>>>>>>>>>>>>โ€.

Hope this helps.

/**
 *  Aeon Minimote Controller
 *
 *  Copyright 2014 SmartThings
 *
 *  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.
 *
 */
 
definition(
    name: "Aeon Minimote Controller",
    namespace: "ST",
    author: "",
    description: "Control one or more Hue bulbs using an Aeon MiniMote.",
    category: "My Apps",
    iconUrl: "http://www.philips.co.jp/shared/assets/jp/SmallParagraphImage/ConsumerCare/hue_80x70.jpg",
    iconX2Url: "http://www.philips.co.jp/shared/assets/jp/SmallParagraphImage/ConsumerCare/hue_80x70.jpg",
    iconX3Url: "http://www.philips.co.jp/shared/assets/jp/SmallParagraphImage/ConsumerCare/hue_80x70.jpg")

preferences {
	section("Define Aeon Minimote for controlling lights") {
		input "controller", "capability.button", title: "Aeon Minimote"
	}
    section("Define Hue bulbs...") {
		input "hues", "capability.colorControl", title: "Hue light bulbs", multiple: true, required: false
	}
    section("Define bedroom lamp switches...") {
		input "lightSwitch", "capability.switch", title: "Bedroom Lamp Switch", multiple: true, required: false
	}    
    section("Define office light...") {
    	input "officeLights", "capability.switch", title: "Office Light Switch", multiple: true, required: false
    }
    section("Define office lamp switches...") {
    	input "officeLamps", "capability.switch", title: "Office Lamp Switch", multiple: true, required: false
    }
    section("Define fan switches...") {
    	input "fanSwitch", "capability.switch", title: "Fan Switch", multiple: false, required: false
    }    
    section("Define notification alarms...") {
    	input "alarms", "capability.alarm", title: "Which Alarm(s)", multiple: true, required: false
    }
}

def installed() {
	log.debug "Installed with settings: ${settings}"
	state.colorIndex = -1    
	initialize()
}

def updated() {
	log.debug "Updated with settings: ${settings}"
	unsubscribe()
	initialize()
}

def initialize() {
	subscribe controller, "button", buttonHandler
}

def buttonHandler(evt) {
	switch(evt.jsonData?.buttonNumber) {        
// button number 1 ***********************************************************************************
		case 1:
        	def hueSwitch = hues.currentValue("switch")
            log.debug "On current switch: ${hueSwitch}" 
        	if (evt.value != "held") {
                log.debug "button number: $evt.jsonData? button value: $evt.value"
    			if ("${location.mode}" == "NORMAL") {                
                    log.debug "mode is ${location.mode}"  	
                	if ("${hueSwitch}" != "[off, off]") {   
                    	log.debug "turn ON hues and lightswitch"
                    	// PRESSED
                        // NORMAL
                    	// ON
                        // turn hues OFF
                        log.debug "turn OFF hues and lightswitch"  	
                        hues.off()                        
                        lightSwitch.off()
                    }
                    else {
                    	log.debug "turn ON hues and lightswitch"
                    	// PRESSED
                        // NORMAL
                        // OFF
                        // turn all ON
                     	// hues on, daylight settings, level: 99
                        def color = [name:"Daylight", hue: 53, saturation: 91]
                		hues.setColor(hue: color.hue, saturation: color.saturation)  
                        hues.setLevel(99)
                        hues.on()
                        lightSwitch.on()
                    }
                }
				else {
					// if mode is NIGHT              		
              		log.debug "mode is ${location.mode}"
              		if ("${hueSwitch}" != "[off, off]") {   	
                    	// PRESSED 
                        // NIGHT
                    	// ON
                        // turn all lights OFF
                        log.debug "turn OFF hues and lightswitch"  	
                        def color = [name:"Red", hue: 100, saturation: 100]
                		hues.setColor(hue: color.hue, saturation: color.saturation)
                        hues.setLevel(20)
                        hues.off()
                        lightSwitch.off()
                    }
                    else {
						// PRESSED
						// NIGHT
                    	// OFF
                        // turn on hues only
                        // hues on, daylight settings, level: 10
                    	log.debug "turn on hues"
                        def color = [name:"Red", hue: 100, saturation: 100]
                		hues.setColor(hue: color.hue, saturation: color.saturation)
                        hues.setLevel(10)
                        hues.on()
                    }
                }
            }
 			else {
            	// button HOLD 
                log.debug "button number: $evt.jsonData?.buttonNumber; button value: $evt.value"
            	if ("${location.mode}" == "NORMAL") {
                // if mode is NORMAL
                	log.debug "mode is ${location.mode}"
                    if ("${hueSwitch}" != "[off, off]") {
                		// if status is ON
                        log.debug "hue switch is ${hueSwitch}"
                        	// HELD
                            // NORMAL
                            // ON
                        	// turn hues OFF, set default
                        	def color = [name:"Daylight", hue: 53, saturation: 91]
                			hues.setColor(hue: color.hue, saturation: color.saturation)
                        	hues.setLevel(99)
                            hues.off()
                            lightSwitch.off()
                    }
                    else {
    					log.debug "hue switch is ${hueSwitch}"
                    		// HELD
                            // NORMAL
                            // OFF
                            // turn all ON
                            def color = [name:"Daylight", hue: 53, saturation: 91]
                			hues.setColor(hue: color.hue, saturation: color.saturation)  
                            hues.setLevel(20)
                            hues.on()
                            lightSwitch.on()
                    }
                }
                else {
                // if mode is NIGHT
                log.debug "mode is ${location.mode}"
                	log.debug "mode is ${location.mode}"
                    if ("${hueSwitch}" != "[off, off]") {
                        log.debug "hue switch is ${hueSwitch}"
                			// HELD
                            // NIGHT
                            // ON
                        	// set warm white color settings, level: 40                            
                            def color = [name:"Warm White", hue: 20, saturation: 80]
                			hues.setColor(hue: color.hue, saturation: color.saturation)  
                            hues.setLevel(60)                            
                            hues.on()
                            lightSwitch.on()
                    }
                	else {
                        log.debug "hue switch is ${hueSwitch}"
                    		// HELD
                            // NIGHT
                            // OFF
            				// turn hues ON
                        	// turn hues on: red/orange settings, level: 99
                            def color = [name:"Red", hue: 100, saturation: 100]
                			hues.setColor(hue: color.hue, saturation: color.saturation)  
                            hues.setLevel(99)
                            hues.on()                            
                    }
                }      
            }
        	break


// button number 2 ***********************************************************************************
		case 2:
        	def GESwitch = officeLights.currentValue("switch")
        	if (evt.value != "held") {
            	// button press
                log.debug "button number: $evt.jsonData?.buttonNumber; button value: $evt.value"                
				if ("${GESwitch}" == "[off, off, off]") {
                	// PRESS
                	// turn on
					log.debug "${GESwitch}"	
					officeLights.setLevel(99)
                    officeLamps.on()
    			}
                else {
					// PRESS
                    // turn off
					log.debug "${GESwitch}"	
					officeLights.off()
                	officeLamps.off()
                }
            }
            else {
            	log.debug "button number: $evt.jsonData?.buttonNumber; button value: $evt.value"                
				if ("${GESwitch}" == "[off, off, off]") {
                	// HELD
                	// turn on
					log.debug "${GESwitch}"	
					officeLamps.off()
                    officeLights.setLevel(10)
    			}
                else {
					// HELD
                    // turn off
					log.debug "${GESwitch}"	
					officeLamps.off()
                	officeLights.setLevel(10)
                }
            }
        	break


// button number 3 ***********************************************************************************
        case 3:
        	log.debug "starting mode is ${location.mode}"
            if (evt.value != "held") {
            	// is button press
                log.debug "button number: $evt.jsonData?.buttonNumber; button value: $evt.value"                
                if ("${location.mode}" == "NORMAL") {
                	log.debug "switching from NORMAL mode to NIGHT mode ...1"
                	// PRESS
                    // NORMAL
                    // switch to NIGHT mode
                    // 
                    setLocationMode("NIGHT")
                    fanSwitch.on()
                }
                else if ("${location.mode}" == "NIGHT") {
                	log.debug "switching from NIGHT mode to NORMAL mode ...2"
                    // PRESS
                    // NIGHT
                    // swith to NORMAL mode
                    // 
                    setLocationMode("NORMAL")
                    fanSwitch.off()
                }
            }
            
//// see here ---- >>>>>>>>>>>>>
            else {
            	beepAlarm(1)
            	if ("${location.mode}" == "NORMAL") {
                	log.debug "switching from NORMAL mode to AWAY mode"
            		// HELD
                    // NORMAL
                    // pause for 10 seconds
                    // switch to AWAY mode
                    // 
                    
                    log.debug "pause 1"
                    // turn all off except office light
                    officeLamps.off()
                    fanSwitch.off()
                    officeLights.setLevel(50)
                    // pause 10 seconds
                    pause(10000)
                    officeLights.off()
                    pause(15000)
                    setLocationMode("AWAY")
                    log.debug "setting AWAY mode"
                }
                else if ("${location.mode}" == "NIGHT") {
                	log.debug "switching from NIGHT mode to AWAY mode"
                	// HELD
                    // NIGHT
                    // pause for 15 seconds
                    // switch to AWAY mode
                    // 
                    log.debug "pause 2"
                    fanSwitch.off()
                    officeLamps.off()
                    officeLights.setLevel(99)
                    for (ii in 0 .. 25) {
                    	officeLights.setLevel(100-(ii*4))
                    	pause(1000)
                    }
                    officeLights.off()
                    setLocationMode("AWAY")
                    log.debug "setting AWAY mode"
                }
            }
        	break


// button number 4 ***********************************************************************************
        case 4:
        	if (evt.value != "held") {
            	// button press
                log.debug "button number: $evt.jsonData?.buttonNumber; button value: $evt.value"
                fanSwitch.off()
                officeLights.off()
                officeLamps.off()
                hues.off()
                lightSwitch.off()
            }
            else {
            	// IF TIME IS 
				// START SUNSET
                // START SUNRISE

            }
        	break
        
        default:
        	// do nothing
        	break
    }
}

private beepAlarm(numBeeps) {
	def onFor = 1250
	def offFor = 1250

	log.debug "beeping $numFlashes times"
	def delay = 1L
	numBeeps.times {
		log.trace "alarm on after $delay msec"
		alarms?.both(delay: delay)
		delay += onFor
		log.trace "alarm off after $delay msec"
		alarms?.off(delay: delay)
		delay += offFor
	}
}

(Dylan R) #7

Thanks, thatโ€™s a big help. FYI, I was able to a consistent beep less than 1250ms with rule machine - only problem is that it occasionally goes off for 20 seconds or so.