FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Return usage.get_{monthstat,daystat} in expected format by jules43 · Pull Request #394 · python-kasa/python-kasa · GitHub

Repository navigation

Return usage.get_{monthstat,daystat} in expected format - #394

Merged
rytilahti merged 5 commits into
python-kasa:masterfrom
jules43:usage-get-stat
Feb 18, 2023
Merged

rytilahti merged 5 commits into
python-kasa:masterfrom
jules43:usage-get-stat

Conversation

jules43 commented Nov 11, 2022 •
edited by rytilahti
Loading

Copy link
Copy Markdown
Contributor

This is an initial fix for the issue discussed here:

Fixes #373

This code largely duplicates the solution used for the Emeter module.

I have work in progress on a pydantic based version for which I will create a second PR.

codecov-commenter commented Nov 15, 2022 •
edited
Loading

Copy link
Copy Markdown

Codecov Report

Base: 78.95% // Head: 79.28% // Increases project coverage by +0.32% 🎉

Coverage data is based on head (85f16c6) compared to base (12c98eb).
Patch coverage: 83.78% of modified lines in pull request are covered.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #394      +/-   ##
==========================================
+ Coverage   78.95%   79.28%   +0.32%     
==========================================
  Files          25       25              
  Lines        1863     1868       +5     
  Branches      269      266       -3     
==========================================
+ Hits         1471     1481      +10     
+ Misses        358      353       -5     
  Partials       34       34              
Impacted Files Coverage Δ
kasa/smartdevice.py 86.93% <ø> (+2.76%) ⬆️
kasa/modules/usage.py 69.64% <62.50%> (-4.17%) ⬇️
kasa/modules/emeter.py 97.77% <100.00%> (+0.15%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

rytilahti left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looking great, thanks! 💯 I added a couple of comments for your consideration prior merging this.

Comment thread kasa/cli.py
Comment thread kasa/tests/test_usage.py
Comment thread kasa/modules/emeter.py Outdated
Comment thread kasa/modules/usage.py Outdated
Comment thread kasa/tests/test_usage.py
rytilahti changed the title Initial fix for usage get_daystat and get_monthstat not returning data in correct format Fix usage module's get_{monthstat,daystat} not returning data in correct format Nov 15, 2022
rytilahti added the bug Something isn't working label Nov 15, 2022

jules43 commented Nov 17, 2022

Copy link
Copy Markdown
Contributor Author

Hopefully I've made changes based on all the feedback. The only thing I haven't done is added additional tests to test_usage.py. This is definitely a good idea but, as I understand it, would require extending newfakes which I think is probably outside this PR. I also feel I'll need to understand newfakes a bit better before having a go, so any hints would be great.

Copy link
Copy Markdown
Member

I think it's not worth trying to force the tests inside the existing ones, but rather add module level tests separately, especially as the fixture files do not contain the necessary information. This reminded me about that I was exploring this idea earlier, see #404 if you wish.

Anyway, it is good as it is also without that. I'll do a review later tonight/tomorrow.

rytilahti left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks good to me after fixing some minor changes to the docs 👍

Comment thread kasa/modules/usage.py Outdated
Comment thread kasa/modules/usage.py Outdated
Comment thread kasa/modules/emeter.py Outdated
Comment thread kasa/modules/emeter.py Outdated
Comment thread kasa/modules/emeter.py Outdated
Comment thread kasa/modules/emeter.py Outdated
jules43 and others added 5 commits February 18, 2023 20:14
Change usage module get_daystat and get_monthat to return dictionaries of date index: time values as spec'd instead of raw usage data. Output matches emeter module get_daystat and get_monthstat
Use the new _convert function in emeter for all conversions rather than the one in smartdevice.py
Removed unused function _emeter_convert_emeter_data from smartdevice.py
Tidied up some doc string comments
Added a check for explicit values from conversion function

rytilahti commented Feb 18, 2023 •
edited
Loading

Copy link
Copy Markdown
Member

Uhh, I should've used merge instead of rebase to save the review comments, oh well... I rebased this on top of the current master and changed the docstrings a bit, I think this is good to go for the next release. Thanks again @jules43! 🥇

rytilahti added this to the 0.5.1 milestone Feb 18, 2023
rytilahti changed the title Fix usage module's get_{monthstat,daystat} not returning data in correct format Return usage.get_{monthstat,daystat} in expected format Feb 18, 2023
rytilahti merged commit 43ed47e into python-kasa:master Feb 18, 2023
pillarsdotnet pushed a commit to pillarsdotnet/python-kasa that referenced this pull request Oct 22, 2026
)

* Basic fix for issue: python-kasa#373
Change usage module get_daystat and get_monthat to return dictionaries of date index: time values as spec'd instead of raw usage data. Output matches emeter module get_daystat and get_monthstat

* Fixed some formatting and lint warnings to comply with black/flake8
Use the new _convert function in emeter for all conversions rather than the one in smartdevice.py
Removed unused function _emeter_convert_emeter_data from smartdevice.py

* Added a first pass test module for testing the new usage conversion function

* Changes based on PR feedback
Tidied up some doc string comments
Added a check for explicit values from conversion function

* Rebase on top of current master, fix docstrings

---------

Co-authored-by: Teemu Rytilahti <tpr@iki.fi>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cli.py usage year and month options do not output data as expected

3 participants


Back | FazBrowse Home | New Git URL