# Everyone is away and alarm is disarmed

**URL:** <https://discourse.nodered.org/t/everyone-is-away-and-alarm-is-disarmed/93720>\
**Category:** General\
**Tags:** home-assistant\
**Created:** [6 December 2024 07:12 UTC](https://discourse.nodered.org/t/everyone-is-away-and-alarm-is-disarmed/93720 "2024-12-06T07:12:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Node11](https://avatars.discourse-cdn.com/v4/letter/n/eada6e/32.png) [@Node11](https://discourse.nodered.org/u/Node11)\
**Post date:** [6 December 2024 07:12 UTC](https://discourse.nodered.org/t/everyone-is-away-and-alarm-is-disarmed/93720/1 "2024-12-06T07:12:48Z")

</div>

Hi,

I'd like to have a flow that does the following:

-when "device\_tracker.a" and "device\_tracker.b" are both away  
and:  
-when alarm\_control\_panel.alarm\_partition\_1 is disarmed  
then:  
-notify "mobile\_app\_iphone\_14" and say "xxxxxx - enter text here"

Because the status of both trackers may not always be the same (away/home, etc.) I think it might be necessary to run the flow at certain intervals during a 24 hour period (if there is a way around that, I am open to that, too.)

If you have a solution to this and are able to post the code, that would be great.

Thank you

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [6 December 2024 07:35 UTC](https://discourse.nodered.org/t/everyone-is-away-and-alarm-is-disarmed/93720/2 "2024-12-06T07:35:01Z")

</div>

Hi @Node11

1. I have moved this out of **Developing Nodes** - you're not developing a node
2. You have tagged this with **home-assistant**
3. With the details provided, it seems very dependant on HA Nodes

Honestly, I would ask the HA community - few here use HA

However, you can maybe make use of the `inject` node to run with an interval, to kick start any checks you want to do, and respond accordingly.

 ![Screenshot 2024-12-06 at 07.34.10](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/8/486afad1511368ed182f2483829ce6230450d821.png)

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [6 December 2024 08:11 UTC](https://discourse.nodered.org/t/everyone-is-away-and-alarm-is-disarmed/93720/3 "2024-12-06T08:11:36Z")

</div>

I find that the home assistant nodes want to do too many functions inside a single node, which makes it confusing.

I would keep it simple and sequential.  
use 'current state' nodes, only fill in the entity id and keep everything else default. Process the output using switch nodes, if the value passes, continue.

something like

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/0/f057e7da5363af717c5e75d0797139018cef5c99.png)

The inject node can be set to run at intervals as @marcus-j-davies pointed out.

---

<div class="post-metadata">

**Author:** ![mikefila](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikefila/32/95223_2.png) [@mikefila](https://discourse.nodered.org/u/mikefila)\
**Post date:** [6 December 2024 12:35 UTC](https://discourse.nodered.org/t/everyone-is-away-and-alarm-is-disarmed/93720/4 "2024-12-06T12:35:27Z")

</div>

The simple way to do this is to use the person integration. In settings go to people. Create a person for everyone you want to track and assign their device tracker.

You have an entity that is called `zone.home`. This sensor will show the number of people who are home. When no one is home it's state will be zero. It's also instantly updated so there is no need to poll over and over. Place that sensor in an event state node.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/8/8871dae928c212ae662bc4375a08edca3601356d.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/a/3a5efc9af9afdf351310f9ea1d055dfa9240e98f.png)

```auto
[{"id":"f819f6c13f389062","type":"server-state-changed","z":"0a325c35fc29f44e","name":"","server":"6b1110b5.183a4","version":6,"outputs":2,"exposeAsEntityConfig":"","entities":{"entity":["zone.home"],"substring":[],"regex":[]},"outputInitially":true,"stateType":"str","ifState":"0","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":1240,"y":240,"wires":[["556b7cabbec8a8e3"],[]]},{"id":"1456d48f8918b8e1","type":"api-call-service","z":"0a325c35fc29f44e","name":"","server":"6b1110b5.183a4","version":7,"debugenabled":false,"action":"notify.mobile_app_pixel_8_pro","floorId":[],"areaId":[],"deviceId":[],"entityId":[],"labelId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","blockInputOverrides":true,"domain":"notify","service":"mobile_app_pixel_8_pro","x":1830,"y":240,"wires":[[]]},{"id":"556b7cabbec8a8e3","type":"api-current-state","z":"0a325c35fc29f44e","name":"alarm_partition_1 disarmed ?","server":"6b1110b5.183a4","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"","state_type":"str","blockInputOverrides":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1530,"y":240,"wires":[["1456d48f8918b8e1"],[]]},{"id":"6b1110b5.183a4","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"id","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]

```

If you rather avoid using the person integration, you can use a trigger state node. Add each entity

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/d/8d392903a59c646cc13a33f08cc6cc09e4598372.png)

Below define their state by adding conditions

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/b/3b2e238abc307c5307747d22eda840c6ab94f367.png)

```auto
[{"id":"39b7071a58cb1b73","type":"trigger-state","z":"0a325c35fc29f44e","name":"","server":"6b1110b5.183a4","version":5,"inputs":0,"outputs":2,"exposeAsEntityConfig":"","entities":{"entity":["device_tracker.pixel_7","device_tracker.pixel_8_pro","switch.hallway"],"substring":[],"regex":[]},"debugEnabled":false,"constraints":[{"targetType":"entity_id","targetValue":"device_tracker.pixel_7","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"away"},{"targetType":"entity_id","targetValue":"device_tracker.pixel_8_pro","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"away"},{"targetType":"entity_id","targetValue":"switch.hallway","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off"}],"customOutputs":[],"outputInitially":false,"stateType":"str","enableInput":false,"x":1130,"y":740,"wires":[[],[]]},{"id":"6b1110b5.183a4","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"id","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]

```

---

<div class="post-metadata">

**Author:** ![Node11](https://avatars.discourse-cdn.com/v4/letter/n/eada6e/32.png) [@Node11](https://discourse.nodered.org/u/Node11)\
**Post date:** [6 December 2024 15:04 UTC](https://discourse.nodered.org/t/everyone-is-away-and-alarm-is-disarmed/93720/5 "2024-12-06T15:04:35Z")

</div>

Very cool, thank you, [mikefila](https://discourse.nodered.org/u/mikefila). So to test out the away status, I put one of the devices into away mode and I see this:

 ![Screenshot 2024-12-06 at 7.01.05 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/c/9ca82105cdf246c0df848171ddfe25ddb62b182c.png)

As soon as that device goes to away status, the # changed to 1. As soon as I put it back to home, it went to 2. So it looks like if both go away, it's 0, which then triggers the 2nd node which looks at the alarm status (I put in DISARMED for this section, not sure if that is what it needs to see.) Once it sees DISARMED, then it sends a notification?

Here's the code, does it look right? I'm not sure why it's saying it can't find "mobile\_app\_iphone\_14"

[https://pastebin.com/raw/TbEcxTva](https://pastebin.com/raw/TbEcxTva)

---

<div class="post-metadata">

**Author:** ![mikefila](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikefila/32/95223_2.png) [@mikefila](https://discourse.nodered.org/u/mikefila)\
**Post date:** [6 December 2024 16:35 UTC](https://discourse.nodered.org/t/everyone-is-away-and-alarm-is-disarmed/93720/6 "2024-12-06T16:35:03Z")

</div>

The current state, go to devtools and look for the alarm entity. Make sure the state is actually `DISARMED`. Many times the state displayed on the dash is reflective of it's type but the actual state will be on/off. Also that it is in all capitals, state is case sensitive.

If the iphone is not showing up in the action drop down, first try restarting node red itself. Drag out any home assistant node set any way and deploy. Then check for the entity in the drop down.

If it is still not there, in any HA node towards the top where your home assistant server is click the pencil icon. Uncheck the cache autocomplete option. Click update/done/deploy. Then repeat the previous step restarting and deploying a new node before checking.

---

<div class="post-metadata">

**Author:** ![Node11](https://avatars.discourse-cdn.com/v4/letter/n/eada6e/32.png) [@Node11](https://discourse.nodered.org/u/Node11)\
**Post date:** [6 December 2024 20:56 UTC](https://discourse.nodered.org/t/everyone-is-away-and-alarm-is-disarmed/93720/7 "2024-12-06T20:56:43Z")

</div>

The alarm part is correct, as I could see it update to disarmed...I am working on the notification now. It's a new install and I haven't worked on Node-Red for several years - to say I am rusty is an understatement.

 ![Screenshot 2024-12-06 at 12.57.44 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/3/b356beedea4e27fc981fc45904cea88e1817c230.png)

I do find the phone in the drop-down, but when I go to deploy, I get this:

 ![Screenshot 2024-12-06 at 12.59.01 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/a/aae2d8d6ff42ccd228bc6198dc83c1e83cae5de7.png)  
 ![Screenshot 2024-12-06 at 12.59.20 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/b/bb054c465001e404714d4b18ccbabb802e5d9c99.png)

---

<div class="post-metadata">

**Author:** ![Node11](https://avatars.discourse-cdn.com/v4/letter/n/eada6e/32.png) [@Node11](https://discourse.nodered.org/u/Node11)\
**Post date:** [6 December 2024 21:13 UTC](https://discourse.nodered.org/t/everyone-is-away-and-alarm-is-disarmed/93720/8 "2024-12-06T21:13:36Z")

</div>

It's working, thanks a bunch. I would have never figured out that 2,1, 0 status - that makes it super easy, like you said.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [20 December 2024 21:14 UTC](https://discourse.nodered.org/t/everyone-is-away-and-alarm-is-disarmed/93720/9 "2024-12-20T21:14:23Z")

</div>

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