# Best practices for presence detection

**URL:** <https://discourse.nodered.org/t/best-practices-for-presence-detection/24575>\
**Category:** General\
**Created:** [10 April 2020 08:58 UTC](https://discourse.nodered.org/t/best-practices-for-presence-detection/24575 "2020-04-10T08:58:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edo78](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/edo78/32/19682_2.png) [@Edo78](https://discourse.nodered.org/u/Edo78)\
**Post date:** [10 April 2020 08:58 UTC](https://discourse.nodered.org/t/best-practices-for-presence-detection/24575/1 "2020-04-10T08:58:19Z")

</div>

Hi,  
I'm trying to figure out how to manage a pretty classic presence detection management.

I have multiple devices that can be detected near a light. If only one of them is close then I have to turn on the light but I don't have to turn it off until all the devices are far away.

I'm still new to node-red so I still have problem with the flow approach and I'm thinking about a simple boolean approach.

I just can check all devices status with an OR but I'm not sure it's a best practice.

Do you have any advice?

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [10 April 2020 09:04 UTC](https://discourse.nodered.org/t/best-practices-for-presence-detection/24575/2 "2020-04-10T09:04:56Z")

</div>

What kind of devices?  
If we are talking about detecting presence of smart phones, in my case iPhones, I definitely say Monitor is very good. Have been using it successfully for more than a year now

> **[andrewjfreyer/monitor](https://github.com/andrewjfreyer/monitor)**
>
> Distributed advertisement-based BTLE presence detection reported via mqtt - andrewjfreyer/monitor

---

<div class="post-metadata">

**Author:** ![Edo78](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/edo78/32/19682_2.png) [@Edo78](https://discourse.nodered.org/u/Edo78)\
**Post date:** [10 April 2020 09:21 UTC](https://discourse.nodered.org/t/best-practices-for-presence-detection/24575/3 "2020-04-10T09:21:06Z")

</div>

I'm using room-assistant (more as a proof of concept) but right now I'm more interested in how to manage in node-red a generic situation that could be handled with a simple "OR" in a classic programming style.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [10 April 2020 10:31 UTC](https://discourse.nodered.org/t/best-practices-for-presence-detection/24575/4 "2020-04-10T10:31:47Z")

</div>

Without knowing what devices or the protocols it's difficult to say.

Your language suggests you are thinking in a procedural / polling manner.

Node-red is much better suited to event based programming e.g. when a device is detected, an event occurs (e.g. a node fires it's output) then using other nodes, you determine what to do with that.

If you provide more details, I'm certain someone can steer you.

---

<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:** [9 June 2020 10:31 UTC](https://discourse.nodered.org/t/best-practices-for-presence-detection/24575/5 "2020-06-09T10:31:51Z")

</div>

Closed on 9 June 2020 10:31 UTC

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