Closed OTZro closed 1 year ago
回應 417 代表 API 回應超量使用,但我沒有看過 StateMsg
的內容是像你這樣的,不掛 proxy 時也會有一樣的錯誤嗎?
看了一下 StatusCode 的判斷是抓 429 才有處理超量 API 的 exception,417就直接丟出來了。
不掛 Proxy 的話我目前會收到超量的 exception,掛了 Proxy 會收到 417 這是部份的 log (有掛 proxy)
2023-07-03 13:39:36.123 INFO (MainThread) [custom_components.panasonic_smart_app]
Loading your Panasonic devices. This may takes few minutes to complete.
2023-07-03 13:39:36.123 INFO (MainThread) [custom_components.panasonic_smart_app.smartApp] Attemping to login...
2023-07-03 13:39:36.124 DEBUG (MainThread) [custom_components.panasonic_smart_app.smartApp] Making request to https://ems2.panasonic.com.tw/api/userlogin1 with headers {'user-agent': 'okhttp/4.9.1'} and data {'MemId': '***', 'PW': '***', 'AppToken': 'D8CBFF4C-2824-4342-B22D-189166FEF503'}
2023-07-03 13:39:40.416 INFO (MainThread) [custom_components.panasonic_smart_app] Updating device info...
2023-07-03 13:39:40.417 DEBUG (MainThread) [custom_components.panasonic_smart_app.smartApp] Making request to https://ems2.panasonic.com.tw/api/UserGetRegisteredGwList2 with headers {'cptoken': '---', 'user-agent': 'okhttp/4.9.1'} and data None
2023-07-03 13:39:43.542 DEBUG (MainThread) [custom_components.panasonic_smart_app.smartApp] Making request to https://ems2.panasonic.com.tw/api/UserGetInfo with headers {'cptoken': '---', 'user-agent': 'okhttp/4.9.1'} and data {'name': 'Power', 'from': '2023/07/01', 'unit': 'day', 'max_num': 31}
2023-07-03 13:39:46.607 DEBUG (MainThread) [custom_components.panasonic_smart_app.smartApp] Making request to https://ems2.panasonic.com.tw/api/DeviceGetInfo with headers {'cptoken': '---', 'auth': '---', 'gwid': '---', 'user-agent': 'okhttp/4.9.1'} and data [{'CommandTypes': [{'CommandType': '0x00'}, {'CommandType': '0x01'}, {'CommandType': '0x04'}, {'CommandType': '0x03'}, {'CommandType': '0x02'}, {'CommandType': '0x0F'}], 'DeviceID': 1}]
2023-07-03 13:39:49.693 DEBUG (MainThread) [custom_components.panasonic_smart_app.smartApp] Making request to https://ems2.panasonic.com.tw/api/DeviceGetInfo with headers {'cptoken': '---', 'auth': '---', 'gwid': '---', 'user-agent': 'okhttp/4.9.1'} and data [{'CommandTypes': [{'CommandType': '0x21'}, {'CommandType': '0x0B'}, {'CommandType': '0x0C'}, {'CommandType': '0x08'}, {'CommandType': '0x1B'}, {'CommandType': '0x1E'}], 'DeviceID': 1}]
2023-07-03 13:39:52.725 DEBUG (MainThread) [custom_components.panasonic_smart_app.smartApp] Making request to https://ems2.panasonic.com.tw/api/DeviceGetInfo with headers {'cptoken': '---', 'auth': '---', 'gwid': '---', 'user-agent': 'okhttp/4.9.1'} and data [{'CommandTypes': [{'CommandType': '0x1A'}, {'CommandType': '0x18'}, {'CommandType': '0x05'}, {'CommandType': '0x17'}, {'CommandType': '0x11'}, {'CommandType': '0x19'}], 'DeviceID': 1}]
2023-07-03 13:39:56.177 DEBUG (MainThread) [custom_components.panasonic_smart_app.smartApp] Making request to https://ems2.panasonic.com.tw/api/DeviceGetInfo with headers {'cptoken': '---', 'auth': '---', 'gwid': '---', 'user-agent': 'okhttp/4.9.1'} and data [{'CommandTypes': [{'CommandType': '0x1F'}, {'CommandType': '0x37'}], 'DeviceID': 1}]
2023-07-03 13:39:59.313 DEBUG (MainThread) [custom_components.panasonic_smart_app.smartApp] Making request to https://ems2.panasonic.com.tw/api/DeviceGetInfo with headers {'cptoken': '---', 'auth': '---', 'gwid': '---', 'user-agent': 'okhttp/4.9.1'} and data [{'CommandTypes': [{'CommandType': '0x00'}, {'CommandType': '0x01'}, {'CommandType': '0x04'}, {'CommandType': '0x03'}, {'CommandType': '0x02'}, {'CommandType': '0x0F'}], 'DeviceID': 1}]
2023-07-03 13:40:02.570 DEBUG (MainThread) [custom_components.panasonic_smart_app.smartApp] Making request to https://ems2.panasonic.com.tw/api/DeviceGetInfo with headers {'cptoken': '---', 'auth': '---', 'gwid': '---', 'user-agent': 'okhttp/4.9.1'} and data [{'CommandTypes': [{'CommandType': '0x21'}, {'CommandType': '0x0B'}, {'CommandType': '0x0C'}, {'CommandType': '0x08'}, {'CommandType': '0x1B'}, {'CommandType': '0x1E'}], 'DeviceID': 1}]
2023-07-03 13:40:06.080 DEBUG (MainThread) [custom_components.panasonic_smart_app.smartApp] Making request to https://ems2.panasonic.com.tw/api/DeviceGetInfo with headers {'cptoken': '---', 'auth': '---', 'gwid': '---', 'user-agent': 'okhttp/4.9.1'} and data [{'CommandTypes': [{'CommandType': '0x1A'}, {'CommandType': '0x18'}, {'CommandType': '0x05'}, {'CommandType': '0x17'}, {'CommandType': '0x11'}, {'CommandType': '0x19'}], 'DeviceID': 1}]
2023-07-03 13:40:09.373 DEBUG (MainThread) [custom_components.panasonic_smart_app.smartApp] Making request to https://ems2.panasonic.com.tw/api/DeviceGetInfo with headers {'cptoken': '---', 'auth': '---', 'gwid': '---', 'user-agent': 'okhttp/4.9.1'} and data [{'CommandTypes': [{'CommandType': '0x1F'}, {'CommandType': '0x37'}], 'DeviceID': 1}]
2023-07-03 13:40:12.329 DEBUG (MainThread) [custom_components.panasonic_smart_app.smartApp] Making request to https://ems2.panasonic.com.tw/api/DeviceGetInfo with headers {'cptoken': '---', 'auth': '---', 'gwid': '---', 'user-agent': 'okhttp/4.9.1'} and data [{'CommandTypes': [{'CommandType': '0x00'}, {'CommandType': '0x01'}, {'CommandType': '0x04'}, {'CommandType': '0x03'}, {'CommandType': '0x02'}, {'CommandType': '0x0F'}], 'DeviceID': 1}]
2023-07-03 13:40:15.487 DEBUG (MainThread) [custom_components.panasonic_smart_app.smartApp] Making request to https://ems2.panasonic.com.tw/api/DeviceGetInfo with headers {'cptoken': '---', 'auth': '---', 'gwid': '---', 'user-agent': 'okhttp/4.9.1'} and data [{'CommandTypes': [{'CommandType': '0x21'}, {'CommandType': '0x0B'}, {'CommandType': '0x0C'}, {'CommandType': '0x08'}, {'CommandType': '0x1B'}, {'CommandType': '0x1E'}], 'DeviceID': 1}]
2023-07-03 13:40:18.688 DEBUG (MainThread) [custom_components.panasonic_smart_app.smartApp] Making request to https://ems2.panasonic.com.tw/api/DeviceGetInfo with headers {'cptoken': '---', 'auth': '---', 'gwid': '---', 'user-agent': 'okhttp/4.9.1'} and data [{'CommandTypes': [{'CommandType': '0x1A'}, {'CommandType': '0x18'}, {'CommandType': '0x05'}, {'CommandType': '0x17'}, {'CommandType': '0x11'}, {'CommandType': '0x19'}], 'DeviceID': 1}]
2023-07-03 13:40:22.487 DEBUG (MainThread) [custom_components.panasonic_smart_app.smartApp] Making request to https://ems2.panasonic.com.tw/api/DeviceGetInfo with headers {'cptoken': '---', 'auth': '---', 'gwid': '---', 'user-agent': 'okhttp/4.9.1'} and data [{'CommandTypes': [{'CommandType': '0x1F'}, {'CommandType': '0x37'}], 'DeviceID': 1}]
2023-07-03 13:40:25.451 DEBUG (MainThread) [custom_components.panasonic_smart_app.smartApp] Making request to https://ems2.panasonic.com.tw/api/DeviceGetInfo with headers {'cptoken': '---', 'auth': '---', 'gwid': '---', 'user-agent': 'okhttp/4.9.1'} and data [{'CommandTypes': [{'CommandType': '0x00'}, {'CommandType': '0x01'}, {'CommandType': '0x04'}, {'CommandType': '0x03'}, {'CommandType': '0x02'}, {'CommandType': '0x0F'}], 'DeviceID': 1}]
2023-07-03 13:40:28.723 DEBUG (MainThread) [custom_components.panasonic_smart_app.smartApp] Making request to https://ems2.panasonic.com.tw/api/DeviceGetInfo with headers {'cptoken': '---', 'auth': '---', 'gwid': '---', 'user-agent': 'okhttp/4.9.1'} and data [{'CommandTypes': [{'CommandType': '0x21'}, {'CommandType': '0x0B'}, {'CommandType': '0x0C'}, {'CommandType': '0x08'}, {'CommandType': '0x1B'}, {'CommandType': '0x1E'}], 'DeviceID': 1}]
2023-07-03 13:40:32.230 DEBUG (MainThread) [custom_components.panasonic_smart_app.smartApp] Making request to https://ems2.panasonic.com.tw/api/DeviceGetInfo with headers {'cptoken': '---', 'auth': '---', 'gwid': '---', 'user-agent': 'okhttp/4.9.1'} and data [{'CommandTypes': [{'CommandType': '0x1A'}, {'CommandType': '0x18'}, {'CommandType': '0x05'}, {'CommandType': '0x17'}, {'CommandType': '0x11'}, {'CommandType': '0x19'}], 'DeviceID': 1}]
2023-07-03 13:40:36.029 DEBUG (MainThread) [custom_components.panasonic_smart_app.smartApp] Making request to https://ems2.panasonic.com.tw/api/DeviceGetInfo with headers {'cptoken': '---', 'auth': '---', 'gwid': '---', 'user-agent': 'okhttp/4.9.1'} and data [{'CommandTypes': [{'CommandType': '0x1F'}, {'CommandType': '0x37'}], 'DeviceID': 1}]
2023-07-03 13:40:39.281 DEBUG (MainThread) [custom_components.panasonic_smart_app.smartApp] Making request to https://ems2.panasonic.com.tw/api/DeviceGetInfo with headers {'cptoken': '---', 'auth': '---', 'gwid': '---', 'user-agent': 'okhttp/4.9.1'} and data [{'CommandTypes': [{'CommandType': '0x13'}, {'CommandType': '0x14'}, {'CommandType': '0x15'}, {'CommandType': '0x50'}, {'CommandType': '0x54'}, {'CommandType': '0x55'}], 'DeviceID': 1}]
2023-07-03 13:40:42.667 ERROR (MainThread) [custom_components.panasonic_smart_app.smartApp] Failed to access API. Returned 417: {"State":"fail","StateMsg":"503:DeviceJPInfo:aStatusCode"}
2023-07-03 13:40:42.669 INFO (MainThread) [custom_components.panasonic_smart_app.smartApp] Attemping to login...
2023-07-03 13:40:42.670 DEBUG (MainThread) [custom_components.panasonic_smart_app.smartApp] Making request to https://ems2.panasonic.com.tw/api/userlogin1 with headers {'user-agent': 'okhttp/4.9.1'} and data {'MemId': '***', 'PW': '***', 'AppToken': 'D8CBFF4C-2824-4342-B22D-189166FEF503'}
2023-07-03 13:40:47.057 DEBUG (MainThread) [custom_components.panasonic_smart_app.smartApp] Making request to https://ems2.panasonic.com.tw/api/DeviceGetInfo with headers {'cptoken': '---', 'auth': '---', 'gwid': '---', 'user-agent': 'okhttp/4.9.1'} and data [{'CommandTypes': [{'CommandType': '0x13'}, {'CommandType': '0x14'}, {'CommandType': '0x15'}, {'CommandType': '0x50'}, {'CommandType': '0x54'}, {'CommandType': '0x55'}], 'DeviceID': 1}]
2023-07-03 13:40:50.519 ERROR (MainThread) [custom_components.panasonic_smart_app.smartApp] Failed to access API. Returned 417: {"State":"fail","StateMsg":"503:DeviceJPInfo:aStatusCode"}
2023-07-03 13:40:50.521 ERROR (MainThread) [custom_components.panasonic_smart_app] Error fetching Panasonic Smart Application data: Failed while updating device status
2023-07-03 13:40:50.524 DEBUG (MainThread) [custom_components.panasonic_smart_app] Finished fetching Panasonic Smart Application data in 70.108 seconds (success: False)
我找到原因了,主要是我洗衣機沒有開機,抓洗衣機狀態的時候有問題
洗衣機型號: Panasonic LX128B
我昨天的回應是錯的
我原本以為超量是針對整個帳號封鎖,但根據你的測試結果像是鎖 IP 而已,也許掛個 proxy 是個蠻好的解法 🤔
我是用手機控制的時候發現用我家的 Wifi 控 app 會拿不到正確的數值,換成 5G 之後就可以正常拿了,想說這應該是鎖 IP 造成的。
目前測試掛 Proxy 可以解決鎖 IP 的問題,我有五台冷氣一台全熱目前都正常使用。掛 Proxy 的 code 我測試完會再發一個 PR 出來,到時候再麻煩你幫我看一下。
針對 417 的部份我洗衣機是需要開機的狀態先加入一次實體,之後才不會有問題嗎? 我遇到的情況是我重新加入實體的時候收到 417,直接噴 exception,所以導致其他裝置也不能正常操控。我在想是不是需要針對 417 的情況先 catch 並 skip。
裝置離線的狀況已經在這裡處理了,但因為你這次發現的錯誤訊息跟以往都不一樣,才被當成例外拋出
把 503:DeviceJPInfo:aStatusCode
加進 offline_exceptions
應該就行了
當然保持洗衣機開機也是一個懶人解決辦法 😆
@OTZro 不曉得你有沒有空在 Discussions 分享一下你是如何做到 proxy 定時換 IP 的作法?晚點發布更新之後應該會有不少人有興趣了解作法
這個部份我是付費找了一個Rotating Proxy,這種 Proxy 可以設定多久換一次IP
你好,我在嘗試幫 panasonic_smart_app 掛上 proxy,這樣一來就可以突破 panasonic 鎖 ip 的限制(proxy 可以設定一段時間更新 IP)。我加上 proxy 之後收到
Failed to access API. Returned 417: {"State":"fail","StateMsg":"503:DeviceJPInfo:aStatusCode"}
,想問一下大大之前有沒有遇過這個問題(我不確定是 proxy 的原因還是是 server 的問題)?