multiple evolutions

This commit is contained in:
Quentin WEPHRE
2025-12-04 08:11:00 +01:00
parent e9715dc239
commit abd00f9e04
9 changed files with 403 additions and 264 deletions

View File

@@ -15,20 +15,21 @@ if CONNECTION_STRING == "":
print("Provide a connection string for the Iot Hub before running the script!")
exit(13)
SITE_NAME = "LIBERTY"
SITE_NAME = "Bell"
registry_manager = IoTHubRegistryManager.from_connection_string(CONNECTION_STRING)
query_spec = QuerySpecification(query="SELECT * FROM devices WHERE IS_DEFINED(tags.site) AND tags.site = '" + SITE_NAME + "' AND capabilities.iotEdge = true")
#query_spec = QuerySpecification(query="SELECT * FROM devices WHERE IS_DEFINED(tags.site) AND tags.site = '" + SITE_NAME + "' AND capabilities.iotEdge = true")
query_spec = QuerySpecification(query="SELECT * FROM devices WHERE IS_DEFINED(tags.site) AND tags.site = '" + SITE_NAME + "' AND capabilities.iotEdge = false")
query_result = registry_manager.query_iot_hub(query_spec)
devices = []
for item in query_result.items:
deviceId = str(item.device_id)
site = str(item.tags['site'])
number = int(item.tags['number'])
cloud_version = str(item.tags['version'])
site = str(item.tags.get('site')) if item.tags.get('site') else None
number = int(item.tags.get('number')) if item.tags.get('number') else None
cloud_version = str(item.tags.get('version')) if item.tags.get('version') else None
devices.append([deviceId, site, number, cloud_version])
ordered_devices = sorted(devices, key = lambda x: (x[1], x[2]))