Skip to content

Enable multiple requests in smartprotocol #584

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 20, 2023

Conversation

sdb9696
Copy link
Collaborator

@sdb9696 sdb9696 commented Dec 19, 2023

Hopefully a nice and small PR to enable multipleRequest in smartprotocol and the test framework.

A subsequent PRs will introduce the smart request helper functions and use the component_nego result to determine which requests to make rather than hardcoding.

Copy link

codecov bot commented Dec 19, 2023

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (20ea670) 83.63% compared to head (b3bfeaa) 84.78%.

Files Patch % Lines
kasa/tapo/tapoplug.py 55.55% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #584      +/-   ##
==========================================
+ Coverage   83.63%   84.78%   +1.15%     
==========================================
  Files          37       37              
  Lines        3183     3220      +37     
  Branches      803      810       +7     
==========================================
+ Hits         2662     2730      +68     
+ Misses        436      413      -23     
+ Partials       85       77       -8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rytilahti rytilahti added the enhancement New feature or request label Dec 19, 2023
Copy link
Member

@rytilahti rytilahti left a comment

Choose a reason for hiding this comment

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

Nice work, seems to be (mostly) working! 🥇 I added a couple of comments to avoid unnecessary deep nesting, which should help to keep it easier to test and read.

The device main query succeeds querying multiple "modules", but looks like there is a regression on emeter access:

  File "/home/tpr/code/python-kasa/kasa/cli.py", line 474, in state
    echo(f"\t{emeter_status}")
         ^^^^^^^^^^^^^^^^^^^^
  File "/home/tpr/code/python-kasa/kasa/emeterstatus.py", line 52, in __repr__
    f"<EmeterStatus power={self.power} voltage={self.voltage}"
                           ^^^^^^^^^^
  File "/home/tpr/code/python-kasa/kasa/emeterstatus.py", line 30, in power
    return self["power"]
           ~~~~^^^^^^^^^
  File "/home/tpr/code/python-kasa/kasa/emeterstatus.py", line 83, in __getitem__
    return self.__getitem__(i) / 1000
           ~~~~~~~~~~~~~~~~~~~~^~~~~~
TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'

The emeter status container contains only dict_items([('power_mw', None), ('total', None)]).

@sdb9696
Copy link
Collaborator Author

sdb9696 commented Dec 20, 2023

All comments addressed, emeter regression is fixed and the test framework tweaked to cover this regression case.

@sdb9696 sdb9696 requested a review from rytilahti December 20, 2023 09:35
Copy link
Member

@rytilahti rytilahti left a comment

Choose a reason for hiding this comment

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

Looks good to me, I'd extract the error code passing into its own PR though 👍

@sdb9696
Copy link
Collaborator Author

sdb9696 commented Dec 20, 2023

Hi @rytilahti, that's extracted now. I'll submit the new PR once this is merged and I can rebase on top.

Copy link
Member

@rytilahti rytilahti left a comment

Choose a reason for hiding this comment

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

Looks nice and tidy now, thanks!

@rytilahti rytilahti merged commit 6819c74 into python-kasa:master Dec 20, 2023
@sdb9696 sdb9696 deleted the multiple_smart_requests branch December 20, 2023 17:23
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.

2 participants