Skip to content

Commit

Permalink
logging (#63)
Browse files Browse the repository at this point in the history
* logging

* typo

* log

* fixup! Format Python code with black
  • Loading branch information
Danielhiversen authored Nov 5, 2021
1 parent d21abb9 commit 42b1341
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions mill/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ async def request(self, command, payload, retry=3):
_LOGGER.error("No token")
return None

_LOGGER.debug(command, payload)
_LOGGER.debug("Request %s %s", command, payload)

nonce = "".join(
random.choice(string.ascii_uppercase + string.digits) for _ in range(16)
Expand Down Expand Up @@ -168,7 +168,7 @@ async def request(self, command, payload, retry=3):

result = await resp.text()

_LOGGER.debug(result)
_LOGGER.debug("Result %s", result)

if not result or result == '{"errorCode":0}':
return None
Expand Down Expand Up @@ -196,7 +196,7 @@ async def request(self, command, payload, retry=3):

async def request_stats(self, command, payload, retry=3):
"""Request data."""
_LOGGER.debug(command, payload)
_LOGGER.debug("Request stats %s %s", command, payload)
url = API_ENDPOINT_STATS + command
json_data = json.dumps(payload)
token = str(int(time.time() * 1000)) + "_" + str(self._user_id)
Expand Down Expand Up @@ -229,7 +229,7 @@ async def request_stats(self, command, payload, retry=3):

result = await resp.text()

_LOGGER.debug(result)
_LOGGER.debug("Result %s", result)
data = json.loads(result)
return data

Expand Down Expand Up @@ -418,7 +418,9 @@ async def _update_consumption(self, heater):
now = dt.datetime.now(dt.timezone.utc)
if heater.last_updated and (
now - heater.last_updated
) < MIN_TIME_BETWEEN_STATS_UPDATES + dt.timedelta(seconds=random.randint(0, 60)):
) < MIN_TIME_BETWEEN_STATS_UPDATES + dt.timedelta(
seconds=random.randint(0, 60)
):
return

payload = {
Expand Down

0 comments on commit 42b1341

Please sign in to comment.