From 693cb3ee9b9bb41a3c7c3468474a84c1bd4aaed5 Mon Sep 17 00:00:00 2001 From: yoyo930021 Date: Sat, 29 Jul 2023 15:20:48 +0800 Subject: [PATCH 1/2] Handle some error --- custom_components/panasonic_smart_app/smartApp/__init__.py | 2 ++ custom_components/panasonic_smart_app/smartApp/const.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/custom_components/panasonic_smart_app/smartApp/__init__.py b/custom_components/panasonic_smart_app/smartApp/__init__.py index d04c10e..6fb1f2b 100644 --- a/custom_components/panasonic_smart_app/smartApp/__init__.py +++ b/custom_components/panasonic_smart_app/smartApp/__init__.py @@ -24,6 +24,7 @@ EXCEPTION_DEVICE_NOT_RESPONDING, EXCEPTION_INVALID_REFRESH_TOKEN, EXCEPTION_DEVICE_JP_INFO, + EXCEPTION_DEVICE_JP_FAILED, ) from .utils import chunks from . import urls @@ -281,6 +282,7 @@ async def request( EXCEPTION_DEVICE_OFFLINE, EXCEPTION_DEVICE_NOT_RESPONDING, EXCEPTION_DEVICE_JP_INFO, + EXCEPTION_DEVICE_JP_FAILED, ] if resp.get("StateMsg") in offline_exceptions: auth = headers.get("auth", None) diff --git a/custom_components/panasonic_smart_app/smartApp/const.py b/custom_components/panasonic_smart_app/smartApp/const.py index 2b01754..de9c9f4 100644 --- a/custom_components/panasonic_smart_app/smartApp/const.py +++ b/custom_components/panasonic_smart_app/smartApp/const.py @@ -10,7 +10,8 @@ EXCEPTION_DEVICE_OFFLINE = "deviceOffline" EXCEPTION_DEVICE_NOT_RESPONDING = "deviceNoResponse" EXCEPTION_DEVICE_JP_INFO = "503:DeviceJPInfo:aStatusCode" +EXCEPTION_DEVICE_JP_FAILED = ":DeviceJPInfo:GetCommandTransResult failed" EXCEPTION_TOKEN_EXPIRED = "無法依據您的CPToken,auth取得相關資料" EXCEPTION_INVALID_REFRESH_TOKEN = "無效RefreshToken" EXCEPTION_CPTOKEN_EXPIRED = "此CPToken已經逾時" -EXCEPTION_REACH_RATE_LIMIT = "系統檢測您當前超量使用" \ No newline at end of file +EXCEPTION_REACH_RATE_LIMIT = "系統檢測您當前超量使用" From f82ca2a73ea2a8906d9fd84d81c27f3dfc65a976 Mon Sep 17 00:00:00 2001 From: yoyo930021 Date: Sat, 29 Jul 2023 23:19:48 +0800 Subject: [PATCH 2/2] Fix washing machine timer for japan --- custom_components/panasonic_smart_app/const.py | 1 + custom_components/panasonic_smart_app/sensor.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/custom_components/panasonic_smart_app/const.py b/custom_components/panasonic_smart_app/const.py index 6586572..e27bd5e 100644 --- a/custom_components/panasonic_smart_app/const.py +++ b/custom_components/panasonic_smart_app/const.py @@ -78,6 +78,7 @@ "0x13", # Washing machine remaining washing time "0x14", # Washing machine timer "0x15", # Washing machine remaining time to trigger timer + "0x41", # Washing machine timer for japan model "0x50", # Washing machine status "0x54", # Washing machine current mode "0x55", # Washing machine current cycle diff --git a/custom_components/panasonic_smart_app/sensor.py b/custom_components/panasonic_smart_app/sensor.py index 4ae2d43..7189bed 100644 --- a/custom_components/panasonic_smart_app/sensor.py +++ b/custom_components/panasonic_smart_app/sensor.py @@ -302,6 +302,8 @@ def icon(self) -> str: def state(self) -> int: status = self.coordinator.data[self.index]["status"] _current_countdown = status.get("0x13", None) + if _current_countdown is None or float(_current_countdown) < 0: + _current_countdown = status.get("0x41", None) _LOGGER.debug(f"[{self.label}] state: {_current_countdown}") return _current_countdown if _current_countdown else STATE_UNAVAILABLE