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.
[{"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
Below define their state by adding conditions
[{"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}]