Skip to content

Commit

Permalink
Improve log message
Browse files Browse the repository at this point in the history
  • Loading branch information
osk2 committed Oct 2, 2021
1 parent 639b679 commit 6e16ed0
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions custom_components/panasonic_smart_app/smartApp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async def wrapper_call(*args, **kwargs):
PanasonicDeviceOffline,
Exception,
) as exception:
_LOGGER.info(exception)
_LOGGER.warning(exception)
return {}

return wrapper_call
Expand Down Expand Up @@ -177,12 +177,16 @@ async def get_device_overview(gwid: str):
info = await self.get_device_info(device.get("Auth"), codes)
device["status"].update(info)
except PanasonicExceedRateLimit:
_LOGGER.warning("超量使用 API,功能將受限制,詳見 https://github.com/osk2/panasonic_smart_app/discussions/31")
_LOGGER.warning(
"超量使用 API,功能將受限制,詳見 https://github.com/osk2/panasonic_smart_app/discussions/31"
)
overview = await get_device_overview(gwid)
target_device = list(
filter(lambda d: d["GWID"] == gwid, self._devices)
)
_LOGGER.debug(f"[{target_device[0]['NickName']}] overview: {overview}")
_LOGGER.debug(
f"[{target_device[0]['NickName']}] overview: {overview}"
)
device["status"].update(overview)
break

Expand Down Expand Up @@ -249,10 +253,10 @@ async def request(
filter(lambda device: device["Auth"] == auth, self._devices)
)
raise PanasonicDeviceOffline(
f"{device[0]['NickName']} is offline. Retry later..."
f"無法連線至\"{device[0]['NickName']}\",本次更新已略過,將於下輪更新時重試"
)
else:
raise PanasonicDeviceOffline
raise PanasonicDeviceOffline(f"無法連線至裝置,本次更新已略過,將於下輪更新時重試")

if response.status == HTTP_OK:
try:
Expand All @@ -274,10 +278,10 @@ async def request(
filter(lambda device: device["Auth"] == auth, self._devices)
)
raise PanasonicDeviceOffline(
f"{device[0]['NickName']} is offline. Retry later..."
f"無法連線至\"{device[0]['NickName']}\",本次更新已略過,將於下輪更新時重試"
)
else:
raise PanasonicDeviceOffline
raise PanasonicDeviceOffline(f"無法連線至裝置,本次更新已略過,將於下輪更新時重試")

elif resp.get("StateMsg") == EXCEPTION_INVALID_REFRESH_TOKEN:
raise PanasonicTokenExpired
Expand All @@ -289,7 +293,6 @@ async def request(
)
raise PanasonicLoginFailed


elif response.status == HTTP_TOO_MANY_REQUESTS:
raise PanasonicExceedRateLimit
else:
Expand Down

0 comments on commit 6e16ed0

Please sign in to comment.