Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

462- Do not coerce binary/enum Points to values if None when trending #491

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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 @@ -875,7 +875,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 @@ -1009,7 +1010,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