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:
- RSSI changed
- 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
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.