Category Archives: try this

Testing the AWS IoT Button

Screen Shot 2016-05-22 at 7.49.35 PM
I was able to get my hands on an AWS IoT button when it went on sale last week. I had been looking for one of these since they gave them out at re:invent last year. I believe this was the first time it was on sale to the public. I wanted the button to keep next to my bed and would program it to shut off my hue lights and change the temp on my Nest before bed. Sure, I could set each of these independently on a schedule to power off or change temp at a certain time but having one button to take care of both of these actions was what I wanted.

So the button came and I was eager to get started. AWS has a Lambda blueprint for getting started with IoT and the button. It basically uses AWS IoT button to trigger a Lambda function which creates a SNS topic and sends an email. With little configuration you can setup this demo and get some basic experience with AWS IoT.

Check the AWS IoT button page here.
Click the Configure your AWS IoT Button to get started.
Screen Shot 2016-05-22 at 7.18.10 PM

After you login with your AWS creds, what this does is kicks off a Lambda blueprint called iot-button-email that has all of the code and IoT functions associated. While creating from the blueprint make sure of a few things.
1. On Step 2 make sure to add the SQL statement ‘SELECT * FROM ‘iotbutton/+”
2. On Step 3 make sure to update your email and the IoT button serial number in the Lambda function code. Also make sure the Lambda function handler and role is set to the basic execution role.
3. On Step 4 enable the event source and create the function.

A few more tips:
1. After my function was created there was an option to test it, it did not run. Checking the log there was an issue with the lambda basic execution role, not having authorization to create an SNS topic.
To resolve, go into Identity and access management, modify that role and add the SNS full access policy.
Try running the Lambda function again it should work fine.

2. So now that your function runs you need to configure your button to your wifi and IoT details. The button will not work without an IoT certificate and private key.
The Lambda blueprint should create some things policies and a certificate in AWS IoT, however I was not able to pull the private key from the already created certificate.iot-overview
To resolve this I recreated the certificate and attached the thing and policy to it and now I had everything needed alongside my wifi details to configure the button.

If you are having issues getting your button to respond, note the flashing light sequence and refer to the guide on the bottom of the main IoT button page here. While trying to get this working I had a few different errors, short short short (could not connect to network), long short long (certificate did not have permission to publish), long short short (certificate is not activated). Spend some time working through it, understanding how AWS IoT works, and you should be able to figure it out if you’ve made it this far.

You’ll need to subscribe to the SNS topic that was created for your notifications, so be sure to confirm that subscription.

After that you should be able to receive emails from pressing your IoT button!


Moving forward from this very basic demo there are many possibilities.
I used and recipe to turn off my hue when an email is received in my gmail account from from this post. There is another beginners guide to using the IoT button that may be useful if you are testing.
Next ill try and use the hue and nest APIs to trigger actions instead of using email and ifttt.
Have fun!

Automating NZB Movie and TV Downloads


SABnzbd is a usenet reader/downloader that is highly extensible and handles downloading, verifying, repairing and unpacking .nzb files for you.  Its lightweight, written in Python and runs on almost every OS; OSX, Windows, Linux, BSD.


CouchPotatoApp connects with SABnzbd and and lets you maintain a want list of movies and helps automate searching, handoff, and post download file modifications.

CP scans every X hours for titles you add and allows you to configure with different options such as file size and quality.  It also renames and moves files which is very useful if you download and store on two different machines or drives.  This app is also Python based and multi-platform.

Have a look at some of the work this app is doing for you in the log

15:06:52 INFO  [     app.lib.cron.renamer] XBMC metainfo for imdbid, tt1542344, generated
15:06:44 INFO  [    app.lib.cron.subtitle] Finding subtitles for: /Volumes/My Passport/New Movie 2010)
15:06:44 INFO  [     app.lib.cron.trailer] Finding trailers for: /Volumes/My Passport/New Movie (2010)
15:00:22 INFO  [     app.lib.cron.renamer] Moving file "/Users/michaelkahn/Downloads/complete/Movies/-----/newmovie.avi" to
/Volumes/My Passport/New Movie (2010)/New Movie (2010).avi.
15:00:22 INFO  [     app.lib.cron.renamer] Quality Old: 0, New 700.
15:00:17 INFO  [     app.lib.cron.renamer] Creating directory /Volumes/My Passport/New Movie (2010)
15:00:17 INFO  [     app.lib.cron.renamer] Trying to find a home for: newmovie.avi
15:00:17 INFO  [          app.lib.library] Retrieved metainfo: {u'common': [{u'comment': u'Has audio/video index (5.6 MB)',
u'mime type': u'video/x-msvideo', u'image height': 304, u'frame rate': 24.0,
u'producer': u'VirtualDubMod (build 2540/release)',u'image width': 576, u'endianness': u'Little endian', u'duration':
 u'1:32:49', u'bit rate': 1000000.0}], u'audio stream': [{u'compression rate':
11.300000000000001, u'compression': u'mp3', u'sample rate': 48000.0, u'duration': u'1:32:49', u'bit rate': 135800.0,
u'channel': 2}], u'video stream': [{u'image height': 304, u'compression': u'xvid', u'image width': 576, u'bits/pixel': 12,
u'duration': u'1:32:49', u'frame rate': 24.0}]}
14:33:27 INFO  [        app.lib.cron.yarr] Finished search.
14:33:27 INFO  [          app.lib.sabNzbd] NZB sent to SAB successfully.
14:33:26 INFO  [          app.lib.sabNzbd] URL: http://localhost:8080/sabnzbd/api?apikey=-----&mode=addurl&
14:33:26 INFO  [          app.lib.sabNzbd] Sending 'New Movie 2010 DVDSCR XviD PEER' to SABnzbd.
14:33:15 INFO  [] Checking if
&apikey=----- is valid.
14:33:05 INFO  [pp.lib.provider.yarr.base] "New Movie (DVDSCR) (2010)" is too large to be Screener. 2775.04MB instead of the
maximum of 1000MB.
14:33:05 INFO  [pp.lib.provider.yarr.base] "New Movie 2010 DVDSCR AC3 XViD T0XiC iNK (diff group)" is too large to be
Screener. 1413.12MB instead of the maximum of 1000MB.

Very convenient.  After CP finds a movie that I added to my want list, it sends it to SABnzbd, then it moves it over to my SAN (/Volumes/My Passport).  From there my boxee box has the SANs location saved and scans for folder updates every few hours.  So all I have done is added a movie I want to see to the CP want list and soon after its released its ready to play in my living room.  I have heard that Sick Beard is good for TV shows but I do not miss too many on cable with my DVR.  I highly recommend SABnzbd x CP x Boxee for automation and ease with viewing movie downloads.  Enjoy!

Geektool Weather

Geektool is an OSX system preference module that allows you to display information on your desktop. You can display shell, file or image output. I have used this prefpane to display load averages and process data in the past but now I just have it displaying weather info. Its handy for early morning or when a cold spell comes around. Give it a try if you use OSX and think you may have some data you would like to display on your desktop. An Expose Desktop corner and Geektool work nicely together for on the fly info.

Screen shot 2010-05-26 at 7.01.08 PM

And the code. You’ll need lynx to make this work. Replace 32828 with your zip code. Leave me a comment with your geektool scripts if you give it a try.

lynx -dump '' | grep 'Temperature' | cut -c 16-21
lynx -dump '' | grep -m 1 Conditions | awk '{print $2}'
lynx -dump '' | grep -m 1 Observed | awk '{print $5 " "$6}'
lynx -dump '' | grep -m 1 Updated | awk '{print $2 $3" " $4" " $5 " "$6" " $7" " $8 $9}'