Skip to content

Conversation

Lash-L
Copy link
Collaborator

@Lash-L Lash-L commented Oct 28, 2024

Relates to #228

@humbertogontijo
Copy link
Collaborator

humbertogontijo commented Oct 28, 2024

I think it would be best to just keep it simple and create a counter to be used as the request_id (self.counter % 32767). What you think?

@Lash-L
Copy link
Collaborator Author

Lash-L commented Oct 28, 2024

Yeah that probably makes sense. I worried about local messages conflicting though if we went in a sequential order, but it probably does make more sense

@humbertogontijo
Copy link
Collaborator

I don't know if it can conflict between cloud and local. But we can do something like top to bottom on cloud and bottom to top on local

@Lash-L
Copy link
Collaborator Author

Lash-L commented Oct 28, 2024

I don't know if it can conflict between cloud and local. But we can do something like top to bottom on cloud and bottom to top on local

Sorry, I misspoke, I was specifically talking about commands run via the roborock app. i.e. I do something on my phone's app, it happens to be request id 34212 and that happens to be the next sequential id for HA. But it is probably rare enough that that edge case shouldn't even be really considered.

@Lash-L
Copy link
Collaborator Author

Lash-L commented Oct 28, 2024

Okay made the changes, what do you think about that?

@Lash-L Lash-L merged commit e987c17 into main Oct 28, 2024
7 checks passed
@Lash-L Lash-L deleted the async_changes branch October 28, 2024 16:26
f"Attempting to create a future with an existing request_id... New id is {new_id}. "
f"Code may not function properly."
)
request_id = new_id
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this ends up writing the future with a different key, but does not change the request id chosen by the caller. I think this means the response will still be left hanging and/or associated with the wrong request?

@@ -155,9 +155,9 @@ class MessageRetry:
class RoborockMessage:
protocol: RoborockMessageProtocol
payload: bytes | None = None
seq: int = randint(100000, 999999)
seq: int = get_next_int(100000, 999999)
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe these numbers are set once statically, and not once per message creation, which i think was the intent. I think this is the equivalent of setting a constant for all created messages.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Looks like you may be correct? I modified what was existing prior without thinking about it much, I thought data classes worked a bit like init but obviously not. Good catch

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.

3 participants