0

Is there a way to update a Cloud Property for an IoT Device in Azure IoT Hub?

The DTDL for the device Cloud Property is:

{
    "@id": "dtmi:solutionModel:modelDefinition:rkkkbmsz:brcdv6wcme:DeviceSerialNumber",
    "@type": [
        "Property",
        "Cloud",
        "StringValue"
    ],
    "displayName": {
        "en": "Device Serial Number"
    },
    "name": "DeviceSerialNumber",
    "schema": "string",
    "minLength": 1,
    "trimWhitespace": true
},

I am using the Azure IoT SDKs and C#.

deviceClient.UpdateReportedPropertiesAsync(reportedProperties, cancellationToken);

The property is showing up as "_unmodeleddata". The JSON is:

{
    "_unmodeleddata": {
        "DeviceSerialNumber": "dsn1i90NEW"
    },
    "_eventtype": "Property",
    "_timestamp": "2022-08-14T23:13:45.966Z"
}
Mike Lenart
  • 767
  • 1
  • 5
  • 19

1 Answers1

2

The Cloud Property declared in the DTDL model is visible only on the cloud facing side, in other words, there is no either any message exchange pattern between the device and IoT Hub or visibilities.

It based on the IoT Solution, where and how the Cloud Property is stored and managed. In the Azure IoT Hub the Cloud Property can be stored in the device twins such as the property tags.

In the Azure IoT Central, the Cloud Property is using own underlying storage (not the device twin tags) and the REST APIs for handling their values.

Note, that the IoT PnP Device should not send the Cloud Property to the IoT Hub, that's the reason why you are receiving _unmodeleddata for property DeviceSerialNumber

Roman Kiss
  • 7,925
  • 1
  • 8
  • 21
  • So are you saying that if I am using IoT Central it can only be done via the Rest API? – Mike Lenart Aug 16 '22 at 10:55
  • Currently, the Cloud Property in the Azure IoT Central App can be populated via the REST API or manually from the Views/Form, there is no SDKs. Note, that using the *Manage device/Device properties* feature in the IoT Central pane is for managing the device desired properties without the model respect, you can see it, when you send the { "DeviceSerialNumber": "1234" } – Roman Kiss Aug 16 '22 at 11:22
  • So there is no way to use the Azure IoT SDKs to update the Digital Twins for cloud properties for devices stored in IoT Central vs IoT Hub? – Mike Lenart Aug 16 '22 at 11:34
  • I just tried updating a Cloud property using the IoT Central APIs. I am getting Http Response code of 202. Are Cloud Properties Read Only? Do you know why I am getting a 202? – Mike Lenart Sep 04 '22 at 21:26
  • 1
    It looks like there is a bug for updating a cloud property in a respect of the device model and IoT Central extension to DTDL. The response code 202 (Accepted) should be used when the value is match with the IoT Extension to DTDL (such as Min value, Max value, etc.). In the case if the device model doesn't have this IoT Extension, the response value should be 200 (OK). Note, that the Form UI is working correct when the IoT Extension to DTDL is used it. – Roman Kiss Sep 08 '22 at 18:54