Notify if away and alarm not armed

Hi,

New to Node-Red and created a flow to let me know if everyone is away, but the alarm is disarmed. What I have it doing is re-running every few minutes and if everyone is away and it’s disarmed, it waits a bit, checks again on the alarm and then sends an email notification if still not armed. It works fine, but each time it goes through the process again, it sends another email until the alarm is armed. Is there a way to set limits to how often the email can be sent, even if everyone is away and the alarm isn’t armed? Open to other input as well. It helps me learn.

Thanks

image

[{"id":"f52d3fe559476656","type":"trigger-state","z":"91a80f99.6180e","name":"","server":"","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"person.homer, person.marge","entityidfiltertype":"substring","debugenabled":false,"constraints":[{"targetType":"entity_id","targetValue":"person.homer","propertyType":"current_state","comparatorType":"is_not","comparatorValueDatatype":"str","comparatorValue":"home","propertyValue":"new_state.state"},{"targetType":"entity_id","targetValue":"person.marge","propertyType":"current_state","comparatorType":"is_not","comparatorValueDatatype":"str","comparatorValue":"home","propertyValue":"new_state.state"},{"targetType":"entity_id","targetValue":"senaor.alarm","propertyType":"current_state","comparatorType":"is_not","comparatorValueDatatype":"str","comparatorValue":"armed_away","propertyValue":"new_state.state"}],"inputs":0,"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","enableInput":false,"x":272,"y":4032,"wires":[["e7b8e8659b998293"],[]]},{"id":"e7b8e8659b998293","type":"debug","z":"91a80f99.6180e","name":"email","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":546,"y":4032,"wires":[]}]

With your current setup, you can use a delay node set to rate limit

Thanks, I took a look and I see the limits that can be set. I’m glad I asked :slight_smile: I thought the delay could also wait a certain amount of time in the flow (basically slow down the flow,) then continue. Is there another node specifically for that or did I get the right one? I’m assuming I can put the delay node right before the email alert?

Is there a reason I need to inject every few minutes to check on the presence status or is there an alternative way to do this that doesn’t have to run every so often?

You can use a state node.
It will activate when a state is changed.

So one for each in the family, or one for a group of family.

Events state works (for the presence of the first person,) but I can’t connect that to another events state (for the second person.) I can’t find another state that can sense a state change without injecting first. In other words, if person 1 is not home, then go to person 2 and if they aren’t home, continue the flow. That’s why I ended up with the injection repeating itself to determine the state of both persons.

Current state node.
But as said before. It’s better to group the family and let HA do the hard work then you just need to have one events state node (or trigger state node) and the notify node.

1 Like

Mind providing an example, please? I’d like to understand how to put that together the way you describe it.

Something like this:

So group is easier.

It only requires:

But you need to create a group in Home Assistant with the device trackers in the family

Can some people please take a look at this current code (I might modify it some more, but it has generally worked ok, but I am getting additional notifications even after not all the conditions are met.)

Here’s what I am trying to do and would like to know, please, how closely this flow matches this. If everyone is away from the house and the security is not armed, send email notification. If one person is away and one is not and the alarm is not armed, don’t make a notification (only if both are.) If both are away and the alarm is armed, don’t make a notification. I was testing it out, both being away, have the notification go off, returned to “home” and I got one residual email after that. I would like the flow to catch this and not send another email.

[{"id":"7194ba2f074feee3","type":"api-current-state","z":"e3aaa0d4de20b317","name":"Presence - 2","server":"78fd209d.3e277","version":2,"outputs":2,"halt_if":"home","halt_if_type":"str","halt_if_compare":"is","entity_id":"device_tracker.hostname2","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":290,"y":580,"wires":[[],["ec8a7a143b9ddabe"]]},{"id":"99a3602cb8ae0713","type":"api-current-state","z":"e3aaa0d4de20b317","name":"Presence - 1","server":"78fd209d.3e277","version":2,"outputs":2,"halt_if":"home","halt_if_type":"str","halt_if_compare":"is","entity_id":"device_tracker.hostname1","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":110,"y":580,"wires":[[],["7194ba2f074feee3"]]},{"id":"ec8a7a143b9ddabe","type":"api-current-state","z":"e3aaa0d4de20b317","name":"Disarmed?","server":"78fd209d.3e277","version":2,"outputs":2,"halt_if":"disarmed","halt_if_type":"str","halt_if_compare":"is","entity_id":"alarm_control_panel.home_alarm","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":510,"y":580,"wires":[["76e5f6279ba5ee52"],[]]},{"id":"3fee99be167ac5bd","type":"api-current-state","z":"e3aaa0d4de20b317","name":"Disarmed?","server":"78fd209d.3e277","version":2,"outputs":2,"halt_if":"disarmed","halt_if_type":"str","halt_if_compare":"is","entity_id":"alarm_control_panel.home_alarm","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"Alarm is off, please turn on.","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":130,"y":680,"wires":[["78c2b15031ab0f6a"],[]]},{"id":"78c2b15031ab0f6a","type":"e-mail","z":"e3aaa0d4de20b317","server":"smtp.gmail.com","port":"465","secure":true,"tls":true,"name":"1","dname":"","credentials":{"password":"g"},"x":330,"y":680,"wires":[]},{"id":"2a232d3940414051","type":"inject","z":"e3aaa0d4de20b317","name":"Alarm not armed","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"240","crontab":"","once":true,"onceDelay":"1","topic":"","payloadType":"date","x":150,"y":500,"wires":[["99a3602cb8ae0713"]]},{"id":"76e5f6279ba5ee52","type":"delay","z":"e3aaa0d4de20b317","name":"","pauseType":"delay","timeout":"4","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":680,"y":580,"wires":[["3fee99be167ac5bd"]]},{"id":"78fd209d.3e277","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

Thank you

You’re asking for help and then don’t listen to anything we say.
The way you does it is fundamentally flawed.

I’m still working on it, but your recommendations have been helpful. Thanks.

I learned a lot from this: Node Red Cookbook

Check out the Actionable Notification stuff.

Thank you, I’ll check it out.