Security system rule

Hi, im a about to build a home security system. I have several sensors which are sending their data via MQTT to broker (exapmle:"{"RfReceived": {"Sync":15660,"Low":510,"High":1490, "Data":“123456","RfKey":"None"}} "). On the other side i have a switch for sending an on/off signal to a LED (showing if its armed or disarmed). There is a MQTT signal as well. The third part is a siren which receives an ON or OFF signal (MQTT).
Now, the sensors should trigger the alarm signal but only in case of getting the signal from the ON/OFF button.
So far so good. Does anyone have a hint for me, how to get it work?
Here`s a screenshot of my "idea"

Thanks in advance- Jesco

You need to retain the armed state in a Node-RED global/flow variable and only pass the alarm if the system is armed.

As this is an alarm, it is probably also important to have an external warning of it being triggered. I'd use Telegram for that.

Finally, you will want to know if the sensor has failed for some reason. You should be sending output from the ESP every few seconds and you should use the Last Will & Testament feature of MQTT so that the ESP sends an "Online" message normally and the LWT outputs an "Offline" msg if it hasn't received an update in a set period. If the sensor goes offline, you will want to at least be informed. You might want that to set off the alarm.

1 Like

As this is an alarm, it is probably also important to have an external warning of it being triggered. I'd use Telegram for that.

Any pointers to getting Telegram to work?

I tried a while back and couldn't get it to send the message to more than a single receiver, I assume I need to set up a group for this, but I got frustrated and gave up and just used Email instead which worked well enough to forget about it until now. Recent Android updates has made one phone unable to download the attached photos unless connected by WiFi which defeats the whole purpose.

I also use a cheap Android phone with "pay as you go" Ting service running node-red via Termux and Termux-API to send SMS messages. This works great, but I'm finding Android (6) is not 24/7 reliable. About every two weeks I get an Email from MQTT broker telling me the Android phone is dead -- either a "lock-up" or something has made it reboot and the node-red doesn't start automatically.

I forgot to say, that im a newbie ;-) . Pushover should work for that. Im using it on another flow (mail notification if a letter is in the postbox). Right now i have 3 devices. The sensors, the alarmsiren and the (rf)bridge. Every device is working and communicating. The only thing i stuck, is the dependences of each.

You use Tasker to restart node red on boot.

It is a little confusing until you look under the cover and realise that everything happens via conversation ID's. So you can talk both to individuals and groups as long as you find out the ID. This is done be creating the API connection and letting the individuals/groups attach to the bot. With a simple Telegram input that dumps to debug, you can take note of the various conversation ID's which you can then use when you are sending alerts.

Telegram tends to be a lot more reliable than email (well, outside of Russia anyway!) and I've never had more than a few seconds delay before a msg shows up.

Pushover may also work. As might Pushbullet. Though I had issues with Pushbullet and always had to go and manually delete old messages, you don't have to do that on Telegram. Even Skype and Facebook messenger (yuck!) will work if you can create a bot - but Telegram is about the easiest to set up of all of the ones I've tried.

At the end, the push notifications arent the problem (yet)! Im using Openhab and Homekit, so there are a lot of possibilities to do any kind of communication. I do have gaps in the basic knowledge of node red, that might be the main problem :wink: But let`s start over. Right now, the sensors are working and sending data to the rf-bridge. The "only" thing I need is a function node, which looks for an incoming signal of the on/off button. Only if his is "on", the sensor value triggers an outgoing mqtt signal. In theory. Be merciful with me ,-)

That doesn't like a need for a Function node, it sounds like a Switch. In the Switch you can test the value of payload for "on" and send that message on, ignoring other values. Then feed the Switch output into a Change node to set the data you need for MQTT (if you do need to change anything that is).

In fact won't you need to look for two incoming messages ?

  1. Set the on/off state of the alarm ?
  2. An incoming message saying the sensor has been tripped/activated - if so then check that the alarm is on and send out a message to activate the siren/send notification etc ?

Just confirning that the logic is correct ?


Craig, 100% correct! Jesco

OK so instead of a function node you can probably do the following

  1. MQTT in Node with Topic such as Alarm/State - have your system send and On or Off to that Topic based on what is put in from the alarm panel

  2. Have that node feed into a Switch Node - ti checks for the On or Off and send output to two different nodes

  3. Those nodes are Change Nodes - they will set a GLobal Context Variable AlarmState to On or Off

  4. Have another MQTT in node that listens to a Topic such as Alarm/Zone/Sensor1 - send a String in such as Activated on that topic when motion etc is detected

  5. Have this feed into aSwitch node - check if the incoming message is Activated - if so branch off to another Switch Node that checks the Global Variable AlarmState - if == On then sound the alarm, send your alert etc etc, if == off then do whatever your non alert conditions are