Skip to content

Conversation

Lash-L
Copy link
Collaborator

@Lash-L Lash-L commented Sep 3, 2025

Seemingly, tokens now sometimes expire. I'm not sure how long it takes, but the issue is being seen in a few issues. Our error handling logic was wrong in the old system (It was still operating under some mqtt3 logic instead of 5.)

Now, we identify bad auth errors, and pass forward a exception that makes that clear. Then we can prompt a reauth on the HA side.

@Lash-L Lash-L requested a review from allenporter September 3, 2025 02:36
@Lash-L
Copy link
Collaborator Author

Lash-L commented Sep 3, 2025

We will likely need to do something similar in the new mqtt side once everything is finalized.

@Lash-L Lash-L requested a review from allenporter September 7, 2025 18:14
@Lash-L
Copy link
Collaborator Author

Lash-L commented Sep 11, 2025

I am also taking this PR to try to decrease the amount of times we completely reauth in the old system. Right now we are disconnecting and reconnecting, but now we will attempt to unsub and resub 1 time, if that doesn't fix our problem, then we will do the normal reauth.

As well, I bumped up keepalive to 70 seconds as our cloud poll time for not cleaning in HA is 60 seconds which matched it, so I could see that causing issues.

Ideally this is configurable, but imo it doesn't make sense to do major refactoring as this is going to be a dead part of the code soon enough anyways

@Lash-L
Copy link
Collaborator Author

Lash-L commented Sep 17, 2025

Did some simplification. I don't think i specifically want to request re-auth, as waiting is a fine solution.

raise RoborockException(f"Failed to publish ({mqtt.error_string(info.rc)})")

async def validate_connection(self) -> None:
"""Override the default validate connection to try to re-subscribe rather than disconnect."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having trouble following everything going on here because of:

  • the new state member variable
  • keepalive
  • interaction with the parent class, invoking parent calss validate connection 4 different ways

Could this have an opening description of (1) big picture whats supposed to be happening here then (2) at a detailed level what these flows are and how the 3 things interact? Im also unsure how this pare relates to the error handling issue above.

A suggestion for simplification would be to no longer call the parent class validate_connection logic. Instead move that down into the local and cloud clients and inline it here so there are fewer interactions with the parent class.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take a look now, i broke things out into some helper functions

Lash-L and others added 2 commits September 18, 2025 10:42
Co-authored-by: Allen Porter <allen.porter@gmail.com>
@Lash-L Lash-L requested a review from allenporter September 18, 2025 15:20
@Lash-L
Copy link
Collaborator Author

Lash-L commented Sep 21, 2025

Anything outstanding here @allenporter?

connection_queue.set_result(True)

def _mqtt_on_message(self, *args, **kwargs):
self.received_message_since_last_disconnect = False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this now be True?

Unless i misunderstood the naming of this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes good call - it did not match the new naming. fixed.

@Lash-L Lash-L requested a review from allenporter September 21, 2025 14:59
@Lash-L Lash-L merged commit 599da6c into main Sep 21, 2025
9 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants