قالب وردپرس درنا توس
Home / Tips and Tricks / How to program your own dash buttons with AWS – CloudSavvy IT

How to program your own dash buttons with AWS – CloudSavvy IT



IoT Enterprise Button

While the Dash buttons may have ceased, their design continues with AWS’s IoT buttons. Instead of ordering junk food, these can be set to trigger AWS Lambda functions, so you can script your own function with NodeJS and Python.

What does the IoT Enterprise button do?

The concept is quite simple. You press the button and it triggers a Lambda function, which is a serverless application running in the Amazon Web Services cloud and running whatever command or script you want it for. For example, you can have this button connect to the LIFX API to control your smart lights or any other smart device that has an API. You can even get them to connect to your Amazon account to order products for you, fill in the circle and create your own dashboard. The possibilities are really up to you; as long as you can program, you can let this button do almost anything.

What̵

7;s even better is that the button has three modes – single click, double click and long press – which are sent to the Lambda function and can trigger different actions based on the type of press. This essentially turns this button into three with the alternate modes.

They are a little more expensive than the $ 5 Dash buttons and come to $ 26 each. This is probably because the cost is not subsidized by feeding Amazon money just by tapping them. But for how useful these things are, it’s not a bad price, even compared to similar smart home buttons with smaller features. You can download them at (you guessed it) Amazon.

They are amazing and were actually surprisingly easy to set up and get started. The main issue, however, is latency – because these things are designed to remove a single battery for thousands of prints, they stay in low power mode until you press them. Because of this, it takes about four seconds for the button to turn on, connect to Wi-Fi and trigger the Lambda function. Depending on your use case, this may be a dealbreaker, but I’ve used one to control my smart lights instead of an automation hub and have not found it too annoying.

AWS makes some types of these IoT buttons, but the IoT Enterprise button is the upgrade version of the old “IoT button”. Above all, it is much easier to configure and manage distributions via the AWS “IoT 1-Click” service without having to install or manage certificates. For $ 20 per pop, and because they’re small enough to fit in your pocket, these buttons are great.

AWS also makes an LTE variant of this button, in combination with AT&T. Due to the nature of setting up a Wi-Fi-based IoT device like this, it is not very possible to provide the standard IoT Enterprise buttons to remote clients without configuring the buttons in place on their network. It’s a little more expensive, at $ 40, and is quite larger, but will work anywhere where there is a cell signal, and is reportedly much faster than the Wi-Fi-based variant. The settings for these should be mostly the same, as they use the same backend under the hood.

However, you can not really proceed with the installation until you order one, so you will probably want to bookmark this page for later and come back in a few days when it arrives.

Set an IoT button

When your button arrives, download the IoT button installation app for iOS or Android. This acts as a scanner that links buttons to your account. This requires you to be on the same Wi-Fi network as them, making installation super easy for the IoT Enterprise buttons.

Open the app, log in with your AWS account or IAM user information and select “Configure WiFi” in the IoT Enterprise section:

Select

This will bring up a scanner that asks you to scan the device ID that is on the device packaging. After scanning, you must claim the devices and put them in pairing mode by holding down the button for 6 seconds. This will connect to the device via Bluetooth and configure it with the WiFi credentials you have selected.

Claim the button by pressing the device for 6 seconds

You can add any number of devices this way, and if you have already configured your IoT project, you can add them directly from the app.

If you just follow along, you need to create a project to configure the settings for your devices and manage placements. Go to the IoT console in your browser and create a new project under Manage> Projects:

create new project

Give it a name and then proceed to the next screen. The first thing you need to add is a device template. This basically defines the type of device you are deploying and what action it triggers when pressed. If you are only configuring a device, you will still need to create a template to add it. If you have multiple devices, you can create multiple device templates for different actions or add multiple devices to the same template to have two buttons that do the same thing.

Your options send SMS, e-mail or trigger a Lambda function. You probably want to trigger a Lambda function, so select the function here. Annoyingly, there is no option to update this list, so if you just created a Lambda function for this template, you will need to refresh the page and start the project setting again.

add the device tempalte and select lambda function

It should complete the project. On the next screen, you choose to add a new “Device Location” that basically associates a physical device with a device template and a project and is used to track devices in the field.

create location

When done, connect the button. If you press it, it will run your selected Lambda function and generate a new press event in the log. If it does not work, you should test your Lambda function to make sure there is no problem with it and make sure the press appears in the log.

The press information is transferred to the Lambda function in event parameter for the handling function:

{
  deviceInfo: {
    deviceId: 'G030PM037162UXE3',
    type: 'button',
    remainingLife: 99.05,
    attributes: {
      projectRegion: 'us-east-1',
      projectName: 'LightSwitch',
      placementName: 'BathroomLightSwitch',
      deviceTemplateName: 'DeviceType'
    }
  },
  deviceEvent: {
    buttonClicked: { clickType: 'DOUBLE', reportedTime: '2019-12-22T04:32:28.325Z' }
  },
  placementInfo: {
    projectName: 'LightSwitch',
    placementName: 'BathroomLightSwitch',
    attributes: {},
    devices: { DeviceType: 'G030PM037162UXE3' }
  }
}

The most useful thing here is deviceEvent and clickType, which you can use in your function to perform various actions depending on whether the user single-clicked, double-clicked or long-pressed. If you ignore this value in your script, all types of presses will be the same.

From here, it’s up to you to program. You can read our guide to working with Lambda features to learn more.


Source link