我正在尝试修改here提供的快速示例。
我试图添加一些自定义传感器数据类型,但是失败了。然后,我尝试了文档中提到的一些数据类型,但也失败了。
我遇到错误了
Creating Sensor: {
"DataType": "Noise",
"DeviceId": "some-device-id",
"HardwareId": "SAMPLE_SENSOR_NOISE"
}
Request: POST
https://******.*******.azuresmartspaces.net/management/api/v1.0/sensors
Response Status: 404, NotFound , {"error":
{"code":"404.600.000.001","message":"There is no SensorDataType of the
given name."}}
答案 0 :(得分:1)
创建Sensor对象时,您需要发布DataType。如果以后要更改,请使用“无”。 Swagger DOC显示可以扩展的“模型”并查看必填字段。
如果DataType不在api / v1 / system / types中,则需要启用它或创建一个新的DataType。使用所需的信息将新的DataType POST创建到Types。最小的是要在其下整型的TypeName和SpaceID。我的典型模式是创建一个根空间并将任何自定义的孪生对象(如类型)附加到该空间。
我相信这些也是区分大小写的名称。
https://{servicename}.{region}.azuresmartspaces.net/management/swagger/ui/index#/Types
编辑:
使用以下方法检查您的本体
https://{servicename}.{region}.azuresmartspaces.net/management/api/v1.0/ontologies
通过ID和POST选择它们,将它们设置为true,以获取所有可用的内置类型:
[
{
"id": 1,
"name": "Required",
"loaded": true
},
{
"id": 2,
"name": "Default",
"loaded": true
},
{
"id": 3,
"name": "BACnet",
"loaded": true
},
{
"id": 4,
"name": "Advanced",
"loaded": true
}
]
然后,您可以查询所有给定的类型:
https://{servicename}.{region}.azuresmartspaces.net/management/api/v1.0/types?includes=Description,FullPath,Ontologies,Space
您应该会收到类似以下内容:
[
{
"id": 1,
"category": "DeviceSubtype",
"name": "None",
"disabled": false,
"logicalOrder": 0,
"fullName": "None",
"spacePaths": [
"/system"
],
"ontologies": [
{
"id": 1,
"name": "Required",
"loaded": true
}
]
},
{
"id": 2,
"category": "DeviceType",
"name": "None",
"disabled": false,
"logicalOrder": 0,
"fullName": "None",
"spacePaths": [
"/system"
],
"ontologies": [
{
"id": 1,
"name": "Required",
"loaded": true
}
]
},
{
"id": 3,
"category": "DeviceBlobSubtype",
"name": "None",
"disabled": false,
"logicalOrder": 0,
"fullName": "None",
"spacePaths": [
"/system"
],
"ontologies": [
{
"id": 1,
"name": "Required",
"loaded": true
}
]
},
...Objects,
]