I have the feeling that my teenager son spends too much time in front of the TV. We have a house rule that he is allowed to watch TV only after all homework is done, room is tidied up and for no more than couple hours a day. Of course, this rule is hard to control unless time spent in front of the TV is accurately measured, so I came up with an easy way to log TV usage to emoncms and later analyze that. The approach to do this is similar to the method I used to tracking my presence at home i.e. see if the smart TV is registered at home’s WiFi and log that information along with time stamp. The major difference from my previous approach is that I track the device by its MAC address rather than static IP lease. I figured that I want to track few more devices, so setting up a static IP lease for pinging them is going to take me more time than working out another method using MAC address. I use arp-scan to achieve this, to install it run:
sudo apt-get update sudo apt-get install arp-scan
It basically can scan the network for certain MAC address and respond with the corresponding IP address, if it is registered. We use exactly feature this to establish if the TV is on or off by specifying part or all of the MAC address of the device to track:
[Edit July 1st 2014] Increased retries count as the default was giving me unreliable readouts and suppressed vendor decoding to speed things up:
sudo arp-scan --retry 5 --quiet --localnet --interface=wlan0 | grep -s -i 10:08:C1
So here is all this implemented in Node-RED:
A simple function checks if the arp-scan returns anything (meaning the device is on) or a null string, meaning device is off:
The result of this check is published to emoncms node 30. I do some post-processing in emoncms to track the time-on:
So with this data collection running for a while, I will be able to know average TV usage per day.
The script can be easily extended with a rule to turn off the TV if daily usage limit is exceeded, but I do not want to be that tough on the kid. The purpose of this project is to learn more about the TV usage and have arguments to support further usage restrictions or relaxing these, also good for self quantification purposes.
The exact same approach can be applied to tracking usage of anything on your home network that connects to the Internet i.e. game consoles, laptops and so forth.
Page views: 17119