1개 답변
- 최신
- 최다 투표
- 가장 많은 댓글
1
Hi otl,
what is the use-case to use shadow devices for switch devices? Your gateway could interact with the shadows for your switch devices like subscribing to topics and publishing to topics. To use a shadow you don't need to have a thing in IoT Core's devices registry. A shadow is created when you update a shadow. From that moment on you can interact with the shadow. You can use classic or named shadows.
For named shadows you could for example use topics like $aws/things/GATEWAY/shadow/name/SWITCH_DEVICE.
Cheers,
Philipp
관련 콘텐츠
- 질문됨 4달 전
- AWS 공식업데이트됨 9달 전
- AWS 공식업데이트됨 2년 전
- AWS 공식업데이트됨 일 년 전
- AWS 공식업데이트됨 3년 전
Thank you for the reply Philipp! My use-case is to manage the state of switches connected to the gateway e.g. on/off.
Currently, upon a request to "turn on" a switch from a mobile app, the swtich responds with its status and this state is stored in a database. However this transition is proving to be unreliable which is likely due to a bug in our application code. From what I understand reading IoT Atlas/Whitepapers, the recommended way is to use Device Shadows to manage the state transition to abstract the device from the app layer so we dont need to use a database to store the state? Thanks again.
Hi otl. A key advantage of using a shadow for command/control is decoupling your application from the device. Your application need not ask the question "is the device online?" before sending the message. It can just change the shadow and be safe in the knowledge the device will synchronize the change the next time it's online. (Which may be immediately if it's already online.)
Per Philipp's answer, you don't need things to use shadows. You might have a Thing for your gateway, with it having a collection of named shadows; perhaps one per switch attached to the gateway. However your gateway will need to interact with the shadow MQTT topics. Longer term, you might consider using AWS IoT Greengrass on your gateway, and its Shadow manager: https://docs.aws.amazon.com/greengrass/v2/developerguide/shadow-manager-component.html