Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial trigger logs implementation #900

Draft
wants to merge 1 commit into
base: feat/hub_pairing
Choose a base branch
from

Conversation

rytilahti
Copy link
Member

No description provided.

@rytilahti rytilahti added the enhancement New feature or request label May 4, 2024
Comment on lines +401 to +403
ret_val[method] = ex
else:
ret_val[method] = multi_response.get("result")
Copy link
Member Author

Choose a reason for hiding this comment

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

This changes the earlier behavior not to crash on errors, which would also fix the issue encountered in #852.

@@ -35,6 +35,14 @@ def __init__(

async def update(self, update_children: bool = True):
"""Noop update. The parent updates our internals."""
# TODO: we should probably default update_children=False in the library
# and perform these extra queries only on request.
if update_children:
Copy link
Member Author

Choose a reason for hiding this comment

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

The above todo is something we should discuss about, if we change the update_children=False, we could modify SmartDevice.update() to call updates on children, too?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this still a todo for 0.7.0? I think that the default should probably be False and then we can always have the option on calling update on children directly when needed in the future.

Copy link
Collaborator

@sdb9696 sdb9696 left a comment

Choose a reason for hiding this comment

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

Added some comments. Maybe the child device errors should go into 0.7.0 in a separate PR if we don't think we'll get tests for this in time.

Comment on lines +398 to +403
try:
self._handle_response_error_code(multi_response, method)
except KasaException as ex:
ret_val[method] = ex
else:
ret_val[method] = multi_response.get("result")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
try:
self._handle_response_error_code(multi_response, method)
except KasaException as ex:
ret_val[method] = ex
else:
ret_val[method] = multi_response.get("result")
self._handle_response_error_code(multi_response, method, raise_on_error=False)

Wouldn't this achieve the same thing although the result will be the error code rather than the exception (which is consistent with the other handling)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, probably yeah 馃憤

@@ -35,6 +35,14 @@ def __init__(

async def update(self, update_children: bool = True):
"""Noop update. The parent updates our internals."""
# TODO: we should probably default update_children=False in the library
# and perform these extra queries only on request.
if update_children:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this still a todo for 0.7.0? I think that the default should probably be False and then we can always have the option on calling update on children directly when needed in the future.

@rytilahti
Copy link
Member Author

Yes, I was about to write that we probably only want the error handling piece in as a separate PR, as it will also fix the issue when one tries to command a device with out-of-sync time. I'll separate it from the trigger log implementation & leave the update children also out, as that's something which will require some more thought and testing anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants