My combination Manual Alarm (YAML) and Node-RED alarm (and MORE!) - example, and looking for constructive criticism

In my setup, it will still arm with a door open, and once it’s closed that door will be armed as well. I have an alert that I’m trying to figure out that will say something like “The alarm is armed but these were left open!” and it will tell you which was left open. I’m still learning function nodes so it’s not ready yet.

I’m glad that the blog is helpful, I just made another post about using zigbee buttons, google homes, and Node-RED together. You must’ve been one of the 6 people that visited over the weekend :smiley:

hi, congratulations for the work, please let us know when you find the solution for the open doors, cuzz im interested in move my alarm to node red, right now im using one that is in the HACS section, its named bwalarm, that alarm doesnt let you acitvate the alarm while a door is open, or let you know that the door is open and if you want to overide it you can do it.

Here’s what I have so far. It uses a get entities node. I’m using a wild card as I’ve named all of my doors starting with “binary_sensor.door_”, the windows “binary_sensor.window_” and the garage “binary_sensor.cover_”. Doing it this way I can configure the get entities node to grab everything that is a door, window or cover by using a wildcard.

Here’s how it looks right now -

Here's what one of the get entities nodes looks like -

I need to figure out how to make the notification dynamic so that it would override the standard notification telling me the alarm was armed. I have a few ideas but haven’t had the chance to implement it yet.

Mess around with it and let me know if you come up with a better way, I’d love to see it.

Here’s the code if you want to play around with it:

[{"id":"8673e30f.fb9b4","type":"tab","label":"test 3","disabled":false,"info":""},{"id":"3e41c959.5afd96","type":"ha-get-entities","z":"8673e30f.fb9b4","server":"26956a45.92d866","name":"","rules":[{"property":"entity_id","logic":"is","value":"binary_sensor.window","valueType":"re"},{"property":"state","logic":"is","value":"on","valueType":"str"}],"output_type":"split","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":590,"y":220,"wires":[["e807d8f6.4fe178"]]},{"id":"122d20b0.9e336f","type":"ha-get-entities","z":"8673e30f.fb9b4","server":"26956a45.92d866","name":"","rules":[{"property":"entity_id","logic":"is","value":"binary_sensor.door","valueType":"re"},{"property":"state","logic":"is","value":"on","valueType":"str"}],"output_type":"split","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":590,"y":280,"wires":[["e807d8f6.4fe178"]]},{"id":"8131455b.3a43e8","type":"ha-get-entities","z":"8673e30f.fb9b4","server":"26956a45.92d866","name":"","rules":[{"property":"entity_id","logic":"is","value":"cover.door_garage","valueType":"re"},{"property":"state","logic":"is","value":"on","valueType":"str"}],"output_type":"split","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":590,"y":160,"wires":[["e807d8f6.4fe178"]]},{"id":"e807d8f6.4fe178","type":"template","z":"8673e30f.fb9b4","name":"Format Friendly Name","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{{payload.attributes.friendly_name}}}","output":"str","x":860,"y":220,"wires":[["c2849f57.a1e81"]]},{"id":"c2849f57.a1e81","type":"join","z":"8673e30f.fb9b4","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":", ","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1030,"y":220,"wires":[["c74c37db.d77dd8"]]},{"id":"c74c37db.d77dd8","type":"api-call-service","z":"8673e30f.fb9b4","name":"Notify","server":"26956a45.92d866","version":1,"service_domain":"telegram_bot","service":"send_message","entityId":"","data":"{\"message\":\"The alarm has been armed but these have been left open: {{{payload}}}.\"}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1150,"y":220,"wires":[[]]},{"id":"fd192863.885678","type":"inject","z":"8673e30f.fb9b4","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":340,"y":220,"wires":[["8131455b.3a43e8","3e41c959.5afd96","122d20b0.9e336f"]]},{"id":"26956a45.92d866","type":"server","z":"","name":"Hass.io","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true}]

image

[{"id":"8ba8eb11.134ac8","type":"ha-get-entities","z":"b287ee98.ea6a6","name":"","rules":[{"property":"entity_id","logic":"is","value":"binary_sensor\\.(?:door|window)_.+|cover\\.garage_door","valueType":"re"},{"property":"state","logic":"is","value":"on","valueType":"str"}],"output_type":"array","output_empty_results":true,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":278,"y":464,"wires":[["8216dd33.ec247"]]},{"id":"8216dd33.ec247","type":"api-call-service","z":"b287ee98.ea6a6","name":"Notify","version":1,"service_domain":"telegram_bot","service":"send_message","entityId":"","data":"{\t   \"message\":$count(payload) > 0 ? \"The alarm has been armed but these have been left open: \" & $join(payload.attributes.friendly_name, \", \") & \".\" : \"The alarm has been armed.\"\t   \t}","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":434,"y":464,"wires":[[]]},{"id":"72893fd4.be38b","type":"inject","z":"b287ee98.ea6a6","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":108,"y":464,"wires":[["8ba8eb11.134ac8"]]}]
3 Likes

@Kermit, that’s outstanding! Thank you! That is so much more efficient that what I was doing.

I’ve been wanting to learn JSONata, but haven’t started yet. Do you know of any resources where I could start learning?

1 Like

Here’s a post I made a while back that has a couple of reference links:

https://community.home-assistant.io/t/jsonata-examples-for-ha-nodes/128963?u=kermit

1 Like

@PickleSlice Great Job!!

Nice job. i have it up and running. need to change a few things to fit my setup but done nicely.

my only issue is that i need to use some link-in and link-out nodes… and cant do it with subflows. So im gonna have to try to revert it all back to 1 flow.

I like the compactness of the json entity data. Here is another (longer) way of sending a text message list of all perimeter openings left open if everyone has left the home and the alarm is not armed. The automation is also used when the alarm is armed. Otherwise, I use a similar switch node to process alarm operations like others have shown above.

On a side note, nodered can also arm/disarm the alarm automatically using a service call to the arm state, with your alarm code included in json data, using the format {“code”:“1234”}.

@PickleSlice Thank you for this! I’ve been looking everywhere for a good example of the alarm panel using Node Red and this is perfect for my use case. I’m still pretty new to HA and Node Red but your flow alone saved me from days of research and headaches. Plus it taught some things I didn’t even know was possible with NR. I just can’t thank you enough for this. I do have some follow up questions though, if you don’t mind.

Is there a way I can specify which devices I want to monitor based on the alarm mode. For example I want to monitor just doors and windows when it’s Armed-Home but I want to include a few motion sensors only when Armed-Away. Also have you figured out the dynamic notifications yet? If so is there any chance you can share the latest version?

I haven’t looked into splitting up the alarm in sections like that. I know it’s possible, but I don’t know as of yet what direction to point you in.

As far as notifications go, I have figured it out and they have been working great. I need to update my blog, as this security system has grown since I originally posted this. I’ll post up some examples shortly.

1 Like

@PickleSlice I’m following your setup as a guide and it’s going really well, thanks for this!

I’m pretty new to Node Red (didn’t realize subflows existed until now) and have a question. What are the event state and white status nodes in each of the subflows doing?

Thanks!

Shaun

How can I set different triggers for Armed away and armed home?

i just want to thank you so much for the codes.

Just wanted to add my thanks for creating a great baseline to jump from. I have been using my own manual alarm system built in Node-Red for a few years now but it was always clunky and incomplete.

This really tightens everything up so thank you for your hard work on this!

Did you by chance ever look into Life360? I’m currently running into some issues with it arming/disarming from it.

Thanks for sharing.
I am now starting to do the same type of flows and your code sharing is a very huge help !
Thanks again

That’s my primary location automation. Let me get some screenshots and such for you.

Here’s a quick screenshot showing an overview of the leaving, and arriving home flows. Let me know if you want to know anything else.

Hi

Could you please share the flow for the notify which door/window is left open?

Thanks