8000 Add factory_reset() to iotdevice by rytilahti · Pull Request #1125 · python-kasa/python-kasa · GitHub
[go: up one dir, main page]

Skip to content

Add factory_reset() to iotdevice #1125

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
Sep 27, 2024
Merged

Conversation

rytilahti
Copy link
Member
@rytilahti rytilahti commented Sep 21, 2024

This adds support for device factory reset for IOT devices, tested on KP303.
Also extends the base device class API to make factory_reset() to be a part of the common API. This could be extracted into its own PR, if needed.

@rytilahti rytilahti added the enhancement New feature or request label Sep 21, 2024
@rytilahti rytilahti requested a review from sdb9696 September 21, 2024 11:33
Copy link
codecov bot commented Sep 21, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 92.61%. Comparing base (b7fa0d2) to head (d202285).
Report is 212 commits behind head on master.

Files with missing lines Patch % Lines
kasa/iot/iotdevice.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1125      +/-   ##
==========================================
- Coverage   92.62%   92.61%   -0.02%     
==========================================
  Files          96       96              
  Lines        6117     6121       +4     
  Branches     1510     1511       +1     
==========================================
+ Hits         5666     5669       +3     
- Misses        353      354       +1     
  Partials       98       98              

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

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.

LGTM. Might be worth adapting the cli test in #1108 to be @device in this PR once 1108 is merged and rebased.

@rytilahti
Copy link
Member Author

LGTM. Might be worth adapting the cli test in #1108 to be @device in this PR once 1108 is merged and rebased.

It's rather hard to do this nicely as it'll require mocking different code paths for iot & smart :-( Perhaps it's better to do that if and when the query* interface gets refactored?

@sdb9696
Copy link
Collaborator
sdb9696 commented Sep 21, 2024

LGTM. Might be worth adapting the cli test in #1108 to be @device in this PR once 1108 is merged and rebased.

It's rather hard to do this nicely as it'll require mocking different code paths for iot & smart :-( Perhaps it's better to do that if and when the query* interface gets refactored?

query_mock = mocker.patch.object(dev.protocol, "query") doesn't work with iot?

@rytilahti
Copy link
Member Author
rytilahti commented Sep 21, 2024

Nope, it lands in

raise KasaException(f"No required {target} in response: {response}")
which raises an exception:

E        +  where 1 = <Result KasaException("No required system in response: <AsyncMock name='query()' id='140737268681952'>")>.exit_code

And mocking the _query_helper will cause query() not being called.

@rytilahti rytilahti added this to the 0.7.4 milestone Sep 26, 2024
@sdb9696
Copy link
Collaborator
sdb9696 commented Sep 27, 2024

Ok let's merge this then and include in the wider cli testing questions

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.

Ok let's get this merged

@sdb9696 sdb9696 merged commit 1ce5af2 into python-kasa:master Sep 27, 2024
28 of 30 checks passed
@rytilahti rytilahti deleted the feat/iot_reset branch September 27, 2024 17:13
@sdb9696 sdb9696 mentioned this pull request Sep 27, 2024
sdb9696 added a commit that referenced this pull request Sep 27, 2024
## [0.7.4](https://github.com/python-kasa/python-kasa/tree/0.7.4) (2024-09-27)

[Full Changelog](0.7.3...0.7.4)

**Release summary:**

- KL135 color temp range corrected to 9000k max
- Minor enhancements and project maintenance

**Implemented enhancements:**

- Add factory\_reset\(\) to iotdevice [\#1125](#1125) (@rytilahti)
- Add reboot\(\) to the device interface [\#1124](#1124) (@rytilahti)
- Add factory-reset command to cli [\#1108](#1108) (@rytilahti)

**Fixed bugs:**

- Extend KL135 ct range up to 9000K [\#1123](#1123) (@rytilahti)
- Fix cli command for device off [\#1121](#1121) (@sdb9696)

**Project maintenance:**

- Use pytest-socket to ensure no tests are performing io [\#1133](#1133) (@sdb9696)
- Enable ruff lint pycodestyle warnings [\#1132](#1132) (@sdb9696)
- Add autouse fixture to patch asyncio.sleep [\#1131](#1131) (@sdb9696)
- Mock asyncio.sleep for klapprotocol tests [\#1130](#1130) (@rytilahti)
- Add fixture for T110 fw 1.9.0 [\#1129](#1129) (@rytilahti)
- Speed up and simplify github workflows [\#1128](#1128) (@sdb9696)
- Add KS200M\(US\) fw 1.0.12 fixture [\#1127](#1127) (@GatorEG)
- Add stale PR/Issue github workflow [\#1126](#1126) (@sdb9696)
- Add fixture for KL135\(US\) fw 1.0.15 [\#1122](#1122) (@rytilahti)
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
0