aws-iot-button | Internet Button reference project : when a button | Cloud Functions library
kandi X-RAY | aws-iot-button Summary
kandi X-RAY | aws-iot-button Summary
This is an Internet Button reference project: when a button on the device is pressed, a cloud backend gets a notification and performs an action. In this particular case, AWS Lambda function sends an email to the specific email address. But, again, the action could be anything.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of aws-iot-button
aws-iot-button Key Features
aws-iot-button Examples and Code Snippets
Community Discussions
Trending Discussions on aws-iot-button
QUESTION
I am new to Lambda and am trying to write a function that will send an email with a fluid volume through SNS every 24 hours. This Lambda function is triggered by an IoT rule, and without the 24 hour limitation, the inbox will be flooded with emails. In CloudWatch, it looks like the email is being sent even if the email_sent flag is equal to 1. So it makes me think I have not structured my parentheses and brackets correctly? Does anyone see anything wrong with this code?
...ANSWER
Answered 2019-May-11 at 14:59So there's a two things I see that should be done differently.
First, you have this:
createTopic('aws-iot-button-sns-topic', (err, topicArn) => {
Right now your function is creating needless topics without ever deleting them, this is a problem. You should instead create the SNS topic externally and reference it here by either using Lambda environment variables or hard-coding the SNS topic arn. Or, first check if a topic with that name is already existing, and don't create it if it does.
Second, Lambdas don't run for longer than 900 seconds (15 minutes), so checking whether or not the script has been running for >24 hours is impossible.
What you should do instead is create a CloudWatch event trigger that runs every 24 hours using cron. This way, your lambda will run exactly one time every 24 hours (or whatever event you configure), and in the code you simply have to send the message once. There will then be no need to check what time it is or how many you already sent, since you know the event trigger happens only once, therefore your message gets sent once and your Lambda ends its execution right after.
The essence of Lambdas is they are short-lived and stateless, so design your service accordingly :)
Edit: After the comment, I understand the use case more...in this scenario, where the Lambda gets executed by IoT, I would personally store the previous execution time in SSM parameter store or DynamoDB, and then whenever the Lambda gets executed, I would get the value, check if 24 hours passed, and send the SNS if it did. You will have to do this because Lambda won't know otherwise when the last execution time was (and make sure to only update the last execution time on a successful SNS publish call, that eay you're sure that you sent a message that day)
QUESTION
Dear all AWS IoT developers I realized that I can only get three parameters as illustrated from the code below:
...ANSWER
Answered 2018-Apr-01 at 22:57According to this post by Stackoverflow link, json can only specify these parameters. Other parameters such as ""lat/log"" would be hard define.
A suggested solution for finding lat/long would probably by writing nodeJS code utilizing from npm googlemaps
.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install aws-iot-button
Follow the Cloud side setup instructions to setup AWS CLI utility and your AWS credentials
Follow the Device setup instructions to setup your device and provision it to the AWS IoT
Download this repository as a zip file and extract this app on your computer
Exit any running mos.exe process
Open a command prompt (on Windows) or terminal (on Mac/Linux) and go to the extracted app.
You should be able to see the mos.yml file by running dir mos.yml command (on Windows) or ls -l mos.yml (on Mac/Linux)
Find out your device ID
Run the following command to create AWS Cloud Formation stack. Change $DEVICE_ID to your actual device ID, and $MY_EMAIL to your email:
Wait until the stack creation is completed (it may take a few minutes). Alternatively, you can use the web UI to check the status and read event details: https://console.aws.amazon.com/cloudformation/home
During the stack creation, AWS will send a Subscription Confirmation email, so check your email and confirm the subscription by following a link.
Run the following command to ensure that the stack creation is complete:
Copy the fs/init.js file to your device:
Attach to the device to see the device logs
Reboot your device by pressing a reboot button
When the device is connected to the AWS IoT, push the "flash" button on your device. In the device's console, you'll see a message like this:
Now you can go to your AWS dashboard and play with your stack. For example, you may add more subscriptions to the SNS: other than sending emails, it can also call some URL, send SMS, etc. And, of course, you can modify your lambda function to do whatever you want in response to the button press.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page