Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logging #63

Merged
merged 4 commits into from
Nov 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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