diff --git a/common/src/main/java/com/google/udmi/util/MessageUpgrader.java b/common/src/main/java/com/google/udmi/util/MessageUpgrader.java index ecb6a66728..d07af787c1 100644 --- a/common/src/main/java/com/google/udmi/util/MessageUpgrader.java +++ b/common/src/main/java/com/google/udmi/util/MessageUpgrader.java @@ -220,10 +220,20 @@ private void upgradeTo_1_4_1_metadata() { ObjectNode gatewayTarget = new ObjectNode(NODE_FACTORY); gateway.put("target", gatewayTarget); - if (localnetFamilies.has("bacnet")) { - gatewayTarget.put("family", "bacnet"); + final String targetFamily; + if (gateway.has("family")) { + targetFamily = gateway.remove("family").asText(); + } else if (localnetFamilies.has("bacnet")) { + // Prioritise "bacnet" over any other value + targetFamily = "bacnet"; } else if (localnetFamilies.has("vendor")) { - gatewayTarget.put("family", "vendor"); + targetFamily = "vendor"; + } else { + targetFamily = null; + } + + if (targetFamily != null) { + gatewayTarget.put("family", targetFamily); } } diff --git a/tests/sites/downgrade/devices/AHU-102/expected/generated_config.json b/tests/sites/downgrade/devices/AHU-102/expected/generated_config.json new file mode 100644 index 0000000000..4d6e42f397 --- /dev/null +++ b/tests/sites/downgrade/devices/AHU-102/expected/generated_config.json @@ -0,0 +1,114 @@ +{ + "timestamp": "2024-06-11T08:31:26Z", + "version": "1.4.0", + "system": { + "min_loglevel": 300, + "metrics_rate_sec": 10, + "operation": { } + }, + "gateway": { }, + "localnet": { + "families": { + "bacnet": { + "addr": "11052" + } + } + }, + "pointset": { + "points": { + "cooling_water_valve_percentage_command": { + "ref": "AO10.Present_Value", + "units": "percent" + }, + "cooling_water_valve_percentage_sensor": { + "ref": "AI9.Present_Value", + "units": "percent" + }, + "exhaust_air_damper_command": { + "ref": "BO2.Present_Value", + "units": "No-units" + }, + "exhaust_air_static_pressure_sensor": { + "ref": "AI6.Present_Value", + "units": "pascals" + }, + "exhaust_fan_run_command": { + "ref": "BO5.Present_Value", + "units": "No-units" + }, + "exhaust_fan_speed_percentage_command": { + "ref": "AO6.Present_Value", + "units": "percent" + }, + "exhaust_fan_speed_percentage_sensor": { + "ref": "AI5.Present_Value", + "units": "percent" + }, + "exhaust_fan_speed_percentage_setpoint": { + "ref": "AV3.Present_Value", + "units": "percent" + }, + "exhaust_filter_differential_pressure_sensor": { + "ref": "AI4.Present_Value", + "units": "pascals" + }, + "fire_alarm": { + "ref": "BI3.Present_Value", + "units": "No-units" + }, + "heating_water_valve_percentage_command": { + "ref": "AO9.Present_Value", + "units": "percent" + }, + "heating_water_valve_percentage_sensor": { + "ref": "AI10.Present_Value", + "units": "percent" + }, + "outside_air_temperature_sensor": { + "ref": "AI17.Present_Value", + "units": "degrees-celcius" + }, + "return_air_temperature_sensor": { + "ref": "AI3.Present_Value", + "units": "degrees-celcius" + }, + "supply_air_damper_command": { + "ref": "BO1.Present_Value", + "units": "No-units" + }, + "supply_air_static_pressure_sensor": { + "ref": "AI3.Present_Value", + "units": "pascals" + }, + "supply_air_temperature_sensor": { + "ref": "AI12.Present_Value", + "units": "degrees-celcius" + }, + "supply_air_temperature_setpoint": { + "ref": "AI20.Present_Value", + "units": "degrees-celcius" + }, + "supply_fan_run_command": { + "ref": "BO3.Present_Value", + "units": "No-units" + }, + "supply_fan_speed_percentage_command": { + "ref": "AO4.Present_Value", + "units": "percent" + }, + "supply_fan_speed_percentage_sensor": { + "ref": "AI2.Present_Value", + "units": "percent" + }, + "supply_fan_speed_percentage_setpoint": { + "ref": "AV2.Present_Value", + "units": "percent" + }, + "supply_filter_differential_pressure_sensor": { + "ref": "AI1.Present_Value", + "units": "pascals" + } + } + }, + "downgraded_from": "1.5.0" +} \ No newline at end of file diff --git a/tests/sites/downgrade/devices/AHU-102/expected/metadata_norm.json b/tests/sites/downgrade/devices/AHU-102/expected/metadata_norm.json new file mode 100644 index 0000000000..d630092338 --- /dev/null +++ b/tests/sites/downgrade/devices/AHU-102/expected/metadata_norm.json @@ -0,0 +1,158 @@ +{ + "timestamp": "2024-06-11T08:31:26Z", + "version": "1.4.1", + "upgraded_from": "1.4.0", + "hash": "fd811951", + "tags": [ ], + "system": { + "location": { + "site": "US-SFO-XYY", + "section": "L01-NW", + "position": { + "x": 10.0, + "y": 10.0, + "z": 10.0 + } + }, + "physical_tag": { + "asset": { + "guid": "guid://bbfe8b4b-e9e5-424b-9a4e-2234b61c41bf", + "site": "US-SFO-XYY", + "name": "AHU-102" + } + }, + "min_loglevel": 300 + }, + "gateway": { + "gateway_id": "CGW-1", + "target": { + "family": "bacnet" + } + }, + "localnet": { + "families": { + "bacnet": { + "addr": "11052" + } + } + }, + "pointset": { + "points": { + "cooling_water_valve_percentage_command": { + "units": "percent", + "ref": "AO10.Present_Value", + "tags": [ ] + }, + "cooling_water_valve_percentage_sensor": { + "units": "percent", + "ref": "AI9.Present_Value", + "tags": [ ] + }, + "exhaust_air_damper_command": { + "units": "No-units", + "ref": "BO2.Present_Value", + "tags": [ ] + }, + "exhaust_air_static_pressure_sensor": { + "units": "pascals", + "ref": "AI6.Present_Value", + "tags": [ ] + }, + "exhaust_fan_run_command": { + "units": "No-units", + "ref": "BO5.Present_Value", + "tags": [ ] + }, + "exhaust_fan_speed_percentage_command": { + "units": "percent", + "ref": "AO6.Present_Value", + "tags": [ ] + }, + "exhaust_fan_speed_percentage_sensor": { + "units": "percent", + "ref": "AI5.Present_Value", + "tags": [ ] + }, + "exhaust_fan_speed_percentage_setpoint": { + "units": "percent", + "ref": "AV3.Present_Value", + "tags": [ ] + }, + "exhaust_filter_differential_pressure_sensor": { + "units": "pascals", + "ref": "AI4.Present_Value", + "tags": [ ] + }, + "fire_alarm": { + "units": "No-units", + "ref": "BI3.Present_Value", + "tags": [ ] + }, + "heating_water_valve_percentage_command": { + "units": "percent", + "ref": "AO9.Present_Value", + "tags": [ ] + }, + "heating_water_valve_percentage_sensor": { + "units": "percent", + "ref": "AI10.Present_Value", + "tags": [ ] + }, + "outside_air_temperature_sensor": { + "units": "degrees-celcius", + "ref": "AI17.Present_Value", + "tags": [ ] + }, + "return_air_temperature_sensor": { + "units": "degrees-celcius", + "ref": "AI3.Present_Value", + "tags": [ ] + }, + "supply_air_damper_command": { + "units": "No-units", + "ref": "BO1.Present_Value", + "tags": [ ] + }, + "supply_air_static_pressure_sensor": { + "units": "pascals", + "ref": "AI3.Present_Value", + "tags": [ ] + }, + "supply_air_temperature_sensor": { + "units": "degrees-celcius", + "ref": "AI12.Present_Value", + "tags": [ ] + }, + "supply_air_temperature_setpoint": { + "units": "degrees-celcius", + "ref": "AI20.Present_Value", + "tags": [ ] + }, + "supply_fan_run_command": { + "units": "No-units", + "ref": "BO3.Present_Value", + "tags": [ ] + }, + "supply_fan_speed_percentage_command": { + "units": "percent", + "ref": "AO4.Present_Value", + "tags": [ ] + }, + "supply_fan_speed_percentage_sensor": { + "units": "percent", + "ref": "AI2.Present_Value", + "tags": [ ] + }, + "supply_fan_speed_percentage_setpoint": { + "units": "percent", + "ref": "AV2.Present_Value", + "tags": [ ] + }, + "supply_filter_differential_pressure_sensor": { + "units": "pascals", + "ref": "AI1.Present_Value", + "tags": [ ] + } + } + } +} \ No newline at end of file diff --git a/tests/sites/downgrade/devices/AHU-102/metadata.json b/tests/sites/downgrade/devices/AHU-102/metadata.json new file mode 100755 index 0000000000..fd6aa8429c --- /dev/null +++ b/tests/sites/downgrade/devices/AHU-102/metadata.json @@ -0,0 +1,130 @@ +{ + "version": "1.4.0", + "timestamp": "2024-06-11T08:31:26.000Z", + "system": { + "location": { + "site": "US-SFO-XYY", + "section": "L01-NW", + "position": { + "x": 10, + "y": 10, + "z": 10 + } + }, + "physical_tag": { + "asset": { + "guid": "guid://bbfe8b4b-e9e5-424b-9a4e-2234b61c41bf", + "site": "US-SFO-XYY", + "name": "AHU-102" + } + } + }, + "localnet": { + "families": { + "bacnet": { + "addr": "11052" + } + } + }, + "gateway": { + "family": "bacnet", + "gateway_id": "CGW-1" + }, + "pointset": { + "points": { + "supply_filter_differential_pressure_sensor": { + "ref": "AI1.Present_Value", + "units": "pascals" + }, + "supply_fan_speed_percentage_sensor": { + "ref": "AI2.Present_Value", + "units": "percent" + }, + "supply_air_static_pressure_sensor": { + "ref": "AI3.Present_Value", + "units": "pascals" + }, + "exhaust_filter_differential_pressure_sensor": { + "ref": "AI4.Present_Value", + "units": "pascals" + }, + "exhaust_fan_speed_percentage_sensor": { + "ref": "AI5.Present_Value", + "units": "percent" + }, + "exhaust_air_static_pressure_sensor": { + "ref": "AI6.Present_Value", + "units": "pascals" + }, + "cooling_water_valve_percentage_sensor": { + "ref": "AI9.Present_Value", + "units": "percent" + }, + "heating_water_valve_percentage_sensor": { + "ref": "AI10.Present_Value", + "units": "percent" + }, + "supply_air_temperature_sensor": { + "ref": "AI12.Present_Value", + "units": "degrees-celcius" + }, + "return_air_temperature_sensor": { + "ref": "AI3.Present_Value", + "units": "degrees-celcius" + }, + + "supply_air_temperature_setpoint": { + "ref": "AI20.Present_Value", + "units": "degrees-celcius" + }, + "outside_air_temperature_sensor": { + "ref": "AI17.Present_Value", + "units": "degrees-celcius" + }, + "fire_alarm": { + "ref": "BI3.Present_Value", + "units": "No-units" + }, + "supply_fan_speed_percentage_command": { + "ref": "AO4.Present_Value", + "units": "percent" + }, + "exhaust_fan_speed_percentage_command": { + "ref": "AO6.Present_Value", + "units": "percent" + }, + "cooling_water_valve_percentage_command": { + "ref": "AO10.Present_Value", + "units": "percent" + }, + "heating_water_valve_percentage_command": { + "ref": "AO9.Present_Value", + "units": "percent" + }, + "supply_air_damper_command": { + "ref": "BO1.Present_Value", + "units": "No-units" + }, + "exhaust_air_damper_command": { + "ref": "BO2.Present_Value", + "units": "No-units" + }, + "supply_fan_run_command": { + "ref": "BO3.Present_Value", + "units": "No-units" + }, + "exhaust_fan_run_command": { + "ref": "BO5.Present_Value", + "units": "No-units" + }, + "supply_fan_speed_percentage_setpoint": { + "ref": "AV2.Present_Value", + "units": "percent" + }, + "exhaust_fan_speed_percentage_setpoint": { + "ref": "AV3.Present_Value", + "units": "percent" + } + } + } +} diff --git a/tests/sites/downgrade/devices/CGW-1/expected/errors.map b/tests/sites/downgrade/devices/CGW-1/expected/errors.map new file mode 100644 index 0000000000..6e8c83561c --- /dev/null +++ b/tests/sites/downgrade/devices/CGW-1/expected/errors.map @@ -0,0 +1,5 @@ +Exceptions for CGW-1 + While loading credentials for local device CGW-1 + Found 0 credentials + expected files + Missing files: [rsa_private.pem, rsa_private.pkcs8, rsa_public.pem] diff --git a/tests/sites/downgrade/devices/CGW-1/expected/generated_config.json b/tests/sites/downgrade/devices/CGW-1/expected/generated_config.json new file mode 100644 index 0000000000..29dc542d21 --- /dev/null +++ b/tests/sites/downgrade/devices/CGW-1/expected/generated_config.json @@ -0,0 +1,23 @@ +{ + "timestamp": "2024-06-11T08:31:32Z", + "version": "1.4.0", + "system": { + "min_loglevel": 300, + "metrics_rate_sec": 10, + "operation": { } + }, + "gateway": { + "proxy_ids": [ "EM-1", "AHU-102", "AHU-103", "AHU-104", "AHU-105", "CTRP-101", "CTRP-102", "CTRP-103", "CTRP-104", "FCU-10101", "FCU-10102", "FCU-10103", "FCU-10104", "FCU-10105", "FCU-10106", "FCU-10107", "FCU-10108", "FCU-10109", "FCU-10110", "FCU-10111", "FCU-10112", "FCU-10113", "FCU-10114", "FCU-10115", "FCU-40101", "FCU-40102", "FCU-40103", "FCU-40104", "FCU-40105", "FCU-40106", "FCU-40107", "FCU-40108", "FCU-40109", "FCU-40110", "FCU-40111", "FCU-40112", "FCU-40113", "FCU-40114", "FCU-40115", "FCU-20101", "FCU-20102", "FCU-20103", "FCU-20104", "FCU-20105", "FCU-20106", "FCU-20107", "FCU-20108", "FCU-20109", "FCU-20110", "FCU-20111", "FCU-20112", "FCU-20113", "FCU-20114", "FCU-20115", "FCU-20116", "FCU-20117", "FCU-20118", "FCU-30101", "FCU-30102", "FCU-30103", "FCU-30104", "FCU-30105", "FCU-30106", "FCU-30107", "FCU-30108", "FCU-30109", "FCU-30110", "FCU-30111", "FCU-30112", "FCU-30113", "FCU-30114", "FCU-30115", "FCU-30116", "FCU-30117", "FCU-30118", "FCU-30119", "FCU-30120", "FCU-30121", "FCU-30122", "FCU-30123", "FCU-30124", "FCU-30125", "FCU-30126" ] + }, + "localnet": { + "families": { + "bacnet": { + "addr": "1010001" + } + } + }, + "pointset": { + "points": { } + }, + "downgraded_from": "1.5.0" +} \ No newline at end of file diff --git a/tests/sites/downgrade/devices/CGW-1/expected/metadata_norm.json b/tests/sites/downgrade/devices/CGW-1/expected/metadata_norm.json new file mode 100644 index 0000000000..329b76cae2 --- /dev/null +++ b/tests/sites/downgrade/devices/CGW-1/expected/metadata_norm.json @@ -0,0 +1,45 @@ +{ + "timestamp": "2024-06-11T08:31:32Z", + "version": "1.4.1", + "upgraded_from": "1.4.0", + "hash": "4a67fd1c", + "tags": [ ], + "cloud": { + "auth_type": "RS256" + }, + "system": { + "location": { + "site": "US-SFO-XYY", + "section": "L06-SW", + "position": { + "x": 10.0, + "y": 10.0, + "z": 10.0 + } + }, + "physical_tag": { + "asset": { + "guid": "guid://65c244b3-f6ec-49bc-8d68-df1f2946be08", + "site": "US-SFO-XYY", + "name": "CGW-1" + } + }, + "min_loglevel": 300 + }, + "gateway": { + "target": { + "family": "bacnet" + }, + "proxy_ids": [ "EM-1", "AHU-102", "AHU-103", "AHU-104", "AHU-105", "CTRP-101", "CTRP-102", "CTRP-103", "CTRP-104", "FCU-10101", "FCU-10102", "FCU-10103", "FCU-10104", "FCU-10105", "FCU-10106", "FCU-10107", "FCU-10108", "FCU-10109", "FCU-10110", "FCU-10111", "FCU-10112", "FCU-10113", "FCU-10114", "FCU-10115", "FCU-40101", "FCU-40102", "FCU-40103", "FCU-40104", "FCU-40105", "FCU-40106", "FCU-40107", "FCU-40108", "FCU-40109", "FCU-40110", "FCU-40111", "FCU-40112", "FCU-40113", "FCU-40114", "FCU-40115", "FCU-20101", "FCU-20102", "FCU-20103", "FCU-20104", "FCU-20105", "FCU-20106", "FCU-20107", "FCU-20108", "FCU-20109", "FCU-20110", "FCU-20111", "FCU-20112", "FCU-20113", "FCU-20114", "FCU-20115", "FCU-20116", "FCU-20117", "FCU-20118", "FCU-30101", "FCU-30102", "FCU-30103", "FCU-30104", "FCU-30105", "FCU-30106", "FCU-30107", "FCU-30108", "FCU-30109", "FCU-30110", "FCU-30111", "FCU-30112", "FCU-30113", "FCU-30114", "FCU-30115", "FCU-30116", "FCU-30117", "FCU-30118", "FCU-30119", "FCU-30120", "FCU-30121", "FCU-30122", "FCU-30123", "FCU-30124", "FCU-30125", "FCU-30126" ] + }, + "localnet": { + "families": { + "bacnet": { + "addr": "1010001" + } + } + }, + "pointset": { + "points": { } + } +} \ No newline at end of file diff --git a/tests/sites/downgrade/devices/CGW-1/metadata.json b/tests/sites/downgrade/devices/CGW-1/metadata.json new file mode 100755 index 0000000000..d288b31fb8 --- /dev/null +++ b/tests/sites/downgrade/devices/CGW-1/metadata.json @@ -0,0 +1,40 @@ +{ + "version": "1.4.0", + "timestamp": "2024-06-11T08:31:32.000Z", + "system": { + "location": { + "site": "US-SFO-XYY", + "section": "L06-SW", + "position": { + "x": 10, + "y": 10, + "z": 10 + } + }, + "physical_tag": { + "asset": { + "guid": "guid://65c244b3-f6ec-49bc-8d68-df1f2946be08", + "site": "US-SFO-XYY", + "name": "CGW-1" + } + } + }, + "cloud": { + "auth_type": "RS256" + }, + "gateway": { + "proxy_ids": [ "EM-1", "AHU-102", "AHU-103", "AHU-104", "AHU-105", "CTRP-101", "CTRP-102", "CTRP-103", "CTRP-104", "FCU-10101", "FCU-10102", "FCU-10103", "FCU-10104", "FCU-10105", "FCU-10106", "FCU-10107", "FCU-10108", "FCU-10109", "FCU-10110", "FCU-10111", "FCU-10112", "FCU-10113", "FCU-10114", "FCU-10115", "FCU-40101", "FCU-40102", "FCU-40103", "FCU-40104", "FCU-40105", "FCU-40106", "FCU-40107", "FCU-40108", "FCU-40109", "FCU-40110", "FCU-40111", "FCU-40112", "FCU-40113", "FCU-40114", "FCU-40115", "FCU-20101", "FCU-20102", "FCU-20103", "FCU-20104", "FCU-20105", "FCU-20106", "FCU-20107", "FCU-20108", "FCU-20109", "FCU-20110", "FCU-20111", "FCU-20112", "FCU-20113", "FCU-20114", "FCU-20115", "FCU-20116", "FCU-20117", "FCU-20118", "FCU-30101", "FCU-30102", "FCU-30103", "FCU-30104", "FCU-30105", "FCU-30106", "FCU-30107", "FCU-30108", "FCU-30109", "FCU-30110", "FCU-30111", "FCU-30112", "FCU-30113", "FCU-30114", "FCU-30115", "FCU-30116", "FCU-30117", "FCU-30118", "FCU-30119", "FCU-30120", "FCU-30121", "FCU-30122", "FCU-30123", "FCU-30124", "FCU-30125", "FCU-30126" ] + }, + "localnet": { + "families": { + "bacnet": { + "addr": "1010001" + } + } + }, + "pointset" : { + "points" : { + } + } + } +}