Switch off devices by presence on network


I have this idea in my head, but have no clear way of executing it.

I would like an arduino to monitor my network every minute, to check for certain mac's. If it would detect either the mac of my smartphone, or my wife's smartphone, it can switch on certain appliances. Between a certain time-interval, this does not count, unless manually overridden.

The way I see it: When neither me or my wife is home, the water filtration unit, well pump, ventilation unit, network printer... Need to be completely shut off (relay card). When either one of us arrives at home (smartphone connected to the network), all these devices can receive power. But when we go to sleep, even though we are still connected to the home network, I want these devices off again. For this I would use a fixed interval, which can be manually overridden.

Is this possible?

If you use DHCP then you can do a DNS lookup to get the device's IP and then ping it. Not all devices will respond to ping (ICMP Echo requests) but my Android smartphone does so perhaps yours will too. If you don't use DHCP then you can just use the static addresses directly.

An alternative would be to query the WiFi hub's status to find what devices have attached. I don't know of a standard API for that but most WiFi-capable unmanaged routers will provide a method to query that information (I've got hubs that present it via web pages, and others that also provide SSH command line shells) and any IP-capable device with a network connection should be capable of querying it.

Given that you don't want to detect just whether the devices are present but also whether the person is awake, I think it might be better to focus on better ways to work out whether a person is awake. I imagine a good solution would need PIR sensors and/or sensing when lights are switched on, but home automation seems to be a very popular topic at the moment and I suspect people have come up with more clever ways to do it.

A movement sensor or three might do it. One at the front door to detect when you get home. Another couple elsewhere in rooms where you normally are.

The code in the Arduino could wait for (say) 15 minutes with no movement and then shut things down, and turn them back on the moment it detects movement.

Thanks for the replies.

I want to avoid using motion sensors, really want to use the wifi instead. I don't need a detection of whether I'm asleep or not, would just use a schedule for that.

Oh well, what PeterH said then.