Using IoT Device shadow for non registered IoT Core devices connected to local gateway


I have a system with actuators (switches) which connect to a local gateway registered as an “IoT thing” and connects to IoT Core. The gateway subscribes to the topics below and translates messages sent on these topics into HTTP requests to individual devices. The switch devices do not have certificates and do not connect to IoT core, only the local gateway. In this scenario the gateway would need to manage the entire communication flow and translate these messages into HTTP responses for attached devices.

/gateway/<gateway_id>/<device_id> /switch/<gateway_id>/<device_id>

It is possible to use Device Shadows for switch devices that are connected to a local gateway but are not “IoT things” and if so what would implementation look like? From what I understand “named shadows” would allow me to represent a gateway with multiple attributes e.g. switches to which I can manage the state?

asked a year ago269 views
1 Answer

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.


answered a year ago
  • 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:

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions