Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
AWSIotData iotDataClient = AWSIotDataClientBuilder
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(CLIENT_TOKEN, CLIENT_SECRET))).build();
String thingName = "plant-manager";
GetThingShadowResult getThingShadowResult = iotDataClient.getThingShadow(new GetThingShadowRequest().withThingName(thingName));
String state = new String( getThingShadowResult.getPayload().array(), StandardCharsets.UTF_8);
// state is now a JSON string representing the plant-manager Thing Shadow's state
/* {
// To update state, send an UpdateThingShadowRequest containing JSON with your requisite "desired" properties and values
String desiredJson = "{ "desired": { "watering": true } }";
UpdateThingShadowRequest shadowRequest = new UpdateThingShadowRequest()
UpdateThingShadowResult result = iotDataClient.updateThingShadow(shadowRequest);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment