[PYTHON] I tried to unlock the entrance 2 lock sesame with a single push of the AWS IoT button

Background etc.

Positioning of this article

I wrote an article here I made an IFTTT button that unlocks the entrance 2 lock sesame with 1 button (via AWS Lambda). However, it is an article that seems to be able to do such a thing by applying the Lambda function created at that time.

Preceding case

Candy hosue, the publisher of Sesame, published an article in 2018, and I also tried hands-on this once. (The AWS IoT button was bought at that time). However, with the method in this article, only one sesame can be unlocked, so I wanted to unlock two sesame with the touch of a button, so I created the method in this article.

What is an AWS IoT button

This guyis. It is a button that can stimulate IoT 1-Click and Lambda on AWS with the push of a button.

What i did

1. AWS IoT button registration and network connection

Official article

―― 2. Set up the AWS lot 1 click app

All you have to do is follow the steps in.

2. Get API key and Sesame ID for 2 cars

Obtain the API key and sesame ID as described in 1. in the following article.

-I made an IFTTT button that unlocks the entrance 2 lock sesame with one button (via AWS Lambda)

3. Preparation of Lambda function

3-1. Function launch and pysesame2 upload

Launch the function from AWS Lambda and upgrade the external module pysesame2 as described in 2-1. and 2-2. in the following article.

-I made an IFTTT button that unlocks the entrance 2 lock sesame with one button (via AWS Lambda)

3-2. Writing Python code

Write the following code. It's a Python version, but I wonder if 3.8 is fine.

lambda_function.py


from uuid import UUID
from pysesame2 import Sesame
import os

device_id_1 = UUID(os.environ['DEVICE_ID_1'])
device_id_2 = UUID(os.environ['DEVICE_ID_2'])
APIKey = os.environ['APIKEY']
sesame_1 = Sesame(device_id_1, APIKey)
sesame_2 = Sesame(device_id_2, APIKey)

def lambda_handler(event, context):
    sesame_1.async_unlock()
    sesame_2.async_unlock()

After writing the code, write the API key obtained in step 1. and the two sesame IDs one by one in the" environment variable "below it and save it. image.png

3-3. Test

After completing the above, execute the function test from "Test" on the upper right of the screen. The JSON to be poured can be hello world or anything. Success if two sesame are unlocked.

4. Create an IoT 1-Click project and associate buttons with Lambda functions

Official article

―― 4. Create a project on AWS ―― 5. Link the AWS IoT button

Follow the steps in to associate the IoT button with the Lambda function. Success if you press the button and unlock the two sesame! !! !! : grin:

Recommended Posts

I tried to unlock the entrance 2 lock sesame with a single push of the AWS IoT button
I made an IFTTT button that unlocks the entrance 2 lock sesame with 1 button (via AWS Lambda)
I tried to create a model with the sample of Amazon SageMaker Autopilot
I tried to make something like a chatbot with the Seq2Seq model of TensorFlow
I tried to find the entropy of the image with python
I tried to find the average of the sequence with TensorFlow
I wrote a doctest in "I tried to simulate the probability of a bingo game with Python"
I tried to automate the watering of the planter with Raspberry Pi
[Introduction to StyleGAN] I played with "The Life of a Man" ♬
I tried to create a list of prime numbers with python
I tried to register a station on the IoT platform "Rimotte"
I tried to expand the size of the logical volume with LVM
I tried to improve the efficiency of daily work with Python
I tried to make a mechanism of exclusive control with Go
I tried to predict the number of domestically infected people of the new corona with a mathematical model
I tried to solve the first question of the University of Tokyo 2019 math entrance exam with python sympy
I tried to create a plug-in with HULFT IoT Edge Streaming [Development] (2/3)
I tried to get the authentication code of Qiita API with Python.
I tried to automatically extract the movements of PES players with software
I tried to create a plug-in with HULFT IoT Edge Streaming [Execution] (3/3)
I tried to analyze the negativeness of Nono Morikubo. [Compare with Posipa]
I tried to streamline the standard role of new employees with Python
I tried to visualize the text of the novel "Weathering with You" with WordCloud
I tried to get the movie information of TMDb API with Python
I tried to create a plug-in with HULFT IoT Edge Streaming [Setup] (1/3)
I tried to display the altitude value of DTM in a graph
I tried to verify the result of A / B test by chi-square test
I tried to make a url shortening service serverless with AWS CDK
I tried to predict the behavior of the new coronavirus with the SEIR model.
I tried to make a thumbnail image of the best avoidance flag-chan! With RGB values ​​[Histogram] [Visualization]
I tried to save the data with discord
I tried to touch the API of ebay
I tried to correct the keystone of the image
I tried to predict the price of ETF
I tried to vectorize the lyrics of Hinatazaka46!
I tried to make a simple mail sending application with tkinter of Python
When I tried to make a VPC with AWS CDK but couldn't make it
I failed to install django with pip, so a reminder of the solution
I tried to easily visualize the tweets of JAWS DAYS 2017 with Python + ELK
I tried to create a button for Slack with Raspberry Pi + Tact Switch
[Introduction to AWS] I tried porting the conversation app and playing with text2speech @ AWS ♪
The story of making soracom_exporter (I tried to monitor SORACOM Air with Prometheus)
I tried to automatically send the literature of the new coronavirus to LINE with Python
[Python & SQLite] I tried to analyze the expected value of a race with horses in the 1x win range ①
I wanted to know the number of lines in multiple files, so I tried to get it with a command
I tried to learn the sin function with chainer
I tried to create a table only with Django
I tried to extract features with SIFT of OpenCV
I tried to notify the update of "Become a novelist" using "IFTTT" and "Become a novelist API"
I want to transition with a button in flask
I tried to summarize the basic form of GPLVM
I tried to touch the CSV file with Python
I tried to draw a route map with Python
I tried to put out the frequent word ranking of LINE talk with Python
I tried to solve the soma cube with python
I tried to automate the article update of Livedoor blog with Python and selenium.
[MQTT] I tried talking with the device using AWS IoT Core and Soracom Beam
[Python] I tried to automatically create a daily report of YWT with Outlook mail
I tried to visualize the characteristics of new coronavirus infected person information with wordcloud
I tried to automatically generate a password with Python3
I tried to put HULFT IoT (Agent) in the gateway Rooster of Sun Electronics