DeebotUniverse / Deebot-4-Home-Assistant

Home Assistant integration for deebot vacuums
https://deebot.readthedocs.io/integrations/home-assistant/
GNU General Public License v3.0
179 stars 40 forks source link

Timeout improve error message #187

Open MarkLyck opened 2 years ago

MarkLyck commented 2 years ago

Checks

The problem

After setting up the configuration correctly, and starting my vacuum once without issues.

I noticed the state of it today was "unkown", and trying to do any commands didn't work at all. I added logging and found this error:

2022-05-31 08:35:59 DEBUG (MainThread) [deebot_client._api_client] got {'ret': 'fail', 'errno': 500, 'debug': 'wait for response timed out'}
2022-05-31 08:35:59 DEBUG (MainThread) [deebot_client.vacuum_bot] Handle command clean: {'ret': 'fail', 'errno': 500, 'debug': 'wait for response timed out'}
2022-05-31 08:35:59 WARNING (MainThread) [deebot_client.commands.common] Command "clean" was not successfully: {'ret': 'fail', 'errno': 500, 'debug': 'wait for response timed out'}

I then checked the ecovacs app and also saw an error in there "Data aquisition timed out. Please exit and try again". So that makes it seem like the command not running is an ecovacs problem. :/ Please send an appropriate error message to the client if the request times out.

Diagnostics information

deebot-5e9a2c403b11be3cfdceac06a39edf3a-Alfred-ed77c3b94b720de3331d12b0c6ad6675.json.txt

Anything in the logs that might be useful for us?

Interestingly enough.

The state of the vacuum was showing as "unknown"

However after manually going to the vacuum and starting it, then pausing it (using the power button)

The state of the vacuum now correctly shows as "paused".

So that confirms the configuration works and it is able to at least get the state from the vacuum. But just the commands are failing? 🤔

Additional information

No response

MarkLyck commented 2 years ago

After deleting the app, resetting my Deboot T8+ and setting it up again from scratch, both the app and the commands are now working.

But it would still be great to get a proper error response if this happens again 🙏

edenhaus commented 2 years ago

wait for response timed out means that the ecovacs server did not get a response from your robot in time also you see this in the ecovacs app. You need to check if your robot is online and has a stable connection.

I checked the websocket messages and I noticed it took a really long time to get a response, but when I did get a response it's like this:

{
    "id": 13,
    "type": "result",
    "success": true,
    "result": {
        "context": {
            "id": "01811a2376985661bd8d5344471ea557",
            "parent_id": null,
            "user_id": "xxx"
        }
    }
}

This has nothing to do with the integration. This websocket connection is made between your client (browser, app) and your home assistant instance. As you can reach your instance, you will get also a response.

But it would still be great to get a proper error response if this happens again

The state is set to unknown, as we cannot identify and a warning is logged. What error message would you expect?

MarkLyck commented 2 years ago

@edenhaus If an integration times out, I would at minimum expect to see a success: false in response to the call_service message.

in an ideal world, a success: false, accompanied by an error message in the result saying it timed out.

something like:

{
    "id": 13,
    "type": "result",
    "success": false,
    "result": {
         "error": {
            code: 500,
            message: "wait for response timed out",
         },
        "context": {
            "id": "01811a2376985661bd8d5344471ea557",
            "parent_id": null,
            "user_id": "xxx"
        }
    }
}

Although I am not familiar with creating integrations, so maybe that is not even possible? But it was very frustrating debugging this and seeing that home assistant says my command was successful when it wasn't leaving my state out of sync with reality.

edenhaus commented 2 years ago

As explained in the comment above, you are referring to the api communication between the client and HA instance.

I can try to see if I can improve the error handling, but the timeout happens after 1-2 minutes and I don't know if HA allows me to give feedback that late. The timeout is controlled by ecovacs, so I can't change it.

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.