Hi everybody,
I’m a newbie regarding OH(2) and currently think about all the possibilities that are feasible by using OH. What’s crucial for me is presence detection. Because everybody who lives in this house has an iPhone I want to use this device as a source for figuring out if a specific person is at home or not. After doing some research I found out that iPhones register themselves to the network’s mDNS service roughly every 1-2 minutes even when locked and inactive. By doing a mDNS query once a second I am able to detect when an iPhone registers itself to the mDNS service for a few seconds. This way I keep track of when I last saw a specific iPhone (an Exec-Binding issues a shell script which calculates this value and updates an “Number” item). That’s already working pretty well and I can see that period counted in seconds in my sitemap. If anyone is interested in the details, please send me a message.
Now comes the (at least for me) tricky part: I want to implement a rule (or is there better way than using a rule?) which triggers actions when a specific iPhone has not been seen for more than 5 minutes:
- Set some state variable “person_x_present” to “false”.
- Do some further actions reacting to that (or should that be triggered by the update of the state variable just changed?)
- There should be a way to disable this automatism by setting a switch “person_x_presense_detection” to false (maybe iPhone is lost or battery empty). You should then be able to set the variable “person_x_present” manually with a switch.
When someone comes home and his iPhone is being detected again the presence-variable should of couse be set to “true” again and trigger further actions as well. But I guess that should work analog to the leaving rule (in a separate rule)?
What I don’t understand is how and where I can define such a state variable and query it’s status for reacting to a change? Ideally this state variable should be persistent so it survices a restart of the OH service.
And how can I define a rule which is triggered only if my “Number” item exceeds a certain limit?
I really do appreciate any help on how to do this. Thanks in advance!
regards,
Stephan