If you have a mobile phone, chances are that it has a Bluetooth radio integrated. By running a special server ('gateway') program, your mobile phone can be made part of any DoIP network, and you can have your lights turned on and off automatically depending on whether your mobile phone is in range of the Bluetooth base station.
Enable Bluetooth on your mobile phone; how you do this depends on your particular model and brand. Also, make sure that your phone is 'discoverable' (or 'visible', as it is sometimes called).
To integrate Bluetooth devices in your network, you need a computer with a Bluetooth radio (most USB Bluetooth dongles are very cheap and work with Linux). You also need to run the TJBluetoothEPServer (tjtoothepd). If you want to use presence detection in multiple rooms, you need multiple Bluetooth 'base stations' and may have to 'tag' each base station accordingly.
Finally, we use a fabric to listen for Bluetooth devices appearing and disappearing. If this happens, the fabric displayed below will send a '/ep/basic/dim' message to all devices that support it. TJBluetoothEPServer will by default scan every minute and add any device to the HomeWeave network that it finds (and tag it with a specific tag). To make the fabric displayed below work, replace the Bluetooth address below to the address of your phone (if you do not know this, run the fabric once with the default address and see what happens when your phone is detected - if all goes well, it shows your Bluetooth address).
<?xml version='1.0' ?> <!-- This fabric will dim the lights whenever the phone identified by a particular bluetooth address enters or leaves. --> <fabric title="Presence" author="Tommy van der Vorst" version="1"> <!-- This group looks for all the lights in the network (i.e. all devices that support /ep/basic/dim) --> <group id="lights" direction="out"> <discover type="ep"> <requires> <supports method="/ep/basic/dim" /> </requires> </discover> </group> <!-- This is the group in which the presence magic happens. The <specific> tag only matches our phone. The scripts in <entry> and <exit> are executed whenever this device appears cq. disappears. --> <group id="bt" direction="out"> <discover type="ep"> <requires> <specific namespace="org.bluetooth.device" id="00:16:B8:4F:2F:33"/> </requires> <entry> print("Bluetooth device has appeared"); if(!globals.present) { print("Turning the lights on!"); send("lights", new Message("/ep/basic/dim", 1.0)); } globals.present = true; </entry> <exit> print("Bluetooth device has left"); if(globals.present) { print("Turning the lights off!"); send("lights", new Message("/ep/basic/color/fade", 0.0)); } globals.present = false; </exit> </discover> </group> </fabric>
It is possible to make the fabric respond to multiple devices using the <either>-tag; it is left as an exercise to the reader to improve the fabric to count the number of phones currently visible and only turn on/off the light when this count is zero…
<requires>
<either>
<specific namespace="org.bluetooth.device" id="00:16:B8:4F:2F:33"/>
<specific namespace="org.bluetooth.device" id="00:16:B8:4F:2F:34"/>
<specific namespace="org.bluetooth.device" id="00:16:B8:4F:2F:35"/>
</either>
</requires>