Using a Pi to measure TV habits

As noted here, I’m using the the DirecTV SHEF API and a Raspberry Pi to poll my DirecTV receivers every minute and store what they’re doing into a MySQL database. After ~6 months of storing that data, I thought it’d be interesting to analyze some of it.  After all, do I really watch enough HBO and Starz to warrant paying for them every month?

Channel Preferences

  • 25,900 minutes of TV watched (~2.25 hours per day…eek; still less than the national average!).
  • 2,612 minutes of that was recorded (10%).
  • NBC is our favorite channel (3,869 minutes watched, 15%).
  • E! is our second favorite channel (1,911 minutes watched, 7.37%). Gotta keep up with those Kardashians.
  • Premium movie channels (HBO, Starz, Encore, Cinemax, etc) were watched 6,870 minutes (26.52%) – apparently worth the money.
  • Premium movie channels were recorded only 571 minutes (lots of ad hoc movie watching, I guess).
  • NBC is our most recorded channel (479 minutes) followed by HGTV (391 minutes) and ABC (330).

Time Habits

  • Sunday is the most watched day (no surprise here) with 7,157 minutes watched (28%)
  • Saturday is the second with 5,385 (21%)
  • Wednesday is the least watch with 1,144 (4.4%)
  • April was our biggest TV month with 6,413 minutes watched (24.76%)
  • June was our lowest month with 1,197 (4.62%) — July is around 10%.  The excitement of summer faded fast, apparently.
  • 8PM is our biggest TV hour with 1,312 minutes (15.14%).  This is followed by 7pm (13%) and 6pm (10%).
  • 6AM is our lowest TV hour with 68 minutes watched (0.26%).  This is followed by 5am (0.49%) and 4am (0.90%).

This is pointless data but it’s always interesting to assess your own habits.  And if you’re wondering, it took roughly 60 minutes (0.23%) to query and publish this post :).

Advertisements

Webcam Stream as Digital Picture Frame

I don’t have a quality window view in my office building and found myself checking the local news’ weather cams throughout the day so I thought it’d be cool to have a live outdoor view streaming to my desk.  Using a Pi 3, Pi Displaya case, and camera, I built a digital picture frame which streams a live video feed from my apartment window to my desk at work.  While going through the process, I hit a few hiccups and a ton of outdated resources online so I thought I’d share my learnings and provide documentation for anyone wishing to recreate.

The following will setup a Pi to run Chromium in Kiosk mode on startup while silencing errors and hiding your cursor.  The assumptions made before beginning are that you’re able to SSH into both of the Pis and your Pis are connected to WiFi.  The guide I followed to setup my cam stream is solid so no need to re-invent the wheel – use this guide to setup your first Pi to stream your cam image.  The obvious callout is to make sure your stream resolution matches your display’s resolution.  The steps below will be for your picture frame Pi and assume you’ve already got your stream up and running…

Step 1

Run the update/upgrade and install Chromium (as explained here).

sudo apt-get update
sudo apt-get upgrade

Step 2

Install x11 server utilities and unclutter.

sudo apt-get install x11-xserver-utils unclutter

Step 3

Since we want this to be as hands-off as possible and to silence any power-saving settings or error messages on power cycles, we’ll edit the LXDE startup to disable this stuff.

sudo nano ~/.config/lxsession/LXDE-pi/autostart

and add the following lines (not the screensaver commented out):
#@xscreensaver -no-splash
@xset s off
@xset -dpms
@xset s noblank
@sed -i ‘s/”exited_cleanly”: false/”exited_cleanly”: true/’ ~/.config/chromium/Default/Preferences

The last line we’ll add in this file will be the address we want to display.  In the example below, we’ll sinply load Google.com.  We use the incognito tag to prevent Chromium from showing an error in the event of a power cycle.
@chromium-browser –noerrdialogs –kiosk http://www.google.com –incognito

Now, exit and write.

Step 4

Let’s reboot and apply the changes to see the results

sudo reboot