diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 33f71a2..2e2c2fd 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.1.2 +current_version = 0.1.3 parse = (?P\d+)\.(?P\d+)\.(?P\d+)(?Pa)? serialize = {major}.{minor}.{patch}{alpha} diff --git a/README.md b/README.md index 3b76b7c..07994ce 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # py_ecowater -![Current Version](https://img.shields.io/badge/Version-0.1.2-brightgreen) +![Current Version](https://img.shields.io/badge/Version-0.1.3-brightgreen) A python library for getting device data from Ecowater API for devices such as the Rheem RHW42 water softener, which provides WI-FI connectivity via the iQua app. diff --git a/VERSION.txt b/VERSION.txt index 8294c18..7693c96 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -0.1.2 \ No newline at end of file +0.1.3 \ No newline at end of file diff --git a/git-submod-lib b/git-submod-lib index 6f27d4b..237ad04 160000 --- a/git-submod-lib +++ b/git-submod-lib @@ -1 +1 @@ -Subproject commit 6f27d4b9d9f08fd02938aedae2f51213b10f0c56 +Subproject commit 237ad047075ac71dc771aa86f08c4520dee4ed08 diff --git a/src/py_ecowater/constants.py b/src/py_ecowater/constants.py index 6f912a7..b602e2f 100644 --- a/src/py_ecowater/constants.py +++ b/src/py_ecowater/constants.py @@ -21,3 +21,4 @@ def __init__(self, host=ECOWATER_HOST): self.headers_api["host"] = self.host self.headers_auth = ECOWATER_HEADERS.copy() self.headers_auth["content-type"] = "application/json;charset=utf-8" + self.auth_expiry_buffer_minutes = 10 diff --git a/src/py_ecowater/ecowater_client.py b/src/py_ecowater/ecowater_client.py index 5cc374f..31cfe42 100644 --- a/src/py_ecowater/ecowater_client.py +++ b/src/py_ecowater/ecowater_client.py @@ -21,8 +21,10 @@ def __init__(self, username: str, password: str, host: Optional[str] = None): def __authenticate(self) -> bool: if self.auth_token and self.auth_expiration: - if datetime.datetime.now() + datetime.timedelta(days=10) > self.auth_expiration: - self.logger.info("The Auth token expires within 10 days, need to refresh") + auth_minutes_remaining = (self.auth_expiration - datetime.datetime.now()).total_seconds() / 60 + if datetime.datetime.now() + datetime.timedelta(minutes=self.ecowater_constants.auth_expiry_buffer_minutes) > self.auth_expiration: + self.logger.info(f"The Auth token expires in {auth_minutes_remaining} min, which shorter than the " + f"configured buffer of {self.ecowater_constants.auth_expiry_buffer_minutes} min, need to refresh") self.auth_token = "" self.auth_expiration = None else: