我正在使用"('azure-iothub').Registry“来获取设备孪生数据。
strQuery = `SELECT * FROM devices where deviceId IN [${deviceIds}]`;
query = registry.createQuery(strQuery, 500);但是设备双胞胎没有"connectionStateUpdatedTime“属性。根据MS文档,它在设备标识中。https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-identity-registry#device-identity-properties
有获得"connectionStateUpdatedTime“属性的方法吗?
发布于 2021-08-03 10:33:18
您将不会使用connectionStateUpdatedTime获得上述方法,因为它在模式下面返回:
{
"deviceId": "myDeviceId",
"etag": "AAAAAAAAAAc=",
"status": "enabled",
"statusUpdateTime": "0001-01-01T00:00:00",
"connectionState": "Disconnected",
"lastActivityTime": "0001-01-01T00:00:00",
"cloudToDeviceMessageCount": 0,
"authenticationType": "sas",
"x509Thumbprint": {
"primaryThumbprint": null,
"secondaryThumbprint": null
},
"version": 2,
"tags": {
"location": {
"region": "US",
"plant": "Redmond43"
}
},
"properties": {
"desired": {
"telemetryConfig": {
"configId": "db00ebf5-eeeb-42be-86a1-458cccb69e57",
"sendFrequencyInSecs": 300
},
"$metadata": {
...
},
"$version": 4
},
"reported": {
"connectivity": {
"type": "cellular"
},
"telemetryConfig": {
"configId": "db00ebf5-eeeb-42be-86a1-458cccb69e57",
"sendFrequencyInSecs": 300,
"status": "Success"
},
"$metadata": {
...
},
"$version": 7
}
}
}您指的是标识注册表,它是设备或模块标识资源的一个支持REST的集合。当您在标识注册中心中添加一个条目时,IoT集线器会创建一组每个设备的资源,例如包含飞行云到设备消息的队列。有关导入和导出API的更多信息,请参见IoT集线器资源提供者REST。
对于您的需求,您可以使用https://learn.microsoft.com/en-us/rest/api/iothub/service/devices/get-devices API。
GET https://fully-qualified-iothubname.azure-devices.net/devices?api-version=2020-05-31-preview这将给您作为https://learn.microsoft.com/en-us/rest/api/iothub/service/devices/get-devices#device数组的响应,该数组将具有connectionStateUpdatedTime__。
如果您有后续问题,或者我是否不正确地理解了您的问题,请告诉我。
https://stackoverflow.com/questions/68632170
复制相似问题