Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 16, 2024
1 parent ee44496 commit 7571077
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
32 changes: 21 additions & 11 deletions custom_components/audiconnect/audi_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,18 +266,20 @@ def _tryAppendStateWithTs(self, json, name, tsoff, loc):

ts = None
val = self._getFromJson(json, loc)
#_LOGGER.debug("Initial value retrieved for '%s': %s", name, val)
# _LOGGER.debug("Initial value retrieved for '%s': %s", name, val)

# Special handling for remainingChargingTime
if name == "remainingChargingTime" and val is None:
val = 0
_LOGGER.debug("TRY APPEND STATE: 'remainingChargingTime' adjusted to 0 due to None value")
_LOGGER.debug(
"TRY APPEND STATE: 'remainingChargingTime' adjusted to 0 due to None value"
)

if val is not None:
loc[tsoff:] = ["carCapturedTimestamp"]
#_LOGGER.debug("Updated loc for timestamp retrieval: %s", loc)
# _LOGGER.debug("Updated loc for timestamp retrieval: %s", loc)
ts = self._getFromJson(json, loc)
#_LOGGER.debug("Timestamp retrieved for '%s': %s", name, ts)
# _LOGGER.debug("Timestamp retrieved for '%s': %s", name, ts)

if val is not None and ts:
self.states.append({"name": name, "value": val, "measure_time": ts})
Expand All @@ -291,10 +293,14 @@ def _tryAppendStateWithTs(self, json, name, tsoff, loc):
)
else:
if val is None:
_LOGGER.debug("TRY APPEND STATE: Value for '%s' is None; not appending state.", name)
_LOGGER.debug(
"TRY APPEND STATE: Value for '%s' is None; not appending state.",
name,
)
elif not ts:
_LOGGER.debug(
"TRY APPEND STATE: Timestamp for '%s' is None or missing; not appending state.", name
"TRY APPEND STATE: Timestamp for '%s' is None or missing; not appending state.",
name,
)

def _tryAppendFieldWithTs(self, json, textId, loc):
Expand All @@ -306,13 +312,13 @@ def _tryAppendFieldWithTs(self, json, textId, loc):

ts = None
val = self._getFromJson(json, loc)
#_LOGGER.debug("Initial value retrieved for '%s': %s", textId, val)
# _LOGGER.debug("Initial value retrieved for '%s': %s", textId, val)

if val:
loc[-1:] = ["carCapturedTimestamp"]
#_LOGGER.debug("Updated loc for timestamp retrieval: %s", loc)
# _LOGGER.debug("Updated loc for timestamp retrieval: %s", loc)
ts = self._getFromJson(json, loc)
#_LOGGER.debug("Timestamp retrieved for '%s': %s", textId, ts)
# _LOGGER.debug("Timestamp retrieved for '%s': %s", textId, ts)

if val and ts:
self.data_fields.append(
Expand All @@ -333,10 +339,14 @@ def _tryAppendFieldWithTs(self, json, textId, loc):
)
else:
if not val:
_LOGGER.debug("TRY APPEND FIELD: Value for '%s' is missing; not appending field.", textId)
_LOGGER.debug(
"TRY APPEND FIELD: Value for '%s' is missing; not appending field.",
textId,
)
elif not ts:
_LOGGER.debug(
"TRY APPEND FIELD: Timestamp for '%s' is missing; not appending field.", textId
"TRY APPEND FIELD: Timestamp for '%s' is missing; not appending field.",
textId,
)

def _getFromJson(self, json, loc):
Expand Down
1 change: 0 additions & 1 deletion custom_components/audiconnect/audi_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
)
from .audi_api import AudiAPI
from .util import to_byte_array, get_attr
from .const import DOMAIN

from hashlib import sha256, sha512
import hmac
Expand Down

0 comments on commit 7571077

Please sign in to comment.