Skip to content

Commit

Permalink
Release v0.2.3: added living properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
dudanov committed Jun 2, 2024
1 parent 12c9d05 commit 4d19742
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions pyftms/client/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class PropertiesManager:
_properties: UpdateEventData
"""Properties dictonary"""

_live_properties: set[str]
"""Properties dictonary"""

_settings: SetupEventData
"""Properties dictonary"""

Expand All @@ -33,6 +36,7 @@ class PropertiesManager:
def __init__(self, on_ftms_event: FtmsCallback | None = None) -> None:
self._cb = on_ftms_event
self._properties = {}
self._live_properties = set()
self._settings = {}

def set_callback(self, cb: FtmsCallback):
Expand All @@ -42,6 +46,7 @@ def _on_event(self, e: FtmsEvents) -> None:
"""Real-time training data update handler."""
if e.event_id == "update":
self._properties |= e.event_data
self._live_properties.update(k for k, v in e.event_data.items() if v)
elif e.event_id == "setup":
self._settings |= e.event_data
elif e.event_id == "training_status":
Expand All @@ -60,6 +65,15 @@ def properties(self) -> UpdateEventData:
"""Read-only updateable properties mapping."""
return cast(UpdateEventData, MappingProxyType(self._properties))

@property
def live_properties(self) -> tuple[str, ...]:
"""
Living properties.
Properties that had a value other than zero at least once.
"""
return tuple(self._live_properties)

@property
def settings(self) -> SetupEventData:
"""Read-only updateable settings mapping."""
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyftms"
version = "0.2.2"
version = "0.2.3"
description = "PyFTMS - Python Fitness Machine Service client library."
authors = ["Sergey V. DUDANOV <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit 4d19742

Please sign in to comment.