These are techniques to determine if a device is active on your network, but I'm understanding that you want to control your heating only when people are active and present. The moment you ping your router, whether manually or by program, it will think something's "alive".
If your RPi is your DHCP server, you can tell when a device gets a new IP address lease, which is at least an indication that the device is active. dnsmasq
can easily be configured to assign specific address ranges based on device type, for example, so you'd easily be able to discern phones from desktops without having to know every possible connecting MAC address up front. For example, here's a redacted dump of my /var/lib/misc/dnsmasq.leases
file after my sons visited:
Code: Select all
1431137959 60:be:b5:XX:XX:XX 172.16.16.117 android-XXXXX1 01:60:be:b5:XX:XX:XX
1431123335 dc:9b:9c:XX:XX:XX 172.16.16.109 XXiPhone 01:dc:9b:9c:XX:XX:XX
1431258352 64:66:b3:XX:XX:XX 172.16.16.124 raspi06 *
1431165215 64:66:b3:XX:XX:XX 172.16.16.86 raspi07 *
1431148159 cc:6d:a0:XX:XX:XX 172.16.16.71 NP-13C1CFXXXXXX *
1431260545 fc:c2:de:XX:XX:XX 172.16.16.121 android-XXXXX2 01:fc:c2:de:XX:XX:XX
1431247578 d8:90:e8:XX:XX:XX 172.16.16.111 android-XXXXX3 01:d8:90:e8:XX:XX:XX
1431236319 00:1a:98:XX:XX:XX 172.16.16.84 android-XXXXX4 *
This gives me 3 relevant bits of data for each active device:
1. The current IP address assigned in the DHCP lease. In my case, all client devices use DHCP, so those are the only ones I'd be interested in for your scenario.
2. The name the device used when querying the DHCP server. All of my Android devices use android-XXXXXX
, and my RPis use their hostname (raspiXX
), while Rokus use NP-XXXXXXXXXXXX
so telling them apart is easy.
3. The device MAC address. This is useful because the 1st 3 bytes of a MAC address designate a manufacturer (although this can be changed, it's not common to do so). My son's iPhone uses a name that I couldn't easily predict, but I can tell that it's an Apple device based on the 1st 3 bytes of the MAC address. I can also pick out my Motorola smartphone:
DC-9B-9C-XX-XX-XX Apple, USA
60-BE-B5-XX-XX-XX Motorola Mobility LLC, USA
FC-C2-DE-XX-XX-XX Murata Manufacturing Co., Ltd., JAPAN
64-66-B3-XX-XX-XX TP-LINK TECHNOLOGIES CO., LTD., CHINA
D8-90-E8-XX-XX-XX Samsung Electronics Co.,Ltd, SOUTH KOREA
00-1A-98-XX-XX-XX Asotel Communication Limited Taiwan Branch, TAIWAN
CC-6D-A0-XX-XX-XX Roku, Inc., USA
00-0D-4B-XX-XX-XX Roku, LLC, USA
can be configured to assign different IP parameters based on any of these patterns. The beauty of doing it on the DHCP server (e.g. RPi) is that I don't have to do any network probes which themselves might look like "human" traffic, and I have access to a lot of device info without having to know about them up front (e.g. building a list of MAC addresses). If I set a short DHCP lease time, for example, for anything requesting a lease with the name android-XXXXXX
, the leases disappear when the device is no longer present.
That still just means the phone is in your home though, and certainly not in a specific room or necessarily near a user. My IP subnet can be pinged well out into my yard and on the street. You also have no means of detecting user with a device that's not on your wifi or local network, or who has no device on them.
How localized do you want detection to be? House or room level? Might passive IR sensors be more effective at detecting bodies versus devices? Do you want to know when anybody is present, or only care about certain tech-savvy individuals? What about pets? What if the device goes into standby and is not active on the network for hours?