Data Visualization and Demo

As mentioned previously, my goal wasn’t to just create a home controller/dashboard but to also collect as much data as possible while doing so.  So tonight, I started playing around with a few different visualizations of the data I’ve collected thus far.  It took a few hours but I’m satisfied with the current state.
I’m doing simple dumps of the most recent music played by my Amazon Echo; most recent programming watched via DirecTv; visualizing the daily average, minimum, and maximum temperature and humidity levels in my apartment; visualizing by hour of day the average, min, and max temperature for the current month vs the previous month; breaking down the amount of time I spend at home by day of week (and telling on myself that I like to leave work early on Fridays :)); and visualizing my TV watching habits by hour of day and day of week.
I recorded a video of this all and also included the DirecTv control demo at the end.

Home Automation and NFC Tags

NFC has proven to be a pretty useless technology for cell phones (unless you’re one of the people who use you Google Wallet/Apple Pay).  Nevertheless, I decided to buy some tags and play with them because they’re so damn cheap (just over a dollar each, depending on the type).
20161002_121409
One useful application of NFC tags is setting “scenes” using my existing home automation setup.  By setting a tag where I usually place my phone at night, I can trigger several events all at once.  When I play my phone on my nightstand, the following events are triggered:

  1. If it’s a weekday, set my alarm for 7:00 AM.
  2. If an alarm was set, the phone will adjust its volume and say “Alarm set to 7 AM”.
  3. Using the same text to speech, the phone will say “Goodnight, Kevin.”
  4. After pausing for a few seconds, it’ll POST to a simple script I wrote  and turn all the lights in the apartment off before setting it’s volume to mute for the remainder of the night.

It’s a simple way of automating my night time routine and is likely the most practical use of NFC tags with home automation (and it’s not super practical, at that).  If you want to recreate, here’s how I did it…

NFC Tag and App

I decided to go with the WhizTags brand because they boast more writeable space (888 bytes of writeable memory vs the standard 144 bytes). For reading and writing the tag, I went with the NFC Tools app. There’s no real reason for using this app – it just looked to be the most stable after a quick search.

Creating the Task

One of the benefits of the NFC Tools app is that you can export import json tasks.  Here’s the json for the task I noted

[ {
    "tasks.profile.name":"bedtime post",
    "tasks.profile.date":"20161002T101631",
    "tasks.profile.length":11,
    "tasks.profile.size":226,
    "tasks.profile.data":[ {
        "tasks.profile.fields": {
            "field1": "5"
        }
        ,
        "tasks.profile.config": {
            "itemUpdate": "false", "requestType": "53", "itemTask": "5", "itemDescription": "5", "itemHash": "16686621-29d1-46bf-80f0-2d8905abcfdb"
        }
    }
    ,
    {
        "tasks.profile.fields": {
            "field1": "0"
        }
        ,
        "tasks.profile.config": {
            "itemUpdate": "false", "requestType": "819", "itemTask": "1", "itemHash": "b63e98a5-7385-4ae5-a71e-a76949092649", "itemDescription": "1 second"
        }
    }
    ,
    {
        "tasks.profile.fields": {
            "field4": "true", "field1": "true", "field3": "true", "field8": "1", "field2": "true", "field5": "true", "field7": "false", "field6": "false"
        }
        ,
        "tasks.profile.config": {
            "itemUpdate": "false", "requestType": "92", "itemTask": "f9", "itemDescription": "MON,TUE,WED,THU,FRI\nPerform the tasks below", "itemHash": "eb2223cb-c5a2-4d59-a1a8-961e1bb13dde"
        }
    }
    ,
    {
        "tasks.profile.fields": {
            "field3": "0", "field1": "7am", "field2": "7"
        }
        ,
        "tasks.profile.config": {
            "itemUpdate": "false", "requestType": "41", "itemTask": "7:0;7am", "itemDescription": "7am - 07:00", "itemHash": "ba40261a-84e3-437d-b1e4-b44dbc6e0b8f"
        }
    }
    ,
    {
        "tasks.profile.fields": {
            "field1": "Alarm set for seven am."
        }
        ,
        "tasks.profile.config": {
            "itemUpdate": "false", "requestType": "85", "itemTask": "Alarm set for seven am.", "itemHash": "02fc2b51-36ba-497a-adea-1620b5799d8c", "itemDescription": "Alarm set for seven am."
        }
    }
    ,
    {
        "tasks.profile.fields": {
            "field1": "1"
        }
        ,
        "tasks.profile.config": {
            "itemUpdate": "false", "requestType": "819", "itemTask": "2", "itemDescription": "2 seconds", "itemHash": "60c8cd67-00bb-4850-a5c2-cbe5883f3de4"
        }
    }
    ,
    {
        "tasks.profile.fields": {
            "field1": "1"
        }
        ,
        "tasks.profile.config": {
            "itemUpdate": "false", "requestType": "90", "itemTask": "1", "itemHash": "78382993-811f-4692-b110-61ff20406731", "itemDescription": "Close your conditional block"
        }
    }
    ,
    {
        "tasks.profile.fields": {
            "field1": "Goodnight, Kevin."
        }
        ,
        "tasks.profile.config": {
            "itemUpdate": "false", "requestType": "85", "itemTask": "Goodnight, Kevin.", "itemDescription": "Goodnight, Kevin.", "itemHash": "acab1f45-d379-4af4-99f9-0ccb63db4ae3"
        }
    }
    ,
    {
        "tasks.profile.fields": {
            "field1": "2"
        }
        ,
        "tasks.profile.config": {
            "itemUpdate": "false", "requestType": "819", "itemTask": "3", "itemDescription": "3 seconds", "itemHash": "37320287-c034-4742-a959-705ac3399800"
        }
    }
    ,
    {
        "tasks.profile.fields": {
            "field1": "0"
        }
        ,
        "tasks.profile.config": {
            "itemUpdate": "false", "requestType": "53", "itemTask": "0", "itemHash": "d7a566bd-107b-4dae-aff4-f2ce832f06e6", "itemDescription": "0"
        }
    }
    ,
    {
        "tasks.profile.fields": {
            "field1": "http:\/\/hellokevin.com\/nfc\/goodnight.php", "field2": "status=false;"
        }
        ,
        "tasks.profile.config": {
            "itemUpdate": "true", "requestType": "110", "itemTask": "http:\/\/hellokevin.com\/nfc\/goodnight.php|status=false;", "itemHash": "e1e00d48-16fa-4942-9d9e-298b806a65c2", "itemDescription": "Request: http:\/\/hellokevin.com\/nfc\/goodnight.php\nPOST parameters :\nName: status \/ Value: false", "itemTaskExtra": null
        }
    }
    ]
}
]

The Script

The script used to turn the lights off is a modified version of this script, which I posted earlier.  Instead of controlling a single device, I simply added in all the lights in my home and added in the POST var.