Skip to content

Commit

Permalink
Merge pull request #18 from lellky/lellky/device-model
Browse files Browse the repository at this point in the history
Adds property model
  • Loading branch information
piotrbulinski authored Feb 10, 2024
2 parents a749d1d + f7d585d commit 23b3ebe
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
1 change: 1 addition & 0 deletions examples/device_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ async def main():
# check device name and s/n
print(f"Device Name: {device.device_name}")
print(f"Serial Number: {device.serial_number}")
print(f"Device Model: {device.model}")
print(f"Outside air temp.: {device.outside_air_temperature} °C")
print(f"Supply air temp.: {device.supply_air_temperature} °C")
print(f"Extract air temp.: {device.extract_air_temperature} °C")
Expand Down
15 changes: 13 additions & 2 deletions flexit_bacnet/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ async def _set_value(self, device_property: DeviceProperty, value: Any) -> None:

@property
def device_name(self) -> str:
"""Return device name, e.g.: HvacFnct21y_A."""
device_name = self._get_value(self._device_property, bacnet.ReadValue.OBJECT_NAME)
"""Return device name, e.g.: Flexit Nordic"""
device_name_from_device = self._get_value(self._device_property, bacnet.ReadValue.OBJECT_NAME)
device_name = DEVICE_NAMES.get(device_name_from_device)

if not isinstance(device_name, str):
return ''
Expand All @@ -67,6 +68,16 @@ def serial_number(self) -> str:

return serial_number

@property
def model(self) -> str:
"""Return device's model, e.g.: S2 REL."""
model = NORDIC_MODELS.get(int(self.serial_number[0:6]))

if not isinstance(model, str):
return ''

return model

@property
def outside_air_temperature(self) -> float:
"""Outside air temperature in degrees Celsius, e.g. 14.3."""
Expand Down
23 changes: 23 additions & 0 deletions flexit_bacnet/nordic.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,26 @@
DEVICE_PROPERTIES = [
item for _, item in globals().items() if isinstance(item, DeviceProperty)
]

# The first six digits in the Nordic serial number corresponds to the Nordic model.
NORDIC_MODELS = {
800111: "S2 REL",
800121: "S3 REL",
800110: "S2 RER",
800120: "S3 RER",
800221: "CL4 REL",
800220: "CL4 RER",
800130: "S4 RER",
800131: "S4 REL",
800210: "CL2 RER",
800211: "CL2 REL",
800200: "CL3 RER",
800201: "CL3 REL",
800300: "KS3 RER",
800301: "KS3 REL",
}

# The name of the device
DEVICE_NAMES = {
"HvacFnct21y_A": "Flexit Nordic",
}

0 comments on commit 23b3ebe

Please sign in to comment.