Skip to content

Commit

Permalink
docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
yozik04 committed Jun 24, 2024
1 parent c6cb797 commit 75581ce
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions vallox_websocket_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def __init__(self, ip_address: str):
self._settable_addresses = {}

async def load_data_model(self) -> None:
"""Load data model from unit or local file."""
if self.data_model.is_valid:
return

Expand All @@ -132,6 +133,7 @@ async def load_data_model(self) -> None:
raise DataModelReadException("Failed to load data model")

async def load_data_model_from_unit(self) -> bool:
"""Load data model from unit."""
for path in ["js/bundle.js", "js/vallox.js"]:
url = f"http://{self.ip_address}/{path}"
logger.info(f"Attempting to load data model from {url}")
Expand All @@ -147,6 +149,7 @@ async def load_data_model_from_unit(self) -> bool:
return False

async def load_bundled_data_model(self, version: str) -> bool:
"""Load bundled data model."""
try:
await self.data_model.read_bundled(version)
self._on_model_loaded()
Expand All @@ -163,9 +166,11 @@ def _on_model_loaded(self) -> None:
}

def get_settable_addresses(self) -> Dict[int, type]:
"""Get settable addresses."""
return self._settable_addresses

def set_settable_address(self, address: Union[int, str], var_type: type) -> None:
"""Set settable address."""
if var_type not in [int, float]:
raise ValloxInvalidInputException("Only float or int types are supported")

Expand All @@ -182,6 +187,7 @@ def set_settable_address(self, address: Union[int, str], var_type: type) -> None
)

def is_temperature(self, key: str) -> bool:
"""Check if key is related to a temperature."""
if key.startswith("A_CYC_TEMP_"):
return True
if key.endswith("TEMP_TARGET"):
Expand Down Expand Up @@ -244,6 +250,7 @@ async def _get_responses() -> List[bytes]:
async def fetch_metrics(
self, metric_keys: Optional[List[str]] = None
) -> MetricDict:
"""Fetch metrics."""
await self.load_data_model()

metrics = {}
Expand All @@ -270,6 +277,7 @@ async def fetch_metrics(
return metrics

async def fetch_raw_logs(self) -> List[List[Dict[str, Union[int, float]]]]:
"""Fetch raw logs."""
await self.load_data_model()

payload = self.messages.log_read_request.build({})
Expand Down Expand Up @@ -310,6 +318,7 @@ async def fetch_raw_logs(self) -> List[List[Dict[str, Union[int, float]]]]:
return series

async def set_values(self, dict_: Dict[str, Union[int, float, str]]) -> None:
"""Set values."""
await self.load_data_model()

items = []
Expand Down

0 comments on commit 75581ce

Please sign in to comment.