Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mango/augment_site_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def main():
print(f"Discovery wasn't found: {item_path}. Skipping.")
continue

cloud_num_id = discovery_match.item()
cloud_num_id = str(discovery_match.iloc[0])


if "CGW" in d: # gateways have their own metadata and are not in carson config
Expand Down
5 changes: 3 additions & 2 deletions mango/loadsheet_to_building_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def main():
"units", "deviceId", "objectType", "objectId", "isMissing"]]

display_name = asset
code = ", ".join(sorted(asset_loadsheet.controlProgram.dropna().unique().tolist()))
code = ", ".join(sorted(asset_loadsheet.controlProgram.dropna().astype(str).unique().tolist()))
type = asset_loadsheet.typeName.dropna().unique().tolist()
if len(type) != 1:
print(f"[ERROR] Asset has no typeName: {asset}. Check Loadsheet.")
Expand Down Expand Up @@ -72,7 +72,8 @@ def main():
print(f"[WARNING] No numeric_id found for proxy_id: {device.proxy_id}")
device.numeric_id = None
elif len(device_match) > 1:
print(f"[WARNING] Multiple numeric_id found for {device.proxy_id}, {', '.join(device_match.tolist())}. Using the first one.")
match_list = [str(x) for x in device_match.tolist()]
print(f"[WARNING] Multiple numeric_id found for {device.proxy_id}, {', '.join(match_list)}. Using the first one.")
device.numeric_id = str(device_match.values[0])
else:
device.numeric_id = str(device_match.values[0])
Expand Down
39 changes: 39 additions & 0 deletions models/cloud_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,45 @@
import os
from helpers import helpers

def parse_object_id(dp_string):
"""
Parses device_id and object_id from a metadata string.
"""
try:
if not isinstance(dp_string, str):
return None, None

# Handle URI format: bacnet://4013203/AV/13
if "bacnet://" in dp_string:
# Remove protocol and split by slash
clean_uri = dp_string.replace("bacnet://", "")
parts = clean_uri.split("/")

# Now parts is ['4013203', 'AV', '13']
if len(parts) < 3:
return None, None

numeric_id = parts[0]
type_initials = parts[1]
index = parts[2]
return str(numeric_id), f"{type_initials}:{index}"

# Handle Legacy format: DP_2800039_ANALOG_VALUE_68
elif "DP_" in dp_string:
parts = dp_string.split("_")
if len(parts) < 4:
return None, None

numeric_id = parts[1]
type_initials = "".join([word[0] for word in parts[2:-1]])
index = parts[-1]
return str(numeric_id), f"{type_initials}:{index}"

return None, None

except Exception as e:
return None, None

class Device:
def __init__(self, proxy_id=None, numeric_id=None, point_dict=None, device_list=None, metadata=None, guid=None):
self._proxy_id = proxy_id
Expand Down