Best Presence detection

bluetooth
owntracks
presence
Tags: #<Tag:0x00007f21372be8f0> #<Tag:0x00007f21372bd798> #<Tag:0x00007f21372bd130>

(ksiezykmirek) #43

I have found problem in this linę:

Grep is case sensitive, do the -i parameter need to be add before $1. Otherwise macs has to have all small cases.


(ksiezykmirek) #44

Next update:
CRU (cron) list is lost on reboot, so in need to be addet to init script like this:

cru a mirek “* * * * " "/jffs/maccheck.sh xx:xx:xx:xx:xx:xx mirek"
cru a ania "
* * * *” “/jffs/maccheck.sh yy:yy:yy:yy:yy:yy ania”


Presence (OPEN)
(Josh Barfield) #45

Great idea, it’s working well for me. Just sharing a few notes from issues I ran into getting it set up on my router.

My version of Tomato doesn’t have bash, and /bin/sh is symlinked to busybox ash. This causes an issue with the “function fcomp()” line (syntax error on the function), so just trim it to “fcomp()” and that will work.

Second issue I had was with your execution. Originally you listed maccheck.sh [switch name] [MAC address] as the syntax, but it’s actually expecting maccheck.sh [MAC address] [switch name]. Not a big deal, just might be confusing if someone is reading along at home.

Thanks again for the great idea!


(Kees Van Gelder) #46

Very true words about basic security.
Allow me to chip in on the lighter side:
there is a great (dutch) TV commercial of an insurance company that shows a guy giving a lecture on home automation. And just as he enthusiastically is telling how he can control his home from his phone, burglars show up at his house. At that moment the guy is showing the crowd how he can open his garagedoor and put a spotlight on his prized vintage car… anyway, you get the picture.

You are very right saying in the end it is just about how much risc you are willing to accept. Though I am basically in favor of even being able to switch on my toaster via my phone, I still rely on just a traditional lock on my doors. No WiFi, RFID or what have ya there


(Masssssy) #47

I feel like I should put this script i worked on a while back here. Uses a simple scan to detect and keep your presence but uses bluetooth authentication if you’ve been away. This fixes an issue with spamming authentication as that screws up both the server and the phone and eventually at least one will need a restart.


(Dome) #48

This thread hasn’t seen a lot of activity… but since I think it’s still a resource for new openHAB users looking to set up presence detection, I want to point out a new method of detection for iPhone users. Bear in mind that you’ll need to modify the example rules a bit if you want presence switches, but it shouldn’t be too complicated.


(Martin Eskildsen) #49

I am working on a JSR223 lib for presence detection that is (when finished) intended to use a varity of technologies to detect Presence. Right now i am in an early state, where I have done a lot of thinking and written som pseudo code.

My intention is to provide a Python library that can use some or all of these technolgies:

  • Wifi (connected, RSSI, Roaming between AP)
  • Bluetooth Proximity
  • Presence service (like OwnTracks)
  • Sensors (Door contacts, PIR Sensors, Cameras etc.)

The idea is that each person can be configured to use a different/individual technology to identify Presence.
My idea with the unpersonalized sensors is to use those as an indicator that there is somebody there. The personalized “sensors” like Wifi, Owntracks will be used to calculate a probability of whom it may be.

I am also considering a mechanishm where a specific series of events can be used; For instance

  1. Pir Sensor in hallway is activated
  2. Frontdoor is opened
  3. Bluetooth in car is seen by Bluetooth scanner
  4. Time is between 6:30 - 7:30 in the morning

At my place this means (>90%): Wife is leaving for work.

That was just some initial thoughts. i have started a POC to see what needs to be done. :slight_smile:


(Ralph Borchers) #50

Do you plan your python library to be able to work distributed over multiple nodes?
Does Bluetooth Proximity include BTLE devices?


(Martin Eskildsen) #51

Yes, For me this is exactly the same as Wifi, it can have multiple nodes (Access Points).
The problem is that it shouldn’t be too complex to setup, then it is useless in my opinion.

You should think of this library as a library that works with data that is already in openHAB (via items and/or things/channels).


(Rich Koshak) #52

It would be great to include the Wasp in the Box algorithm into this library as well. That would round out the features nicely.


(Martin Eskildsen) #53

Thanks for mentioning. I have brifly looked at the article you have a link to earlier in this post. Actually I think that the concepts will cover my thoughts. At least I have thought of the difference in sensors (e.g personal).
I will start of with this algorithm as it seems to cover most of my thoughts.


(Henning F. Mettge) #54

Hey @mr_eskildsen,

that sounds very promising! I am very excited.

Bye
HFM


(Martin Eskildsen) #55

Just to update how I am progressing.
I have now reached my first milestone. That is to get a rough skeleton up and running.
I already had started a project to handle rules for my lightning. When thinking about it I realised that quite a lot of the basic handling would be exactly the same code. So I have created a bae lib to handle these things.
Next I have created python classes so that I can build my model.
I have decided to split the problem into “two dimensions”. One dimension is to identify where (location) events is happening, and the other dimension would then be how accurate can I identify whom is present.

Now each and every sensor should define how accurate it is in each of the two dimensions. Eg. a door contact is very accurate in location dimension, where it doesn’t tell you much about who is opening the door. I Wifi connected device would be more accurate (moderate to high), about identifying a person (it could be a device shared amongst a couple of persons).
I have created a sensor called WifiClient and I have setup a framework to get notifed whenever one the the following events occurs:

  1. Connect/Disconnect
  2. RSSI changed
  3. Roaming between different Accesspoints

For each sensor I calculate i it has detected presence, when it was detected and also when last “sign of life” was detected. I also plan to add a value defining for how long time a “sign of life” would mean that somebody is there. For a door/window sensor this would mean 30-60 seconds, where a play command on a Chromecast would mean everything between a few minutes (watching a Youtube clip) and a couple of hours (Netflix movie).

Each sensor is mapped to at least one of the two dimensions (depending on the definition of the sensor). A Wifi Client would be mapped to the house location (and not a room) because that would corresppond to the accuracy. It would also be mapped to one or more specific persons, thus i covers both dimensions great and therefore I have started with this.

Right now I have just pushed the code onto my production Raspberry Pi and I will use the comming days to improve the WifiClients ability to determine presence.
One problem I would have to deal with is that I always turns off my phone during night (so openHAB would believe I am out whenever I goes to bed).
That one have to be solved, I am thinking of a “Keep A live” mechanishm, Without having implemented it, i think it should be some kind of a hysteresis that keeps the presence flag high as long as the phone is off. I hope that knowledge about the RSSi could help in determination of this. i believe RSSI for a phone leaving would get weaker before disconencting, where it would just dissapear in this case. But I need som logs to identifi what to do,

I almost forgot to state that my primarily goal is to define something, that other people can use without recoding everything. It should be adaptable,s o that you just would have to define your objects and link them together in the two dimensions. But that is future. Right now I can hardly model my own world :slight_smile:
I should also be possible to extend the library with your own sensors, so that all kinds of strange stuff could be used to presence detection.

Next step would be to make this simple sample (version 0.1) usefull, and also add validation. I won’t publish anything before I have a simple validation of the model added.I think I have taken quite a big step, since I have a working framework right now.


(Rich Koshak) #56

This is the problem that the wasp-in-the-box algorithm is supposed to solve. Basically if you have sensors that detect entry/exit like a door sensor, if you no longer detect presence events but an entry sensor hasn’t triggered assume they are still present.


(Martin Eskildsen) #57

I agree that this is part of the answer. I can think of a lot of situations where the lack of a door contact being triggered won’t tell you the full story. As an example: Lets assume that I turn off my phone at 22:00, at 22:30 my wifes comes home (and she has a habbit of turning of Wifi). The presence detection knows that I am at home, it will then detect that front door is opened and since it doesn’t detect anybody comming home, it might end up concluding that I am leaving.
Off course you can argue that I doesn’t have sufficient sensors to detect if somebody is entering or leaving. So it is a bit more complicated than just calculating what the sensors available says. I believe the result is highly dependent on how you choose sensors to represent availability of a person. The algorithm has to be aware if the sensors linked to that person is usefull for determining presence for a specific person. Therefore I see that each sensor has two attributes:

  1. Accuracy of Location
  2. Acuuracy of determining a person

Basically door window contacts has a high accuracy, because they are mounted on a specific location, where they say absolutely nothing of the person.On the other hand other sensors would be much tighter related to a person.

The problem is that the algorithm should be able to identify the quality of the calculation, the quality is really difficult to embed into calculation, because it depends on how different people is acting. It is hard to determine the quality of the calculation, since the same sensor would result in different quality for my wife and my self. So the tricky part is to make this parameter configurable WITHOUT making configuration rocket science.

So there is a need to make relevant parameters configurable, therefore it would be nice to dicuss concrete cases and also ideas to handling this in an simple way.

Yesterday I have enabled a a WifiClient for one personal device for each person in the house. The results is as expected: Not even close to anything reliable :slight_smile:
Tonight I have added a Geofence (OwnTracks) to two persons, so I can start playing around and tweaking :slight_smile:

Offcourse contacts, pir sensors etc.also has to be taken into account.

Again I would like some ideas to concrete implementation.As soon as I have some code that I beleive is just a little usefull, I will publish that.


(Kim Andersen) #58

Martin, have you thought about using Face detection. A face detection in the doorway, and you know for sure who is entering, (known people). Then use WiFi/bluetooth to state when they leave.

I wonder if it would be possible using Netamo Welcome. I havn´t given this lots of thoughts, and have not seen any serious reviews stress testing the Netamo Welcome. Heck I dont even know if it´s possible to use the Netamo Welcome together with Openhab. But I guess a face detection item would cover most presence problems.


(Martin Eskildsen) #59

I Haven’t considered specific devices, my thoughts is more on how to get reliable results. My thoughts is at the more abstract level, where it is considerations on how can I say if presence detection is precise or not. I have made small experiments with the hardware I have (a couple of PIR sensors, a lot of door / window contacts, Wifi presence, Bluetooth presence and OwnTracks. I have also been pointed in direction off Wasp in the box algorithm. The description thoughts described is really great, at a general level. Nothing close to something that could be implemented in code.

The more I look on my own data, it becomes more clearly to me, that the choice of sensors really matters. The combination of different sensors really matters. A PIR sensor is excellent at detecting movement in an area, where OwnTracks give a more rough indication of location, but a more usefull indication of whom it is.

In my hallway I have placed a PIR sensor at a central place. Means that nearly every person moving around the house have to pass this sensor. Really good for determining presence, really bad for determining the transistion coming / leaving. I have therefore had some thoughts about how to identifi the quaility of a measurement. For instance the Unifi controller has (sometimes) a latency between a couple of minutes to 10 minutes before identifying a client going offline. Other Wifi solutions might have other timings. I need to handle this in an algortihm. Where Ubiquiti Unifi has a lot of parameters, others might have less / others, must aslo be handled…
I have also thought of creating a Presence service (webservice or whatever), because it might be usefull if the service has some kind of learning (eg. if in doubt it will ask if an event was a transition). On the other hand I don’t want a complex model…

So right now I am trying to think o a scenario that is at least usefull for myself, and hopefully worth publishing to others.

Regarding the Netamo Welcome - as far as I see it has an API, thats good news => can be adapted by openHAB


(Kim Andersen) #60

I stumpled upon an article about the same challenge. In this article its the same goal, but the autor mention a specific device (ibeacons) for the use, which I believe together with other devices, liek you suggest, you´ll get pretty close to reach your goal.

I´m thinking I may have to spend a few hundred danish kroner, just to try this ibeacon thing :slightly_smiling_face:


(Martin Eskildsen) #61

A Raspberry Pi could do the same :slight_smile:


(Kim Andersen) #62

Well, you´ll need alot of Pi´s if you want presence room detection. And ibeacons runs on batteries, Pi´s dont :slight_smile: