Skip to content

Commit

Permalink
BACnet ingress free socket after discover
Browse files Browse the repository at this point in the history
  • Loading branch information
TShapinsky committed May 17, 2023
1 parent 3cb694c commit d0f46d3
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions buildingmotif/ingresses/bacnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,20 @@ def __init__(self, ip: Optional[str] = None):
# for each discovered Device, create a BAC0.device object
# This will read the BACnet objects off of the Device.
# Save the BACnet objects in the objects dictionary
assert self.network.discoveredDevices is not None
for (address, device_id) in self.network.discoveredDevices: # type: ignore
# set poll to 0 to avoid reading the points regularly
dev = BAC0.device(address, device_id, self.network, poll=0)
self.devices.append(dev)
self.objects[(address, device_id)] = []
try:
assert self.network.discoveredDevices is not None
for (address, device_id) in self.network.discoveredDevices: # type: ignore
# set poll to 0 to avoid reading the points regularly
dev = BAC0.device(address, device_id, self.network, poll=0)
self.devices.append(dev)
self.objects[(address, device_id)] = []

for bobj in dev.points:
obj = bobj.properties.asdict
self._clean_object(obj)
self.objects[(address, device_id)].append(obj)
for bobj in dev.points:
obj = bobj.properties.asdict
self._clean_object(obj)
self.objects[(address, device_id)].append(obj)
finally:
self.network.disconnect()

def _clean_object(self, obj: Dict[str, Any]):
if "name" in obj:
Expand Down

0 comments on commit d0f46d3

Please sign in to comment.