azure - 如何自动将设备与设备模板关联?
问题描述
我想自动将我的设备与其模板相关联。这里有一篇关于此的文章: 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
.
有人知道在注册中包含设备模板的正确方法吗?
解决方案
创建 ProvisioningDeviceClient 后,您需要将 provisioning_payload 属性设置为包含您在上面链接的每个文档中的模型 ID 的 JSON 字符串。
推荐阅读
- rxjs - Rxjs 管道 - 一个管道或多个管道中的多个运算符?
- python - 运行多个 Node.js 或 Python 脚本
- tensorflow - 频谱图数据的 LSTM 输入形状
- python - 当我使用 Tkinter 下拉框时,使用 WHERE 子句的 SQlite 查询没有给我正确的输出
- javascript - 如何根据特定条件禁用和启用 javascript 按钮?
- javascript - 为什么我不能用香草 javascript 开玩笑地调用 fetch?
- bash - 在bash中将文件名修剪为给定数量的字母的命令
- shell - npx:shell-auto-fallback 参数已被删除
- python - 当两者之一是 np.array(dtype=np.complex128).real 时,numpy matmul 非常慢
- javascript - 从输入类型 = 文件中选择图像并使用样式组件将其设置为背景