Skip to content

Commit

Permalink
Merge pull request #491 from onboard-data/boolean_enum_history
Browse files Browse the repository at this point in the history
462- Do not coerce binary/enum Points to values if None when trending
  • Loading branch information
ChristianTremblay authored Nov 26, 2024
2 parents 5e63102 + 4614a54 commit 4264a0b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions BAC0/core/devices/Points.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ async def priority(self, priority=None):
return None
return val

def _trend(self, res: t.Union[float, int, str]) -> None:
def _trend(self, res: t.Optional[t.Union[float, int, str]]) -> None:
now = datetime.now().astimezone()
self._history.timestamp.append(now)
self._history.value.append(res)
Expand Down Expand Up @@ -851,7 +851,8 @@ def __init__(
self.properties.units_state = tuple(str(x) for x in units_state)

def _trend(self, res):
res = "1: active" if res == BinaryPV.active else "0: inactive"
if res is not None:
res = "1: active" if res == BinaryPV.active else "0: inactive"
super()._trend(res)

@property
Expand Down Expand Up @@ -979,7 +980,8 @@ def __init__(
)

def _trend(self, res):
res = f"{res}: {self.get_state(res)}"
if res is not None:
res = f"{res}: {self.get_state(res)}"
super()._trend(res)

@property
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "BAC0"
version = "2024.09.20dev"
version = "2024.09.20"
description = "BACnet Scripting Framework for testing DDC Controls"
authors = [{name = "Christian Tremblay", email = "[email protected]"}]
readme = "README.md"
Expand Down Expand Up @@ -40,4 +40,4 @@ include = [
namespaces = false

[tool.pytest.ini_options]
asyncio_default_fixture_loop_scope = "session"
asyncio_default_fixture_loop_scope = "session"

0 comments on commit 4264a0b

Please sign in to comment.