首页 > 解决方案 > 如何自动将设备与设备模板关联?

问题描述

我想自动将我的设备与其模板相关联。这里有一篇关于此的文章: https ://docs.microsoft.com/en-us/azure/iot-central/core/concepts-get-connected#automatically-associate-with-a-device-template

示例代码在 JS 中,并表示包含iotcModelId: '< this is the URN for the capability model>'; OR '__iot:interfaces': { CapabilityModelId: <this is the URN for the capability model> }

我可以在 python 设备 SDK 文档中看到在客户端创建期间可用的关键字 args。 https://github.com/Azure/azure-iot-sdk-python/wiki/key-word-arguments-during-client-creations

但我在这些关键字中看不到任何关于设备模板的内容。我自己尝试了几种排列方式,但似乎没有任何效果,因为我正在使用ProvisioningDeviceClient.create_from_x509_certificate.

有人知道在注册中包含设备模板的正确方法吗?

标签: azureazure-iot-sdkazure-iot-central

解决方案


创建 ProvisioningDeviceClient 后,您需要将 provisioning_payload 属性设置为包含您在上面链接的每个文档中的模型 ID 的 JSON 字符串。


推荐阅读