rospogrigio / localtuya

local handling for Tuya devices
GNU General Public License v3.0
2.96k stars 563 forks source link

Unknown error when adding DPS manually for climate GW #1625

Open biggdaniell opened 10 months ago

biggdaniell commented 10 months ago

The gateway is a PNI (E-GW-R) and clients are PNI branded ETOP thermostat valve heads (ETOP-HT-01AC-FOR-TRV). DPS are not detected automatically despite the fact that ID and local key is read successfully from cloud.

When adding DPS manually (copy/paste IDs from cloud), I get to select entity as "climate", select only the target and current temps (skipping or not all optional settings makes no difference) and when I'm trying to save I get "unknown error".

Here are the logs: `ValueError: invalid literal for int() with base 10: 'bfbf377b4da3d22e2fjhq5' 2024-01-12 19:52:28.043 ERROR (MainThread) [homeassistant.components.automation] Automation with alias 'ikea button notification' failed to setup triggers and has been disabled: Unknown device 'f35b2e14621087240b2f3aa1745fabab' 2024-01-12 19:52:36.848 ERROR (MainThread) [homeassistant.components.automation] Automation with alias 'ikea button notification' failed to setup triggers and has been disabled: Unknown device 'f35b2e14621087240b2f3aa1745fabab' 2024-01-12 19:52:38.594 ERROR (MainThread) [homeassistant.components.automation] Automation with alias 'ikea button notification' failed to setup triggers and has been disabled: Unknown device 'f35b2e14621087240b2f3aa1745fabab' 2024-01-12 19:52:38.649 INFO (MainThread) [custom_components.localtuya] Service localtuya.reload called: reloading integration 2024-01-12 19:52:39.892 ERROR (MainThread) [homeassistant.components.automation] Automation with alias 'ikea button notification' failed to setup triggers and has been disabled: Unknown device 'f35b2e14621087240b2f3aa1745fabab' 2024-01-12 19:52:43.016 INFO (MainThread) [custom_components.localtuya] Cloud API connection succeeded. 2024-01-12 19:52:46.805 WARNING (MainThread) [homeassistant.components.switch] Platform rest not ready yet: No route to resource/endpoint: http://172.16.16.21:5000/setSta; Retrying in background in 30 seconds 2024-01-12 19:53:08.798 ERROR (MainThread) [custom_components.localtuya.pytuya] [bf4...i1m] Failed to get status: could not decrypt data: wrong local_key? (exception: Expecting value: line 1 column 1 (char 0)) Traceback (most recent call last): File "/config/custom_components/localtuya/pytuya/init.py", line 953, in _decode_payload json_payload = json.loads(payload) ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/json/init.py", line 346, in loads return _default_decoder.decode(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/config/custom_components/localtuya/pytuya/init.py", line 863, in detect_available_dps data = await self.status() ^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/localtuya/pytuya/init.py", line 795, in status status = await self.exchange(DP_QUERY) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/localtuya/pytuya/init.py", line 780, in exchange payload = self._decode_payload(msg.payload) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/localtuya/pytuya/init.py", line 955, in _decode_payload raise DecodeError( custom_components.localtuya.pytuya.DecodeError: could not decrypt data: wrong local_key? (exception: Expecting value: line 1 column 1 (char 0)) 2024-01-12 19:53:08.869 DEBUG (MainThread) [custom_components.localtuya.config_flow] Initial state update failed (could not decrypt data: wrong local_key? (exception: Expecting value: line 1 column 1 (char 0))), trying reset command 2024-01-12 19:53:08.870 DEBUG (MainThread) [custom_components.localtuya.config_flow] No DPS able to be detected: object of type 'NoneType' has no len() 2024-01-12 19:53:08.871 DEBUG (MainThread) [custom_components.localtuya.config_flow] Detected DPS: {} 2024-01-12 19:53:08.871 DEBUG (MainThread) [custom_components.localtuya.config_flow] Manual DPS Setting: bfbf377b4da3d22e2fjhq5 (['bfbf377b4da3d22e2fjhq5']) 2024-01-12 19:53:08.874 DEBUG (MainThread) [custom_components.localtuya.config_flow] Total DPS: {'bfbf377b4da3d22e2fjhq5': -1} 2024-01-12 19:53:19.043 ERROR (MainThread) [aiohttp.server] Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request resp = await request_handler(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 543, in _handle resp = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 114, in impl return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 233, in auth_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 31, in headers_middleware response = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 149, in handle result = await handler(request, request.match_info) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 63, in with_admin return await func(self, request, *args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 234, in post return await super().post(request, flow_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper result = await method(view, request, data, args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post result = await self._flow_mgr.async_configure(flow_id, data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 320, in async_configure result = await self._async_handle_step( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 416, in _async_handle_step result: FlowResult = await getattr(flow, method)(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/localtuya/config_flow.py", line 764, in async_step_configure_entity self.entities.append(strip_dps_values(user_input, self.dps_strings)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/localtuya/config_flow.py", line 208, in strip_dps_values stripped[field] = int(user_input[field].split(" ")[0]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: invalid literal for int() with base 10: 'bfbf377b4da3d22e2fjhq5'`

biggdaniell commented 10 months ago

Can someone help me with this?