You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Once the dynamic group is created, we can iterate on devices in that group to apply the configuration.
For example:
using Amazon.IotData;
using Amazon.IotData.Model;
using Newtonsoft.Json.Linq;
// Define the device group details
string groupName = "my-group";
string desiredState = "{ \"power\": \"on\", \"brightness\": 80 }";
// Create a new instance of the AWS IoT Data client
var iotDataClient = new AmazonIotDataClient();
// Retrieve the list of devices in the group
var listThingsRequest = new ListThingsInThingGroupRequest
{
ThingGroupName = groupName
};
var listThingsResponse = await iotClient.ListThingsInThingGroupAsync(listThingsRequest);
// Update the device shadows of the devices in the group
foreach (var thing in listThingsResponse.Things)
{
var updateShadowRequest = new UpdateThingShadowRequest
{
ThingName = thing.ThingName,
ShadowName = "default",
Payload = JObject.Parse(desiredState)
};
var updateShadowResponse = await iotClient.UpdateThingShadowAsync(updateShadowRequest);
// Synchronize the device shadows with the devices
var getShadowRequest = new GetThingShadowRequest
{
ThingName = thing.ThingName,
ShadowName = "default"
};
var getShadowResponse = await iotClient.GetThingShadowAsync(getShadowRequest);
var reportedState = JObject.Parse(getShadowResponse.Payload.ToString())["state"]["reported"];
}
The text was updated successfully, but these errors were encountered:
US: #1868
Description
Once the dynamic group is created, we can iterate on devices in that group to apply the configuration.
For example:
The text was updated successfully, but these errors were encountered: