# Openhab Presence monitoring

**URL:** https://discourse.nodered.org/t/openhab-presence-monitoring/6053
**Category:** General
**Created:** [22 December 2018 01:18 UTC](https://discourse.nodered.org/t/openhab-presence-monitoring/6053 "2018-12-22T01:18:35Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Shadowbreed](https://avatars.discourse-cdn.com/v4/letter/s/ad7895/32.png) [@Shadowbreed](https://discourse.nodered.org/u/Shadowbreed)
#### Post date: [22 December 2018 01:18 UTC](https://discourse.nodered.org/t/openhab-presence-monitoring/6053/1 "2018-12-22T01:18:35Z")

</div>

I am rather new at Node-red (as in I installed it yesterday) so this is probably extremely simple, but I can't for the life of me figure it out..

I am trying to set up some simple presence monitoring logic.  
I am pulling the state of home/away from openhab using the openhab-in node, getting a simple on/off

What I want to do is the following:

2 people.  
If neither is home, then check if guests is set to on/off and based on that take action.

If one of us is home, then skip any further checks, and take another action.

I can figure out how to use a switch to check for each person: if home then action 1, if not then action 2.  
But I can't figure out how to check if both person 1 and person 2 is set to off, then check guests, if also off then action 3  
Or how to do If any of these 3 is set to on, then action 4

---

<div class="post-metadata">

### Author: ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)
#### Post date: [22 December 2018 01:37 UTC](https://discourse.nodered.org/t/openhab-presence-monitoring/6053/2 "2018-12-22T01:37:27Z")

</div>

Assuming all the information is held within the same message, you could do it with a switch node followed by a switch node. Or by using a function node with a javascript if this AND that type statement (google for the correct syntax)

If the information isn’t within the same message you need to get it there, you could use a join node, or store the data in memory. This has come up a lot in the past couple of days. There’s and example here [Output two attributes in the template](https://discourse.nodered.org/t/output-two-attributes-in-the-template/5983/6)  
and you can read the docs within the working with function part of the documentation

---

<div class="post-metadata">

### Author: ![Shadowbreed](https://avatars.discourse-cdn.com/v4/letter/s/ad7895/32.png) [@Shadowbreed](https://discourse.nodered.org/u/Shadowbreed)
#### Post date: [22 December 2018 07:16 UTC](https://discourse.nodered.org/t/openhab-presence-monitoring/6053/3 "2018-12-22T07:16:15Z")

</div>

Thanks 🙂 the Join node is what made it work for me. I assume this can be done more efficiently, but it achieves what I wanted 🙂

[{"id":"9734930c.831ed","type":"tab","label":"Presence","disabled":false,"info":""},{"id":"cbaec52.3d13f38","type":"switch","z":"9734930c.831ed","name":"Home or Away","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"ON","vt":"str"},{"t":"eq","v":"OFF","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":361,"y":115.99999904632568,"wires":[["5ba135b.a7484cc"],["5ba135b.a7484cc"]]},{"id":"a5b73a40.836478","type":"switch","z":"9734930c.831ed","name":"Home or Away","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"ON","vt":"str"},{"t":"eq","v":"OFF","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":357.9000015258789,"y":207,"wires":[["5ba135b.a7484cc"],["5ba135b.a7484cc"]]},{"id":"defb60f0.0ec94","type":"switch","z":"9734930c.831ed","name":"Home or Away","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"ON","vt":"str"},{"t":"eq","v":"OFF","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":357.9000015258789,"y":306.00000190734863,"wires":[["5ba135b.a7484cc"],["5ba135b.a7484cc"]]},{"id":"e4b36b40.196498","type":"switch","z":"9734930c.831ed","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"ON","vt":"str"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":721.1000595092773,"y":207.00000286102295,"wires":[["61eae6b7.e3f608"],["c9062098.f6d92"]],"outputLabels":["ON","OFF"]},{"id":"61eae6b7.e3f608","type":"debug","z":"9734930c.831ed","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":877.1000137329102,"y":140.00000190734863,"wires":[]},{"id":"c9062098.f6d92","type":"debug","z":"9734930c.831ed","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":876.1000595092773,"y":256.00000381469727,"wires":[]},{"id":"5ba135b.a7484cc","type":"join","z":"9734930c.831ed","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\n","joinerType":"str","accumulate":false,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":536.1000556945801,"y":208.00000190734863,"wires":[["e4b36b40.196498"]]},{"id":"d78c5e36.888af","type":"comment","z":"9734930c.831ed","name":"Is anyone home","info":"","x":697.1000061035156,"y":242.00000286102295,"wires":[]},{"id":"1afef592.76a4aa","type":"comment","z":"9734930c.831ed","name":"Combine messages","info":"","x":586.1000595092773,"y":164.00000190734863,"wires":[]},{"id":"21228fd9.7f62f","type":"comment","z":"9734930c.831ed","name":"Get status","info":"","x":333.0000534057617,"y":164.00000190734863,"wires":[]},{"id":"712bce96.7e26a","type":"comment","z":"9734930c.831ed","name":"Someone Is home","info":"","x":896.1000595092773,"y":104.00000095367432,"wires":[]},{"id":"58a82e11.e9e65","type":"comment","z":"9734930c.831ed","name":"Nobody Home","info":"","x":875.1000366210938,"y":220,"wires":[]},{"id":"f3fa6276.9cfde","type":"inject","z":"9734930c.831ed","name":"","topic":"","payload":"ON","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":165.10000610351562,"y":84.00000095367432,"wires":[["cbaec52.3d13f38"]]},{"id":"d81a9ae3.bbd608","type":"inject","z":"9734930c.831ed","name":"","topic":"","payload":"ON","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":165,"y":195.00000190734863,"wires":[["a5b73a40.836478"]]},{"id":"c24e2c8f.1232c","type":"inject","z":"9734930c.831ed","name":"","topic":"","payload":"ON","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":167,"y":284,"wires":[["defb60f0.0ec94"]]},{"id":"704c527d.14399c","type":"inject","z":"9734930c.831ed","name":"","topic":"","payload":"OFF","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":164.10000610351562,"y":123.00000190734863,"wires":[["cbaec52.3d13f38"]]},{"id":"1140aa8f.723cd5","type":"inject","z":"9734930c.831ed","name":"","topic":"","payload":"OFF","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":164,"y":233.00000381469727,"wires":[["a5b73a40.836478"]]},{"id":"9bf4074d.3e8e78","type":"inject","z":"9734930c.831ed","name":"","topic":"","payload":"OFF","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":168,"y":322,"wires":[["defb60f0.0ec94"]]}]
