Skip to content

Commit

Permalink
patch v0.1.3 (#5)
Browse files Browse the repository at this point in the history
* Patch v0.1.2 to v0.1.3

* Log the auth expiry time remaining and make buffer configurable

* Remove unnecessary var
  • Loading branch information
ejsuncy authored Jul 30, 2023
1 parent 72895f4 commit b7a91d6
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.1.2
current_version = 0.1.3
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(?P<alpha>a)?
serialize =
{major}.{minor}.{patch}{alpha}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.2
0.1.3
2 changes: 1 addition & 1 deletion git-submod-lib
1 change: 1 addition & 0 deletions src/py_ecowater/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 4 additions & 2 deletions src/py_ecowater/ecowater_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit b7a91d6

Please sign in to comment.