Presence detection via iPhone's mDNS Entry. How to integrate into OH2?

When you are satisfied with your solution, it would be great to post it as a new thread in the Tutorials and Examples section, maybe entitled “iPhone Presence Detection using mDNS”. iPhone detection is of much interest and there have been lots of approaches attempted but the mDNS approach is a new one.

A Rule is the appropriate way to implement this. At a high level I would set it up to create/reschedule a five minute Timer when the Number Item is updated. When the Timer goes off you know you haven’t seen that device for five minutes. At that point you can code all sorts of additional actions.

You can manually control it with switches on your sitemap.

You might find the following posts useful:

The above has a simple example of how to set and reschedule a Timer.

Shows how to manage presence detection when you have multiple devices and/or multiple ways to detect each device. It also shows a simple way to override the sensors using a switch.

Shows how to manage persistence so your states remain when OH restarts.

These are not exactly what you are looking for because they don’t care which device is detected. It does the same thing no matter which device is detected or whether no devices are detected.

A somewhat related Design Pattern is:

This basically codifies the use of separate Item/Items to represent the State (i.e. presence) and all the Rules that care use this Item rather than doing calculations themselves. The Presence Detection design pattern uses this one implicitly so this link is mainly to explain why certain things were done the way they were in that Design Pattern.

Let us know if you have any further questions. We are happy to help, particularly if we can get a good and authoritative tutorial on iPhone detection out of it. :wink: