Description
Is your feature request related to a problem? Please describe.
Version 1 of aws-iot-device-sdk-python required the developer to send a JSON payload containing the contents of the shadow. Version 2 abstracts this functionality away with iotshadow.ShadowState. This is a convenient way for a programmer to specify the reported and desired fields of an MQTT request. However, MQTT allows the user to clear the reported, desired, and fields by sending a null value in the JSON payload. In v1, the programmer could accomplish this by doing something like:
my_json_payload[state][desired] = None
The v1 SDK would then convert the Python 'None' into null in the JSON document.
{
"state": {
"desired": null
}
}
However, the v2 implementation sets any unspecified field to None (found here).
Describe the solution you'd like
I would like the ability to clear the desired and reported fields by setting them to None, or by some other process.
Describe alternatives you've considered
My current workaround involves keeping a local copy of the desired field, entitled self.shadow_desired, and setting each property to None, if the situation sets clear_desired to True. (self.shadow_reported is my local copy of the reported field - always set by me).
if clear_desired:
state = iotshadow.ShadowState(
reported=self.shadow_reported,
# If desired was present, the attributes are nulled
# If desired was not present, this is an empty dict
desired={k:None for k in self.shadow_desired.keys()}
)