Alarm siren latch and switch off after a predetermined time

I am a total newby..I have built a Raspberry pi with sensors that ,when they are triggered, even momentary, I want to sound an alarm siren for a set time, say 5min, and then reset and read the sensor state again. The alarm siren is driven by a relay triggered by an output from a GPIO. This sounds simple, but I just don't know where to look for an example flow. I would be really appreciative if someone could help.

A small example from one of my flows. The siren gets triggered (in Home Assistant) and sounds for 5 seconds

[{"id":"f7d7ebd3.18f488","type":"mqtt out","z":"4059b82d.903f28","name":"","topic":"home-assistant/siren-on","qos":"","retain":"","broker":"90e3adb3.8d47","x":620,"y":940,"wires":[]},{"id":"9d7052be.35178","type":"change","z":"4059b82d.903f28","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"siren.on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":940,"wires":[["f7d7ebd3.18f488"]]},{"id":"ed60e50f.a17138","type":"inject","z":"4059b82d.903f28","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"str","x":130,"y":940,"wires":[["9d7052be.35178","5e28fee3.6a02c"]]},{"id":"b7cd9990.025e78","type":"comment","z":"4059b82d.903f28","name":"Siren on then off","info":"","x":160,"y":900,"wires":[]},{"id":"df9a630a.8ecb8","type":"mqtt out","z":"4059b82d.903f28","name":"","topic":"home-assistant/siren-off","qos":"","retain":"","broker":"90e3adb3.8d47","x":620,"y":1040,"wires":[]},{"id":"51540072.b649d","type":"change","z":"4059b82d.903f28","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"siren.off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":1040,"wires":[["df9a630a.8ecb8"]]},{"id":"5e28fee3.6a02c","type":"delay","z":"4059b82d.903f28","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":350,"y":990,"wires":[["51540072.b649d"]]},{"id":"90e3adb3.8d47","type":"mqtt-broker","z":"","name":"","broker":"192.168.0.242","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

Thank you so much. I am going to experiment with that.

Look at the trigger node. It can be set to send an on signal then ignore any further inputs and then an off signal.

Yes, that is true. I guess my example was unnecessary complex but it depends where and how the siren is connected/controlled. In my example it is a z-wave siren connected with Home Assistant in another RPi in my system. It is possible to "borrow" the siren from outside using MQTT. Unfortunately it requires that you publish the commands to different topics. So I could not use a single trigger node without also adding some change and switch nodes. An alternative flow would look like below, working the same

The TC, @Stevef, has it connected to a GPIO pin so it should for sure be simpler to achieve, just using a trigger node

Cheers

What is the switch for ???
(latest version of trigger allows you to send second output to a second pin ;-))

1 Like

Oh yes, you are right!!! I could simplify :+1:
And now also only setting the topics :wink:

My thanks to you all for the responses. I am 62 years young with an electronics and Linux background, and am having great fun with Raspberry Pis and Arduinos. My programming experience is some Linux, or Unix as it was, scripting. I have never joined one of these forums, and am delighted with all your kind response. I am going to tackle this a bit later and will let you know how I go.

2 Likes

With those skills you’re well ahead of the game ! Have fun.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.