sh00t2kill / dolphin-robot

A custom Home Assistant Component for WiFI enabled Maytronics Dolphin pool cleaner robots
43 stars 9 forks source link

Auth Errors #97

Closed daveholst closed 1 year ago

daveholst commented 1 year ago

Firstly, thanks for the great component!

I am on 0.3.3 and I am getting auth errors in the logs that are stopping the component from working and updating the vacuum card. I fixed it by reloading the integration and it seems to be working again. This is the output from my logs prior to reloading the integration:

2022-12-17 09:08:15.658 DEBUG (MainThread) [custom_components.mydolphin_plus.component.api.mydolphin_plus_api] Connected. Refresh details
2022-12-17 09:08:17.711 DEBUG (MainThread) [custom_components.mydolphin_plus.component.api.mydolphin_plus_api] Status of https://mbapp18.maytronics.com/api/serialnumbers/getrobotdetailsbymusn/: 401
2022-12-17 09:08:17.712 ERROR (MainThread) [custom_components.mydolphin_plus.component.api.mydolphin_plus_api] Failed to post JSON to https://mbapp18.maytronics.com/api/serialnumbers/getrobotdetailsbymusn/, HTTP Status: Unauthorized (401)
2022-12-17 09:08:17.713 ERROR (MainThread) [custom_components.mydolphin_plus.component.api.mydolphin_plus_api] Failed to retrieve Robot Details, Error: 'NoneType' object has no attribute 'get', Line: 321
2022-12-17 09:08:17.713 INFO (MainThread) [custom_components.mydolphin_plus.component.api.mydolphin_plus_api] aws-token-encrypted-key: <Redacted>=
2022-12-17 09:08:17.713 INFO (MainThread) [custom_components.mydolphin_plus.component.api.mydolphin_plus_api] serial_number: F9339YMT6M
2022-12-17 09:08:17.713 INFO (MainThread) [custom_components.mydolphin_plus.component.api.mydolphin_plus_api] login_token: <Redacted>
2022-12-17 09:08:17.714 INFO (MainThread) [custom_components.mydolphin_plus.component.api.mydolphin_plus_api] motor_unit_serial: F9339YMT
2022-12-17 09:08:17.714 INFO (MainThread) [custom_components.mydolphin_plus.component.api.mydolphin_plus_api] Token: <Redacted>
2022-12-17 09:08:17.714 INFO (MainThread) [custom_components.mydolphin_plus.component.api.mydolphin_plus_api] AccessKeyId: <Redacted>
2022-12-17 09:08:17.714 INFO (MainThread) [custom_components.mydolphin_plus.component.api.mydolphin_plus_api] SecretAccessKey: <Redacted>
2022-12-17 09:08:17.714 INFO (MainThread) [custom_components.mydolphin_plus.component.api.mydolphin_plus_api] Motor Unit Serial: F9339YMT6M
2022-12-17 09:08:17.714 INFO (MainThread) [custom_components.mydolphin_plus.component.api.mydolphin_plus_api] Product Name: 99996261-AU
2022-12-17 09:08:17.714 INFO (MainThread) [custom_components.mydolphin_plus.component.api.mydolphin_plus_api] Product Description: DOLPHIN S400 AU
2022-12-17 09:08:17.714 INFO (MainThread) [custom_components.mydolphin_plus.component.api.mydolphin_plus_api] Application Name: myDolphin Plus
2022-12-17 09:08:17.714 INFO (MainThread) [custom_components.mydolphin_plus.component.api.mydolphin_plus_api] Registration Date: None
2022-12-17 09:08:17.714 INFO (MainThread) [custom_components.mydolphin_plus.component.api.mydolphin_plus_api] Robot Name: Harold
2022-12-17 09:08:17.714 INFO (MainThread) [custom_components.mydolphin_plus.component.api.mydolphin_plus_api] Is Registered: N
2022-12-17 09:08:17.714 INFO (MainThread) [custom_components.mydolphin_plus.component.api.mydolphin_plus_api] Product Family: S400
2022-12-17 09:08:17.714 DEBUG (MainThread) [custom_components.mydolphin_plus.component.api.aws_iot_websocket] Connected. Refresh details
2022-12-17 09:08:17.714 DEBUG (MainThread) [custom_components.mydolphin_plus.component.api.aws_iot_websocket] Published message: None to $aws/things/F9339YMT/shadow/get
elad-bar commented 1 year ago

please check the new release v0.4.0, It should address the broker disconnection, tested for 4 days without single disconnection.

please let me know if it works for you

thanks

daveholst commented 1 year ago

I'll update now and see how it goes over the next few days 👍

daveholst commented 1 year ago

Addon didn't work after updating to 4.0.0 I removing my dolphin and then attempted to re-add it. When I put my username and password in I get an error and this:

2023-07-03 15:55:27.019 DEBUG (MainThread) [custom_components.mydolphin_plus.config_flow] Starting async_step_user of MyDolphin Plus
2023-07-03 15:55:32.166 DEBUG (MainThread) [custom_components.mydolphin_plus.config_flow] Starting async_step_user of MyDolphin Plus
2023-07-03 15:55:32.166 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 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, 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 227, 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/auth.py", line 236, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 181, 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 271, in async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/mydolphin_plus/config_flow.py", line 37, in async_step_user
    await config_manager.initialize()
  File "/config/custom_components/mydolphin_plus/managers/config_manager.py", line 91, in initialize
    await self._load()
  File "/config/custom_components/mydolphin_plus/managers/config_manager.py", line 121, in _load
    await self._load_encryption_key()
  File "/config/custom_components/mydolphin_plus/managers/config_manager.py", line 136, in _load_encryption_key
    if self.data is None:
       ^^^^^^^^^
  File "/config/custom_components/mydolphin_plus/managers/config_manager.py", line 50, in data
    return self._data.get(self._entry.entry_id)
           ^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get'
elad-bar commented 1 year ago

Will check it later, There is a possible workaround for it, Remove the integration from devices & integrations, then delete files contains name of mydolphin in .storage directory, restart HA and it will work, Other option is to wait for a fix :)

elad-bar commented 1 year ago

please try with v0.4.1

daveholst commented 1 year ago

Similar error further down now:

2023-07-03 17:04:12.086 DEBUG (MainThread) [custom_components.mydolphin_plus.config_flow] Starting async_step_user of MyDolphin Plus
2023-07-03 17:04:12.087 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 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, 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 227, 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/auth.py", line 236, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 181, 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 271, in async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/mydolphin_plus/config_flow.py", line 37, in async_step_user
    await config_manager.initialize()
  File "/config/custom_components/mydolphin_plus/managers/config_manager.py", line 91, in initialize
    await self._load()
  File "/config/custom_components/mydolphin_plus/managers/config_manager.py", line 126, in _load
    if self._entry.entry_id not in self._data:
       ^^^^^^^^^^^^^^^^^^^^
elad-bar commented 1 year ago

sorry for that, didn't manage to get to the error while testing, currently not at home so I'm releasing fixes without actual test them, I made a deeper review of the code and released new version that should solve it v0.4.2, please test it or wait for an update after I test it later today.

if you tested it anyway, please update whether it solved the problem or not, thanks

oNaiPs commented 1 year ago

@elad-bar v0.4.2 is not showing in https://github.com/sh00t2kill/dolphin-robot/releases, can you fix that? otherwise we can't install from HACS

elad-bar commented 1 year ago

that's weird, I can access it, see it is a release, but not in GitHub, will try to release new version later today and share it here

thanks for raising it

oNaiPs commented 1 year ago

nevermind @elad-bar it seems to be showing, but i just noticed that its not properly ordered in the dropdown

image

installed and will report back if anything is not working

daveholst commented 1 year ago

4.2 seems to have done it for me. But I had to fully uninstall the integration via HACS and do a new install with 4.2 to get it to download the correct version! 🤷

elad-bar commented 1 year ago

thanks for the update, there was an issue with backward compatbility which was fixed in later version, closing the issue.

thanks!