Skip to content

Conversation

@ZeliardM
Copy link
Contributor

Updated scanning and joining Wi-Fi for SMART devices that may use a newer connection process.

@codecov
Copy link

codecov bot commented Jan 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.86%. Comparing base (122849f) to head (0da9c38).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1639      +/-   ##
==========================================
+ Coverage   92.82%   92.86%   +0.03%     
==========================================
  Files         157      157              
  Lines        9649     9698      +49     
  Branches      976      981       +5     
==========================================
+ Hits         8957     9006      +49     
  Misses        492      492              
  Partials      200      200              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds support for a newer Wi-Fi connection process for SMART devices, including support for WPA3 and RSA-encrypted passwords. The changes introduce a fallback mechanism where devices first attempt to use the legacy get_wireless_scan_info API, and if that fails, fall back to the newer scanApList API with enhanced security features.

Key Changes

  • Added dual-path Wi-Fi scanning with automatic fallback between get_wireless_scan_info and scanApList APIs
  • Implemented RSA public key encryption for Wi-Fi passwords in the newer connection flow
  • Extended the WifiNetwork dataclass to support additional fields (auth, encryption) used by newer SMART devices

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 9 comments.

File Description
kasa/device.py Extended WifiNetwork dataclass with optional auth and encryption fields for newer SMART device APIs
kasa/smart/smartdevice.py Implemented dual-path Wi-Fi scanning and joining with RSA encryption support for newer devices, added instance variables for WPA3 support and public key tracking

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

Hey @ZeliardM and happy belated new year! Sorry for not getting back to you earlier, I added some comments to this PR and will try to review the rest of your open ones in a timely manner.

For this PR, I would suggest that we split the wifi handling into its own module to avoid overloading the base class with many implementation details. See my comments inline, and let me know what you think!

@rytilahti rytilahti added the enhancement New feature or request label Jan 26, 2026
@ZeliardM
Copy link
Contributor Author

@rytilahti I was actually thinking since this is pertaining to the SmartCamDevice, I just create wifi_scan and wifi_join in the smartcamdevice.py files instead. I didn't realize the smartcamdevice.py used the same wifi_scan and wifi_join as the smartdevice.py and didn't have their own functions. Thoughts? It would change how I have this setup and make it cleaner since the new functions would be in there without the back and forth in the smartdevice.py

@rytilahti
Copy link
Member

I was actually thinking since this is pertaining to the SmartCamDevice, I just create wifi_scan and wifi_join in the smartcamdevice.py files instead. I didn't realize the smartcamdevice.py used the same wifi_scan and wifi_join as the smartdevice.py and didn't have their own functions. Thoughts? It would change how I have this setup and make it cleaner since the new functions would be in there without the back and forth in the smartdevice.py

Ah, it probabbly makes sense to move them there if that's the case, but I think we could still proceed to clean up the implementation and reuse the interfaces wherever it makes sense. Some parts of the scanning (fallbacks to other methods) will probably need some thought to see how it fits the best API-wise.

@ZeliardM
Copy link
Contributor Author

I'll update everything after a bit and let you know when to take another look. I think the original implementation in the smartdevice.py was fine for those devices, we just need to add the functions to the smartcamdevice.py and have it use those instead of the ones in the smartdevice.py...will let you know.

@ZeliardM ZeliardM requested a review from rytilahti January 27, 2026 00:13
@ZeliardM
Copy link
Contributor Author

ZeliardM commented Jan 27, 2026

@rytilahti I made the following changes:

  • Moved the new WiFi handling to the smartcamedevice.py and reverted all of the complex changes to the smartdevice.py. This allowed for simpler, cleaner WiFi handling in the smartcamdevice.py all around and was easier to work with.
  • Modified the wifi CLI to make the keytype optional for the smartcamdevice.py since keytype is not handled in the new wifi join.
  • Improved the wifi join by implementing a scan at the beginning of the join and pulling the required information from the scan without having to manually input all of it from the CLI. We could make a similar change to the other WiFi handlers in iotdevice.py and smartdevice.py and get rid of the keytype CLI argument completely. That would be up to you and done in another PR.
  • Updated all the test coverage correctly to handle the wifi changes.

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