Skip to content

Commit

Permalink
Make all properties of the device non blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
dingusdk committed Mar 20, 2022
1 parent fd4df1a commit 8fb3fb3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"python.pythonPath": ".venv\\Scripts\\python.exe",
"python.linting.enabled": true,
"python.linting.flake8Enabled": true
}
28 changes: 18 additions & 10 deletions dukaonesdk/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class Device:
"""A class representing a single Duke One Device """
"""A class representing a single Duke One Device"""

def __init__(
self,
Expand All @@ -31,7 +31,7 @@ def __init__(

@property
def device_id(self) -> str:
"""Return the device id """
"""Return the device id"""
return self._id

@property
Expand Down Expand Up @@ -73,29 +73,37 @@ def filter_alarm(self) -> bool:

@property
def filter_timer(self) -> int:
"""Return the filter timer in minutes"""
return self._filter_timer

@property
def humidity(self) -> int:
"""Return the humidity."""
return self._humidity

@property
def firmware_version(self) -> str:
timeout = time.time() + 2
while self._firmware_version is None and time.time() < timeout:
time.sleep(0.1)
"""Return the firmware version of the duka one device"""
return self._firmware_version

@property
def firmware_date(self) -> str:
timeout = time.time() + 2
while self._firmware_date is None and time.time() < timeout:
time.sleep(0.1)
"""return the firmware date"""
return self._firmware_date

@property
def unit_type(self) -> int:
return self._unit_type

def is_initialized(self):
"""Returns True if the device has initilized.
The device is initialize once the get initial get firmware packet has been received.
This packet is send when the device is added to the client
"""
return self.firmware_version is not None

def wait_for_initialize(self):
timeout = time.time() + 2
while self._unit_type is None and time.time() < timeout:
while self.firmware_version is None and time.time() < timeout:
time.sleep(0.1)
return self._unit_type
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="dukaonesdk",
version="1.0.3",
version="1.0.4",
description="Duka One ventilation SDK",
long_description=(
"SDK for connection to the Duka One S6W ventilation. "
Expand Down

0 comments on commit 8fb3fb3

Please sign in to comment.