我正在尝试使用传感器创建一个新设备。
这是我为创建新设备而发送的有效负载:
{"Name":"DeviceABC","HardwareId":"D4xxx425","SpaceId":"xxxx-xxx-xx-xx-xxx","Status":"Provisioned","CreateIoTHubDevice":false,"Properties":[{"Name":"VendorName","Value":"MyVendor"},{"Name":"VendorDeviceId","Value":"D4xxx19425"},{"Name":"VendorDeviceType","Value":"electricity"}],"Sensors":[{"pollRate":0,"id":null,"dataType":"Json","dataUnitType":"KilowattHourEnergy","deviceId":null,"portType":null,"port":"electricity","spaceId":null,"type":"Classic"}]}
在这种情况下,我想使用内置类型。千瓦时
{
"id": 186,
"category": "SensorDataUnitType",
"name": "KilowattHourEnergy",
"disabled": false,
"logicalOrder": 0,
"friendlyName": "kWh"
}
SensorDataType 是:
{
"id": 314,
"spaceId": "xxxx-xx-xxx-xx-xxxx",
"category": "SensorDataType",
"name": "Json",
"disabled": false,
"logicalOrder": 0
}
当我为其他设备执行此操作而不在传感器对象中指定 dataUnitType 时,它工作正常。但只要我把它包括在内,我就会得到这个:
{
"error": {
"code": "400.600.000.000",
"message": "Invalid datatype/dataunittype combination used on sensor."
}}