MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.3k stars 21.48k forks source link

Device model used in the example doesn't work (dtmi:com:example:TemperatureController;2) #82593

Closed romankiss closed 2 years ago

romankiss commented 3 years ago

In the document is used a device model dtmi:com:example:TemperatureController;2 to demonstrate usage of the DTDL V2 in the IoT Central.

I have tried to add this device model into the IoT Central without any success result, using the following ways:

  1. device provisioning included the device modelId

  2. importing manually via the portal: https://raw.githubusercontent.com/Azure/iot-plugandplay-models/main/dtmi/com/example/temperaturecontroller-2.json
    btw. here, I would like to appreciate having also importing a device model based on its modelId.

  3. using a clipboard to paste the content of the device model such as in this case dtmi:com:example:TemperatureController;2 directly to the empty device template

It looks like, the IoT Central didn't support (always failed) a referencing a schema outside of the contents, see the following components:

 {
  "@type": "Component",
  "displayName": {
    "en": "thermostat1"
  },
  "name": "thermostat1",
  "schema": "dtmi:com:example:Thermostat;1"
},
{
  "@type": "Component",
  "displayName": {
    "en": "thermostat2"
  },
  "name": "thermostat2",
  "schema": "dtmi:com:example:Thermostat;2"
},
{
  "@type": "Component",
  "displayName": {
    "en": "DeviceInfo"
  },
  "name": "deviceInformation",
  "schema": "dtmi:azure:DeviceManagement:DeviceInformation;1"
}

So, Is this the IoT Central limitation or a bug?

Thanks Roman


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

SwathiDhanwada-MSFT commented 3 years ago

@romankiss Thanks for your comment. We will review the issue and get back to you shortly.

rido-min commented 3 years ago

Hi @romankiss

IoT Central resolves models from the IoT Plug and Play repository, you must send the dps payload using the format described here and also implemented in the device samples, eg: the TemperatureController .NET Sample

Can you share the exact payload you are sending to central?

When importing, Central follows the expanded format described in the DMR convention

The ModelId dtmi:com:example:TemperatureController;2 will be resolved using this URL https://devicemodels.azure.com/dtmi/com/example/temperaturecontroller-2.expanded.json

This file includes all the dependencies and can be manually imported in Central device templates.

This behavior is also documented in this article and supported in the device model repository SDK

I'd love to better understand your scenario, if you have 20 mins to chat, please reach out at rmpablos at ms dot com

Note: You can create device templates manually, but your must import each of the interfaces in the right order to satisfy the dependency graph.

romankiss commented 3 years ago

Hi @rido-min,

Thanks for prompt reply. I have no problem with a device provisioning. I am using the dps REST for a device provisioning process from the android and desktop applications included assigning a device template based on the modelId.

All process is working well for dps process included also the device template importing if it doesn't exist in the IoT Central.

During my testing, I found a trouble with the modelId dtmi:com:example:TemperatureController;2 which the IoT Central didn't resolve successfully and the provisioned device stayed without assigned a device template or stayed for last one.

My point is, once we have a valid device model in the repository, the consumer such as the IoT Central in this case, should be handled and resolved its importing properly without any manually adjusting.

So, in the case like of the dtmi:com:example:TemperatureController;2 I have to import manually its device model from the url https://devicemodels.azure.com/dtmi/com/example/temperaturecontroller-2.expanded.json in advance for later assigning. Btw. this url also made a trouble for validation at the Publish process, so again using a manually editing a component dtmi:azure:DeviceManagement:DeviceInformation;1 finally finish importing this device model into the IoT Central.

After the above manually process, all device provisioning included assigning and/or reassigning a device template succeeded.

I can accept the above workaround how to import the device model into the IoT Central, but finally it should be done straightforward based on the modelId either via the dps payload or during the device connectivity (once we have a device connection string, the same like we have it for IoT Hub) or manually

Thanks Roman

romankiss commented 3 years ago

Hi @rido-min,

In addition, the following are screen snippets from my apps such as the Azure IoT Hub Tester created long time ago for Azure IoT Hub and Azure IoT Central (DTDL V1). Note, that the version V2 is ready to publish it. The following screen snippet shows a virtual mqtt device device200 with a model dtmi:com:example:TemperatureController;2 connected to the IoT Central App. This virtual device allows to simulate a device model such as telemetry data, properties, etc. for each component.

image

The below screen snippet shows IoT Hub Tester version Phone (android). This version is still under construction and it will be published soon. The phone version will allow to replay the telemetry, properties, methods, etc. based on the capturing a real device:

image

The last screen snippet shows an IoT Central App with a connected device200 and its raw data:

iotc2

Thanks Roman

rido-min commented 3 years ago

During my testing, I found a trouble with the modelId dtmi:com:example:TemperatureController;2 which the IoT Central didn't resolve successfully and the provisioned device stayed without assigned a device template or stayed for last one.

TemperatureController;2 works in my tests. Can you share repro steps and error details? I suspect it fails based on the existing DTMIs in the existing templates, will be good to try in a brand new Central App.

I can manually import the expanded format, what issues do you have when publishing?

Those apps are amazing !! , are you willing to share more details (code, roadmap, etc..)?

/c @sandeeppujar for the issues with central.

romankiss commented 3 years ago

Hi @rido-min, I have created a new Central App. In this case, I was successful from my both apps such as desktop and phone to provision a device with the dtmi:com:example:TemperatureController;2 on the new and empty IoT Central App.

Next, I have provisioned more devices with the following device templates without any problem: dtmi:azureiot:PhoneAsADevice;2 dtmi:com:bluebird:ST102;1 dtmi:rigado:C500W;2 dtmi:mydevicesinc:elsys:elsys_ers;1 dtmi:brickcom:brickcom_m487_dev;1 dtmi:Bosch:XDK110;1

Then, I have tried to provision a device with the following device template, but with an unsuccessful result: dtmi:UK:co:clearwatercontrols:akp;1 https://raw.githubusercontent.com/Azure/iot-plugandplay-models/main/dtmi/uk/co/clearwatercontrols/akp-1.json

the same with the dtmi:Via:driverecorder;2, where the device template has been manually imported and also successfully published it, but doesn't work for device provisioning process.

In conclusion, using the new IoT Central App is much better than the last one from a week ago, but still there are the device templates like the following: dtmi:UK:co:clearwatercontrols:akp;1, dtmi:Via:driverecorder;2 which they are doesn't work with a device provisioning, in other words, there is no guarantee, that the device model stored in the repository will be imported to the IoT Central App during the provisioning process.

I have one more issue related with this. I have expected the same like at the IoT Hub, that the device template can be assigned during the connectivity process. So, once we have a device connection string, we can passed the modelId during the connection, in the case of IoT Central app this feature doesn't work. I hope, this is a bug and it will allow to assign or re-assign a device template also during the device connectivity process.

The phone version of my Azure IoT Tester will be published like others on the codeproject.

Thanks Roman

rido-min commented 3 years ago

seems you have a typo in dtmi:UK:co:clearwatercontrols:akp;1 , it should be dtmi:uk:co:clearwatercontrols:akp;1 (note the DTMIs are case sensitive).

Let me investigate what's the issue with dtmi:Via:driverecorder;2 and I will report back here.

Today Central only looks at the DPS payload to assign devices to a template, will be good to understand your use case to prioritize this feature.

romankiss commented 3 years ago

Hi @rido-min, thanks for pointing the case issue for modelId. So, the dtmi:uk:co:clearwatercontrols:akp;1 and dtmi:via:Driverecorder;2 are working well from my both applications.

It is not necessary to prioritize feature for assigning or reassigning a device model during the device connectivity, just to keep it the same as we have it for IoT Hub, so, once the device has a device connection string (for example cached it after the dps), the device can be assigned a device template during a connection process.

Thanks Roman

dominicbetts commented 2 years ago

Hi @romankiss - did you get all the answers you needed? If so I'll go ahead and close this issue. Thanks!

romankiss commented 2 years ago

Hi @dominicbetts, thanks for asking me, yes, I did it.

dominicbetts commented 2 years ago

please-close

romankiss commented 2 years ago

Hi @rido-min, I have just published my article with android implementation, like I mentioned it.

Azure IoT Central Tester

Thanks Roman

rido-min commented 2 years ago

very nice !!