Giter Club home page Giter Club logo

checkedmailbutton's Introduction

checkedMailButton

Lambda Handler for IoT Dash checkedMailButton

IoT Button I wanted to play with the AWS IoT Button and racked my brain to think of how to use it. In our house whoever gets home first checks the mail and then texts the other person to let them know. Believe it or not texting two words “checked mail” every day can get tedious. Even using “Ok google, send message to…” gets tiresome. So I’ve configured my button so a SINGLE click texts my phone with the message “Cathy checked the mail.” A DOUBLE click texts my wife’s phone with “Kyle checked the mail.” And a LONG click texts my phone with the button’s remaining battery voltage.


Step 1: Setting up the IoT Button

You will need a laptop or computer with WiFi in order to connect with and configure your IoT Button. This comes in handy later when you find yourself copying/pasting information. This step assumes that you have already created and logged in to your AWS account.
  1. Go to https://aws.amazon.com/iot/button/
  2. Click on [Go to Configuration Wizard].
  3. Select "IoT Button" from the IoT Type drop-down menu.
  4. Enter your device serial number found on the back of Button.
  5. Follow the steps in the Wizard to connect to your Button and configure it to connect to WiFi and register it with AWS IoT.
  6. Continue the steps to create the Lambda function using the provided sample code. We will update that in the Step 3 but for now update the sample code using your email address.
  7. At this point click your button and it will email you the test message. The sample Lambda function will create the SNS topic that you will configure in Step 2.

Step 2: Subscribe Cellular Numbers to SNS

The sample Lambda function creates an SNS topic named ‘aws-iot-button-sns-topic’ the first time it is executed. In this step we will add our cellular numbers to that topic to allow sending SMS messages.
  1. Go to the Amazon SNS Console.
  2. Click on Topics from the left hand menu.
  3. Locate the ‘aws-iot-button-sns-topic’ Topic and click on its ARN.
  4. Click on [Create Subscription].
  5. Select ‘SMS’ for Protocol.
  6. For Endpoint enter your cellular number in the 1-138-867-5309 format.
  7. Click on [Create Subscription].
  8. Repeat substeps 4-7 for an additional cellular number.

Step 3: Update Lambda Function

After the sample code has created the SNS Topic updated in Step 2 it has served its purpose. We will store the target phone numbers and messages in Lambda environment variables and then overwrite the sample code with the code in index.js.
/**
 * The following JSON template shows what is sent as the payload:
{
    "serialNumber": "GXXXXXXXXXXXXXXXXX",
    "batteryVoltage": "xxmV",
    "clickType": "SINGLE" | "DOUBLE" | "LONG"
}
 *
 * A "LONG" clickType is sent if the first press lasts longer than 1.5 seconds.
 * "SINGLE" and "DOUBLE" clickType payloads are sent for short clicks.
 *
 * For more documentation, follow the link below.
 * http://docs.aws.amazon.com/iot/latest/developerguide/iot-lambda-rule.html
 */
  1. Go to the Amazon Lambda Console.
  2. Copy and paste the contents of index.js into your Lambda function.
  3. Assign an environment variable with the Key of Number1 and Value of +11388675309 (Substitute your actual number.)
  4. Assign an environment variable with the Key of Message1 and the Value of Alice checked the mail. (Substitute your actual name.)
  5. Repeat substeps 3-4 for the second target cellular number using the Keys of Number2 and Message2.
  6. Click on [Save] and click your Button again to test.

Credits:

As usual, I haven't come up with all of this myself. Inspiration was found from the links below:

checkedmailbutton's People

Contributors

kyle138 avatar

Stargazers

Kevin Sandí avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.