# Room and floor presence v1

{% hint style="warning" %}
In 2020, I decided to rework the logic to handle room and floor presence.

This page represent the "old" way of doing it. The reason why I had to reconsider this model, was the large number of flows and timers involved.

I'd reccomend to instead use the updated [room and floor presence logic v2](https://homey.solweb.no/aggregated-state/room-and-floor-presence-v2).
{% endhint %}

I use logic boolean variables to track if there is anyone present in the room or not. For some areas I use the same technique, but track the present in a complete floor.

### Simple room presence with door sensor

The simplest setup I have to track a room, is to add a window/door sensor and a timer.

I currently use the [chronograph timer](https://homey.app/en-us/app/nl.fellownet.chronograph/Chronograph/).

When the door opens or closes, I set the presence to `true`, restart a timer from 50 minutes. When the timer fires, I flip the presence back to `false`.

![](https://1587494504-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ltn3vQOSB-YGC6qLZu_%2F-LtoelnXgkZRF9oFIK8-%2F-Ltofx0VBbfzrQyjVYmY%2FSkjermbilde%202019-11-16%20kl.%2015.48.26.png?alt=media\&token=caddbc03-246a-4b84-967f-ef16fb4843c6)

For a door sensor, there is no available triggers that covers both open and close. The result is that I duplicate the flow above and have an nearly identical flow **Bad1 trigger active2,** that triggers when the **contact alarm turned off** instead of on.

![](https://1587494504-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ltn3vQOSB-YGC6qLZu_%2F-LtoelnXgkZRF9oFIK8-%2F-LtogLXy6lSahrG7QTnW%2FSkjermbilde%202019-11-16%20kl.%2015.50.10.png?alt=media\&token=61c9362f-2a70-4e36-ae3b-7e4e97f52ad4)

The flow above fires when the door has not been opened or clsoed for 50 minutes.

I use this setup for rooms where you do not stay for very long at a time, such as bathroom and a booth. For the childrens room and other room where you can for stay longer, I've added a motion sensor as well.

### Simple floor presence

I have a floor with multiple motion sensors. I track the presence in this floor by using the zone feature. I have no door sensors (nor doors) on this floor.

![](https://1587494504-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ltn3vQOSB-YGC6qLZu_%2F-LtoelnXgkZRF9oFIK8-%2F-LtohE-8zfzvGo-4AjnL%2FSkjermbilde%202019-11-16%20kl.%2015.54.01.png?alt=media\&token=4369ebc8-b986-4644-98c8-1a7fcd21e4ab)

Then a second flow for setting presence to false.

![](https://1587494504-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ltn3vQOSB-YGC6qLZu_%2F-LtoelnXgkZRF9oFIK8-%2F-LtohQQs5dGkDOa3TK0E%2FSkjermbilde%202019-11-16%20kl.%2015.54.54.png?alt=media\&token=77c58d85-a5b1-4599-bce1-2f0e278689fc)

### More complex presence

It gets messy when you have an area with multiple motion sensor that does not match a floor, and combine them with multiple door sensors.

I have these flows:

* One **setActive** flow, that is executed from the trigger cards. This flow is execturd when motion is detected.
  * The setActive flow sets presence to `true`,&#x20;
  * and stops the timer.
* One card for **each of the motion sensors**/zones when **motion is detected**, starting the **setActive** flow above.
* One flow called **trigger**, that checks if there is no motion in any of the motion sensors, and if so, it:
  * starts a timer with a duration of 20 minutes
  * sets presence to `true`
* One flow for each of the motion sensor when motion alarm is turned off, that:
  * starts the **trigger** flow
* Two flows for each of the door sensors (one for open and one for close), that
  * starts the **trigger** flow
* One flow that fires when the timer finishes
  * Sets presence to `false`

#### setActive flow

![](https://1587494504-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ltn3vQOSB-YGC6qLZu_%2F-LtoelnXgkZRF9oFIK8-%2F-Ltoja1yah0wVoADy5WC%2FSkjermbilde%202019-11-16%20kl.%2016.04.21.png?alt=media\&token=a9a76765-6da5-4cef-9835-88e652255860)

#### trigger flow

![](https://1587494504-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ltn3vQOSB-YGC6qLZu_%2F-LtoelnXgkZRF9oFIK8-%2F-Ltojw-TqAs40-_4i70h%2FSkjermbilde%202019-11-16%20kl.%2016.05.48.png?alt=media\&token=cb4155e3-7236-451a-ba40-0c2063b0a471)

#### inactive flow (timer finishes)

![](https://1587494504-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ltn3vQOSB-YGC6qLZu_%2F-LtoelnXgkZRF9oFIK8-%2F-LtojztxAmub15nZlyhB%2FSkjermbilde%202019-11-16%20kl.%2016.06.05.png?alt=media\&token=c28d2737-bd47-4d6e-9324-cbc03cda4927)

#### example of a motion alarm turns on

![](https://1587494504-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ltn3vQOSB-YGC6qLZu_%2F-LtoelnXgkZRF9oFIK8-%2F-Ltok4E-5DIjv6ItKQqT%2FSkjermbilde%202019-11-16%20kl.%2016.06.29.png?alt=media\&token=2de8006a-6ada-474c-9670-b4e1e2e8702c)

#### example of a motion alarm turns off

![](https://1587494504-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ltn3vQOSB-YGC6qLZu_%2F-LtoelnXgkZRF9oFIK8-%2F-Ltok8eQnU1K4_tT4hcP%2FSkjermbilde%202019-11-16%20kl.%2016.06.45.png?alt=media\&token=19e9ce01-9550-40c8-82e9-269d8d4d1e9b)

#### example of a door opens

![](https://1587494504-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ltn3vQOSB-YGC6qLZu_%2F-LtoelnXgkZRF9oFIK8-%2F-LtokDq1IJKSzprX2Eq8%2FSkjermbilde%202019-11-16%20kl.%2016.07.06.png?alt=media\&token=63a4ca65-ae80-4846-ae22-4115c208ab69)
