在向IoT Central注册和配置设备时将特定名称添加到设备

问题描述

我正尝试使用示例Github- Iot_Central_Python_Sample

在IoT中心上注册和配置设备(使用Azure python sdk)

此示例代码还具有在注册过程中将模板分配给设备的选项,可以使用以下方法完成:

provisioning_device_client.provisioning_payload = '{"iotcModelId":"%s"}' % (model_identity)

IoT中心上的设备信息和设备信息一旦注册

enter image description here

这里的想法是在设备注册期间在有效负载中发送信息。同样,我们也可以在有效负载中发送任何其他信息。 现在,我要更改的设备名称为“ xyz_device”。我尝试将上述有效负载中的设备名称发送为:

provisioning_device_client.provisioning_payload = '{"iotcModelId":"%s","iotcDisplayName":"%s"}' % (model_identity,"xyz_device")

但是无法在IoT中心上更改设备的名称。除了使用“ iotcDisplayName”作为键之外,我还尝试使用“ iotcDeviceName”,但仍然没有成功。

可以帮助我在设备注册期间如何在IoT Central上更改设备名称。

我们将不胜感激。

解决方法

没有文档将描述用于自定义IoT Central应用程序的设备置备的有效负载对象。 here是使用有效负载在设备注册调用期间传递其他属性的某些功能。

但是,要更改设备名称,可以使用REST API Devices - Set,请参见以下示例:

PUT

https://rk2020iotc.azureiotcentral.com/api/preview/devices/groupdpsttestdevice2

标题:

Authorization:<sas-token>

正文:

{
    "displayName":"xyz_device","instanceOf":"urn:q4wlmqvfhh:modelDefinition:ckuivfcyep"
}

enter image description here

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...