AWSIoTPythonSDK.core.shadow.deviceShadow

Functions

Classes

deviceShadow(srcShadowName, ...) The class that denotes a local/client-side device shadow instance.
class AWSIoTPythonSDK.core.shadow.deviceShadow.deviceShadow(srcShadowName, srcIsPersistentSubscribe, srcShadowManager)

The class that denotes a local/client-side device shadow instance.

Users can perform shadow operations on this instance to retrieve and modify the corresponding shadow JSON document in AWS IoT Cloud. The following shadow operations are available:

  • Get
  • Update
  • Delete
  • Listen on delta
  • Cancel listening on delta

This is returned from AWSIoTPythonSDK.MQTTLib.AWSIoTMQTTShadowClient.createShadowWithName function call. No need to call directly from user scripts.

shadowGet(srcCallback, srcTimeout)

Description

Retrieve the device shadow JSON document from AWS IoT by publishing an empty JSON document to the corresponding shadow topics. Shadow response topics will be subscribed to receive responses from AWS IoT regarding the result of the get operation. Retrieved shadow JSON document will be available in the registered callback. If no response is received within the provided timeout, a timeout notification will be passed into the registered callback.

Syntax

# Retrieve the shadow JSON document from AWS IoT, with a timeout set to 5 seconds
BotShadow.shadowGet(customCallback, 5)

Parameters

srcCallback - Function to be called when the response for this shadow request comes back. Should be in form customCallback(payload, responseStatus, token), where payload is the JSON document returned, responseStatus indicates whether the request has been accepted, rejected or is a delta message, token is the token used for tracing in this request.

srcTimeout - Timeout to determine whether the request is invalid. When a request gets timeout, a timeout notification will be generated and put into the registered callback to notify users.

Returns

The token used for tracing in this shadow request.

shadowDelete(srcCallback, srcTimeout)

Description

Delete the device shadow from AWS IoT by publishing an empty JSON document to the corresponding shadow topics. Shadow response topics will be subscribed to receive responses from AWS IoT regarding the result of the get operation. Responses will be available in the registered callback. If no response is received within the provided timeout, a timeout notification will be passed into the registered callback.

Syntax

# Delete the device shadow from AWS IoT, with a timeout set to 5 seconds
BotShadow.shadowDelete(customCallback, 5)

Parameters

srcCallback - Function to be called when the response for this shadow request comes back. Should be in form customCallback(payload, responseStatus, token), where payload is the JSON document returned, responseStatus indicates whether the request has been accepted, rejected or is a delta message, token is the token used for tracing in this request.

srcTimeout - Timeout to determine whether the request is invalid. When a request gets timeout, a timeout notification will be generated and put into the registered callback to notify users.

Returns

The token used for tracing in this shadow request.

shadowUpdate(srcJSONPayload, srcCallback, srcTimeout)

Description

Update the device shadow JSON document string from AWS IoT by publishing the provided JSON document to the corresponding shadow topics. Shadow response topics will be subscribed to receive responses from AWS IoT regarding the result of the get operation. Response will be available in the registered callback. If no response is received within the provided timeout, a timeout notification will be passed into the registered callback.

Syntax

# Update the shadow JSON document from AWS IoT, with a timeout set to 5 seconds
BotShadow.shadowUpdate(newShadowJSONDocumentString, customCallback, 5)

Parameters

srcJSONPayload - JSON document string used to update shadow JSON document in AWS IoT.

srcCallback - Function to be called when the response for this shadow request comes back. Should be in form customCallback(payload, responseStatus, token), where payload is the JSON document returned, responseStatus indicates whether the request has been accepted, rejected or is a delta message, token is the token used for tracing in this request.

srcTimeout - Timeout to determine whether the request is invalid. When a request gets timeout, a timeout notification will be generated and put into the registered callback to notify users.

Returns

The token used for tracing in this shadow request.

shadowRegisterDeltaCallback(srcCallback)

Description

Listen on delta topics for this device shadow by subscribing to delta topics. Whenever there is a difference between the desired and reported state, the registered callback will be called and the delta payload will be available in the callback.

Syntax

# Listen on delta topics for BotShadow
BotShadow.shadowRegisterDeltaCallback(customCallback)

Parameters

srcCallback - Function to be called when the response for this shadow request comes back. Should be in form customCallback(payload, responseStatus, token), where payload is the JSON document returned, responseStatus indicates whether the request has been accepted, rejected or is a delta message, token is the token used for tracing in this request.

Returns

None

shadowUnregisterDeltaCallback()

Description

Cancel listening on delta topics for this device shadow by unsubscribing to delta topics. There will be no delta messages received after this API call even though there is a difference between the desired and reported state.

Syntax

# Cancel listening on delta topics for BotShadow
BotShadow.shadowUnregisterDeltaCallback()

Parameters

None

Returns

None