LoginSignup
0
0

More than 1 year has passed since last update.

AWS IOT の Device Shadow

Last updated at Posted at 2021-09-26

次のページを参考にしました。
AWS IoTのThing Shadowsを図と実行例で理解する

次のバージョンで確認しました。

$ aws --version
aws-cli/2.2.41 Python/3.8.8 Linux/5.14.7-arch1-1 exe/x86_64.arch prompt/off

Thing の作成

create_thing.sh
THING="sample_sep26"
aws iot create-thing --thing-name ${THING}

Thing の一覧

list_things.sh
aws iot list-things | grep thingName

Thing の削除

delete_thing.sh
THING="sample_sep26"
aws iot delete-thing --thing-name ${THING}

Shadow の作成
shadow_sep26_aa.png

Unnamed (classic) Shadow を作成します。
shadow_sep26_bb.png

デバイスの状態が OFF であることを通知

report_off_thing.sh
THING="sample_sep26"
#
aws iot-data update-thing-shadow --thing-name ${THING} \
    --cli-binary-format raw-in-base64-out \
  --payload '{"state": {"reported" : {"led" : "off"}}}' \
  report01.json

デバイスの状態が ON であることを通知

report_on_thing.sh
THING="sample_sep26"
#
aws iot-data update-thing-shadow --thing-name ${THING} \
    --cli-binary-format raw-in-base64-out \
  --payload '{"state": {"reported" : {"led" : "on"}}}' \
  report02.json

デバイスを OFF にするように指令

command_off_thing.sh
THING="sample_sep26"
#
aws iot-data update-thing-shadow --thing-name ${THING} \
    --cli-binary-format raw-in-base64-out \
  --payload '{"state": {"desired" : {"led" : "off"}}}' \
  command01.json

デバイスを ON にするように指令

command_on_thing.sh
THING="sample_sep26"
#
aws iot-data update-thing-shadow --thing-name ${THING} \
    --cli-binary-format raw-in-base64-out \
  --payload '{"state": {"desired" : {"led" : "on"}}}' \
  command01.json

Shadow の状態を取得

get_shadow.sh
THING="sample_sep26"
#
aws iot-data get-thing-shadow --thing-name ${THING} outfile.json
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0