Azure / azure-iot-hub-python

Azure IoT Hub Data Plane Python SDK
MIT License
15 stars 11 forks source link

get_module_twin occasionally returning incomplete data #12

Closed mquilling closed 1 year ago

mquilling commented 1 year ago

My code is pretty simple, a loop setting a desired property new_version if the new version is different. The issue is that on some iterations I am not getting back the full twin and missing the properties field

newest_config_id = 'test'
device_id = 'test'
hw_twin = registry.get_module_twin(device_id, "hw")
if hw_twin.properties.desired.get('new_version') != newest_config_id:
    print('updating')
    registry.update_module_twin(device_id, "hw", Twin(properties=TwinProperties(desired={'new_version': newest_config_id})))

my expectation is that updating prints once and never again, but i will occasionally get

{'$metadata': {'$lastUpdated': '2023-06-23T00:27:29.5939778Z', '$lastUpdatedVersion': 80, '$lastUpdatedBy': 'dev-5139c44-1687478049', '$lastUpdatedByDigest': '638230755398682044'}, '$version': 80}

as a response from get_module_twin and nothing else.

mquilling commented 1 year ago

closing - this was due to specify desired props in the layered deployment, it was overwriting them back to {}.