romedtino / simple-wyze-vac

Home Assistant Custom Component for Wyze Vacuum
48 stars 8 forks source link

Error Setting up entry Simple Wyze Vac for simple_wyze_vac #80

Closed dwdonnelly closed 1 month ago

dwdonnelly commented 1 month ago

Describe the bug Error Setting up entry Simple Wyze Vac for simple_wyze_vac

To Reproduce Each time the vacuum automation is run. This automation has been active for over 1 year with no errors.

Attempted to reload integration. Reload stated success, but the error is still present. Restarted HA, but the error is still present. Obtained new API/KEY and Base32 Secret for 2FA and applied during re-install of integration. Reload stated success. Restarted HA, but the error is still present.

Expected behavior The vacuum automation to run as before.

Screenshots `Logger: homeassistant.config_entries Source: config_entries.py:586 First occurred: July 3, 2024 at 1:17:41 PM (5 occurrences) Last logged: 10:28:13 AM

Error setting up entry Simple Wyze Vac for simple_wyze_vac Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/simple_wyze_vac/init.py", line 52, in async_setup_entry client = await hass.async_add_executor_job(Client, None, None, username, password, key_id, api_key, totp) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/wyze_sdk/api/client.py", line 72, in init self.login() File "/usr/local/lib/python3.12/site-packages/wyze_sdk/api/client.py", line 184, in login response = self._auth_client().user_login( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/wyze_sdk/service/auth_service.py", line 88, in user_login response = self.api_call( ^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/wyze_sdk/service/auth_service.py", line 58, in api_call return super().api_call( ^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/wyze_sdk/service/base.py", line 347, in api_call return super().api_call( ^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/wyze_sdk/service/base.py", line 204, in api_call return self.do_post(url=api_url, headers=headers, payload=json, params=params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/wyze_sdk/service/base.py", line 132, in do_post return self._do_request(client, req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/wyze_sdk/service/base.py", line 106, in _do_request raise err File "/usr/local/lib/python3.12/site-packages/wyze_sdk/service/base.py", line 93, in _do_request response.raise_for_status() File "/usr/local/lib/python3.12/site-packages/requests/models.py", line 1024, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://auth-prod.api.wyze.com/api/user/login`

Simple Wyze Vac Version

Wyze Vacuum Firmware Version -1.6.202

Home Assistant Version -2024.7.0

Additional context None

dwdonnelly commented 1 month ago

@romedtino Just following up to ee if there is any update on this issue?

romedtino commented 1 month ago

Hm, Your traceback indicate a credential/login issue especially with the Error 400 which indicate the server was reached but it was given bad data. Given that the traceback calls the API login, it seems related to an issue with your account?

dwdonnelly commented 1 month ago

@romedtino In working on the problem, I got a new API key, Key ID, and reused my existing 32bit code. I reinstalled the integration. Went through the setup process with no errors.

Then I tested the automation to run the two wyze vacuums and got this error from the 'trace': `Executed: July 11, 2024 at 4:48:15 PM Error: The request to the Wyze API failed. The server responded with: {'code': 3000, 'current': 0, 'data': None, 'hash': '1', 'instance_id': 'bc8a782462df12ed189a18754270bb74', 'isShowToast': 0, 'message': 'Device is offline', 'toastMsg': None, 'total': 0, 'version': 1} Result: params: domain: vacuum service: send_command service_data: params: rooms:

From the log I get in sequence the following three msg (start at the bottom and work up.):

`Logger: homeassistant.components.automation.dave_and_delores_leave Source: components/automation/init.py:755 integration: Automation (documentation, issues) First occurred: July 11, 2024 at 4:48:17 PM (1 occurrences) Last logged: July 11, 2024 at 4:48:17 PM

While executing automation automation.dave_and_delores_leave Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/automation/init.py", line 755, in async_trigger return await self.action_script.async_run( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1770, in async_run return await asyncio.shield(create_eager_task(run.async_run())) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 465, in async_run await self._async_step(log_exceptions=False) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 529, in _async_step self._handle_exception( File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 559, in _handle_exception raise exception File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 527, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1068, in _async_if_step await self._async_run_script(if_data["if_then"]) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1240, in _async_run_script result = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 727, in _async_run_long_action return await long_task ^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1770, in async_run return await asyncio.shield(create_eager_task(run.async_run())) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 465, in async_run await self._async_step(log_exceptions=False) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 529, in _async_step self._handle_exception( File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 559, in _handle_exception raise exception File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 527, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 764, in _async_call_service_step response_data = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 727, in _async_run_long_action return await long_task ^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2731, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2774, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 999, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1071, in _handle_entity_call result = await task ^^^^^^^^^^ File "/config/custom_components/simple_wyze_vac/vacuum.py", line 288, in async_send_command await self.sweep_rooms(params["rooms"]) File "/config/custom_components/simple_wyze_vac/vacuum.py", line 451, in sweep_rooms await self.hass.async_add_executor_job(lambda: self._client.vacuums.sweep_rooms(device_mac=self._vac_mac, room_ids=[room.id for room in rooms if room.name in target_rooms])) File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/simple_wyze_vac/vacuum.py", line 451, in await self.hass.async_add_executor_job(lambda: self._client.vacuums.sweep_rooms(device_mac=self._vac_mac, room_ids=[room.id for room in rooms if room.name in target_rooms])) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/wyze_sdk/api/devices/vacuums.py", line 280, in sweep_rooms return super()._venus_client().control( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/wyze_sdk/service/venus_service.py", line 122, in control return self.api_call(f'/plugin/venus/{did}/control', http_verb="POST", json=kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/wyze_sdk/service/venus_service.py", line 40, in api_call return super().api_call( ^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/wyze_sdk/service/base.py", line 347, in api_call return super().api_call( ^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/wyze_sdk/service/base.py", line 204, in api_call return self.do_post(url=api_url, headers=headers, payload=json, params=params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/wyze_sdk/service/base.py", line 132, in do_post return self._do_request(client, req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/wyze_sdk/service/base.py", line 109, in _do_request raise e File "/usr/local/lib/python3.12/site-packages/wyze_sdk/service/base.py", line 103, in _do_request ).validate() ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/wyze_sdk/service/wyze_response.py", line 142, in validate raise e.WyzeApiError(message, self.data) wyze_sdk.errors.WyzeApiError: The request to the Wyze API failed. The server responded with: {'code': 3000, 'current': 0, 'data': None, 'hash': '1', 'instance_id': 'bc8a782462df12ed189a18754270bb74', 'isShowToast': 0, 'message': 'Device is offline', 'toastMsg': None, 'total': 0, 'version': 1}`

and....

`Logger: homeassistant.components.automation.dave_and_delores_leave Source: helpers/script.py:527 integration: Automation (documentation, issues) First occurred: July 11, 2024 at 4:48:17 PM (2 occurrences) Last logged: July 11, 2024 at 4:48:17 PM

Dave and Delores Leave: If at step 1: Error executing script. Unexpected error for call_service at pos 1: The request to the Wyze API failed. The server responded with: {'code': 3000, 'current': 0, 'data': None, 'hash': '1', 'instance_id': 'bc8a782462df12ed189a18754270bb74', 'isShowToast': 0, 'message': 'Device is offline', 'toastMsg': None, 'total': 0, 'version': 1} Dave and Delores Leave: Error executing script. Unexpected error for if at pos 1: The request to the Wyze API failed. The server responded with: {'code': 3000, 'current': 0, 'data': None, 'hash': '1', 'instance_id': 'bc8a782462df12ed189a18754270bb74', 'isShowToast': 0, 'message': 'Device is offline', 'toastMsg': None, 'total': 0, 'version': 1} Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 527, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 764, in _async_call_service_step response_data = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 727, in _async_run_long_action return await long_task ^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2731, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2774, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 999, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1071, in _handle_entity_call result = await task ^^^^^^^^^^ File "/config/custom_components/simple_wyze_vac/vacuum.py", line 288, in async_send_command await self.sweep_rooms(params["rooms"]) File "/config/custom_components/simple_wyze_vac/vacuum.py", line 451, in sweep_rooms await self.hass.async_add_executor_job(lambda: self._client.vacuums.sweep_rooms(device_mac=self._vac_mac, room_ids=[room.id for room in rooms if room.name in target_rooms])) File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/simple_wyze_vac/vacuum.py", line 451, in await self.hass.async_add_executor_job(lambda: self._client.vacuums.sweep_rooms(device_mac=self._vac_mac, room_ids=[room.id for room in rooms if room.name in target_rooms])) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/wyze_sdk/api/devices/vacuums.py", line 280, in sweep_rooms return super()._venus_client().control( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/wyze_sdk/service/venus_service.py", line 122, in control return self.api_call(f'/plugin/venus/{did}/control', http_verb="POST", json=kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/wyze_sdk/service/venus_service.py", line 40, in api_call return super().api_call( ^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/wyze_sdk/service/base.py", line 347, in api_call return super().api_call( ^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/wyze_sdk/service/base.py", line 204, in api_call return self.do_post(url=api_url, headers=headers, payload=json, params=params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/wyze_sdk/service/base.py", line 132, in do_post return self._do_request(client, req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/wyze_sdk/service/base.py", line 109, in _do_request raise e File "/usr/local/lib/python3.12/site-packages/wyze_sdk/service/base.py", line 103, in _do_request ).validate() ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/wyze_sdk/service/wyze_response.py", line 142, in validate raise e.WyzeApiError(message, self.data) wyze_sdk.errors.WyzeApiError: The request to the Wyze API failed. The server responded with: {'code': 3000, 'current': 0, 'data': None, 'hash': '1', 'instance_id': 'bc8a782462df12ed189a18754270bb74', 'isShowToast': 0, 'message': 'Device is offline', 'toastMsg': None, 'total': 0, 'version': 1}`

and.....

`This error originated from a custom integration.

Logger: custom_components.simple_wyze_vac.vacuum Source: custom_components/simple_wyze_vac/vacuum.py:280 integration: Simple Wyze Vac (documentation) First occurred: July 11, 2024 at 4:48:15 PM (1 occurrences) Last logged: July 11, 2024 at 4:48:15 PM

Received WyzeApiError`

I am guessing I need to get a new 32bit code..or a whole new setup: API key, Key ID, and 32bit code. But that seems odd.

Thoughts?

dwdonnelly commented 1 month ago

@romedtino I think fundamentally you are correct, in that it is a problem outside of HA and this integration. Based on some further testing, it has become apparent that one of my two wyze vacuums has begun to randomly drop offline. This is causing the automation to stop working.

Now, maybe that in itself is an issue. It would seem if the wyze vacuum, in this case, dropped offline, the automation would recognize this issue, and proceed with the rest of the actions within the automation.

Pending your feedback, it would seem correct to close this particular issue.

Standing by.

dwdonnelly commented 1 month ago

@romedtino Well, I am confused on this issue. Several days ago, this one wyze vacuum's lack of wifi connectivity seemed to just solve itself. Meaning, following your suggestion, I contacted Wyze, performed all their troubleshooting recommendations, provided logs, etc, but collectively we could find no issue. And nothing we did corrected the problem - the constant dropping of the wifi connection. Then, a couple of days after the troubleshooting efforts and contemplating ordering a replacement, the vacuum suddenly connected to the house wifi. I ran several tests of its operation over several days and it is operating just fine, via the Wyze app and HA & your integration.

So, at this point, I am marking the problem up to Sun Spots or some gremlin who got tired and moved to another house. And yes, it could be the start of a random problem indicating the wifi system in the vacuum is slowly failing. Have to take a wait and see approach.

At any rate, thank you for the assist, and I am closing this issue.