AWS IoT Dash Button Doorbell
This post is woefully late, as Amazon has stopped selling these button to the general public, but on the other hand, better late than never?
For those not in the know, Amazon sold little buttons, co-branded with Tide, Trojan(!), and toilet paper, that you would set next to wherever it was you used that product, and when you were running low you could just push the button and it would automatically order a refill.
It was exactly as silly as that sounds.
But! They also sold buttons without branding (other than AWS) for $20 that you could program to do whatever you want at the push of a button, assuming what you want is doable using AWS Lambda. That’s what we’re here to do today.
Step zero is to somehow find yourself a button that isn’t being sold anymore. Good luck!
Now that that’s out of the way, let’s get cracking.
For this, we’re going to work our way “backwards”, starting with the service that will alert you by pinging your phone (or desktop, etc). I use a service called Pushover, though you can use any service that is supported by IFTTT. Sign up for an account, pay the $5, and make sure to test the notifications are getting through to your phone.
Next we’re going to use IFTTT, as service that allows you to connect a bunch of things to a bunch of other things. Sign up for an account, then add the ‘Pushover’ service - it will ask you to login to Pushover (again) and choose which device you want to ping. You can leave that as default to ping everything, or select a subset.
Now we create a new IFTTT Webhook. Go to create, click the +This that doesn’t look like a button, then search for ‘webhook’. Step two the only option is “Receive a web request”, let’s do that. Call the Event ‘iotDoorbell’. Now click +That, search for Pushover, and select “Send a Pushover Notification”.
Now we build out the notification itself. Set the title to ‘Ring!’ and the message to ‘Someone is at the door’. If you are very concerned that you’ll never miss someone ringing the bell, change the priority to Emergency, which will buzz you every thirty seconds until you acknowledge the alert.
Create the event, and label it ‘If AWS IoT Dash Button Pushed, Send Notification’ (I’m a big fan of descriptive names, if you couldn’t tell!). We now have the endpoint that will kick off our alert, but we need an API key to be able to hit it. Go to this page to see what your “Maker Webhook” settings are. Specifically, it will have a URL that contains a very long string of garbage at the end of it. That’s your API key, grab it, we’re about to use it.
We’ve finally backed our way up to Amazon. Hopefully you already have an AWS account, if not, go sign up for one. For this, we are going to create a new Lambda function. Use the latest Node.js runtime (12.x as of this writing), call it something memorable (“iOT Button Doorbell” works), and make sure to select “Create a new role with basic Lamda permissions”.
We’re finally to the actual Lambda code. When you copy and paste this, please make sure to change the API Key to the long string that you grabbed a couple of paragraphs ago, and also make sure that the makerEvent
name matches exactly what you called the webhook when you were creating it on IFTTT.
'use strict';
const https = require('https');
const makerKey = '<ifttt API key>'; // change it to your Maker key
exports.handler = (event, context, callback) => {
console.log('Received event:', event);
// make sure you created a receipe for event <serialNumber>-<clickType>
const makerEvent = `iotDoorbell`;
const url = `https://maker.ifttt.com/trigger/${makerEvent}/with/key/${makerKey}`;
https.get(url, (res) => {
let body = '';
console.log(`STATUS: ${res.statusCode}`);
res.on('data', (chunk) => body += chunk);
res.on('end', () => {
console.log('Event has been sent to IFTTT Maker channel');
callback(null, body);
});
}).on('error', (e) => {
console.log('Failed to trigger Maker channel', e);
callback(`Failed to trigger Maker channel: ${e.message}`);
});
};
And finally, we’ve backed our way up all the way to the actual button. Download the iOS app for managing the buttons. Follow the on-screen instructions for adding the button to your account. If you don’t have the original box (because you bought this second-hand or found one lying on the street), the code they want is on the back. You’ll have to login to your AWS account and make sure that your region matches wherever you created your Lambda function.
And now you’re set! Push the button, and your phone should start buzzing and chirping and annoying you to no end. Duct tape the button to the side of your front door and you’re good to go. Or, more seriously, I did all of this to send an alert that my next-door neighbor needed help (she was an elderly lady who had fallen down a few times and I wanted to make sure I was only ever a button push away).
But you have the full power of IFTTT at your finger tips - this doesn’t have to just be an alerting system1. Want to send a tweet that says “Poopin’” every time you hit a button? That power is (literally) at your finger tips. Go forth and find all the uses for a single-use button there are.
-
In fact, you’ll notice that there’s actually no reason to use IFTTT for any of this - Pushover offers a web api, one that we could absolutely call within our Lambda function. Feel free to do that as an exercise, if you do want to keep this as a pure alerting thing. ↩︎