Building a bot that controls lights, music, and possibly more, I’m facing an interesting dilemma.
One of the coolest things I’d like to make it perform is to shut down all the appliances when I leave the house and welcome me when I’m back.
The action of recognising when someone gets in or out of home is called “home fencing”.
There are several ways to implement such feature and after a few days of research, I’m still not sure which one is the best to implement.
It’s possible to tap into my phone’s position and once defined the geographic locations of the house, it would trigger events when entering and exiting. The primary trade-off is the battery of the phone. To perform a proper GPS fencing, it’s required to keep the location services of the phone always active, with an excessive battery consumption.
When the phone gets home, it connects automatically to my wifi, so it would be possible to establish my presence depending on such connection. It can happen at link layer when the phone connects to the wifi, or at IP level, where the phone becomes available with an assigned IP address.
Unfortunately, again for energy efficiency, the iPhone does not keep a permanent connection to the wifi if it’s not operated for a long time. So when the phone is on charge all night long, it disconnects from the wifi, and it can be taken as me leaving the house. Same happens when I pick the phone in the morning, it would be understood as me coming back.
I could equip the bot with a Bluetooth interface and use the discovery feature to assess which devices are around. Having a 10m radius (a little more if just discovering), and living in a small apartment, it could work. I could also use my Apple Watch as discoverable device, being visible to a Bluetooth low energy interface.
I’m currently testing a few options, but it’s an interesting dilemma, so if you have any good idea, please leave a comment and I’ll take it into serious consideration.