Help with code

I’m having trouble finding the right code in the below example "def OneSecond =1". I want a piezo buzzer to churp when a door opens. What I have buzzes for about 3 seconds, and I can’t change the value. I assume I am dealing with a integer variable which cannot go less than 1 second. I have tried .50, 0.50, 00.50. Any help would be appreciated.

def doorOpenDetectedHandler(evt) {
_ log.debug “doorOpenDetectedHandler called: $evt”_
_ theSound.on()_
_ def oneSecOn = 1_
_ runIn(oneSecOn, turnOffSwitch)_

ST is a cloud-based solution. You’re not going to get sub-second performance, ever. You’d be much better off finding a device that will just emit a single chirp when turned on, and have it automatically turn off (locally).

If you want to build something, you could use my ST_Anything project using the TimedRelay device which allows you to define the amount of time (in milliseconds) the output stays on before it turns off automatically.


fibaro realys can be set to swithc off automaticly


I was hoping to be able to get this working with a little code change, but what you guys are saying is probably true. There is no way to chirp this quickly when it is cloud based.

1 Like