Skip to content

Update smartcam credential handling and tests#1664

Open
ZeliardM wants to merge 8 commits into
python-kasa:masterfrom
ZeliardM:feature/smartcam-update-credentials
Open

Update smartcam credential handling and tests#1664
ZeliardM wants to merge 8 commits into
python-kasa:masterfrom
ZeliardM:feature/smartcam-update-credentials

Conversation

@ZeliardM

@ZeliardM ZeliardM commented Mar 1, 2026

Copy link
Copy Markdown
Collaborator

This PR adds update_admin_password in the library and CLI for SMARTCAM devices. It also updates the update_credentials function to correctly handle the local_account for local device authentication. It updates all of the required tests and code coverage as well.

Copilot AI review requested due to automatic review settings March 1, 2026 03:44
@ZeliardM

ZeliardM commented Mar 1, 2026

Copy link
Copy Markdown
Collaborator Author

This should replace PR #1661, working with the user on this PR before they created their own.

Comment thread kasa/smartcam/smartcamdevice.py Dismissed
Comment thread kasa/smartcam/smartcamdevice.py Dismissed
Comment thread tests/smartcam/test_smartcamdevice.py Fixed
Comment thread tests/smartcam/test_smartcamdevice.py Fixed
Comment thread tests/smartcam/test_smartcamdevice.py Fixed
Comment thread tests/smartcam/test_smartcamdevice.py Fixed
Comment thread tests/smartcam/test_smartcamdevice.py Fixed
Comment thread tests/smartcam/test_smartcamdevice.py Fixed
Comment thread tests/smartcam/test_smartcamdevice.py Fixed
@codecov

codecov Bot commented Mar 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.31%. Comparing base (aba457a) to head (0e9d545).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1664      +/-   ##
==========================================
+ Coverage   93.29%   93.31%   +0.02%     
==========================================
  Files         157      157              
  Lines        9932     9965      +33     
  Branches     1022     1027       +5     
==========================================
+ Hits         9266     9299      +33     
  Misses        471      471              
  Partials      195      195              

☔ View full report in Codecov by Harness.
📢 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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds first-class support for updating SMARTCAM admin password (library + CLI) and corrects SMARTCAM local credential updates to target the proper local account identity, with expanded test coverage to validate request payloads and fallback behavior.

Changes:

  • Add SmartCamDevice.update_admin_password() plus shared password encryption/hash helpers.
  • Update SmartCamDevice.update_credentials() to use secname="local_account" and improved old-password fallback handling.
  • Add CLI update_admin_password command and extend smartcam/CLI tests for new/updated behavior.

Reviewed changes

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

Show a summary per file
File Description
kasa/smartcam/smartcamdevice.py Adds admin password update API, refactors RSA encryption into _encrypt_password, and updates credential update request construction/fallbacks.
kasa/cli/device.py Adds device update-admin-password command (implemented as update_admin_password).
kasa/cli/main.py Exposes update_admin_password as a top-level runnable device command via lazy subcommand mapping.
tests/test_cli.py Adds CLI test covering confirmation prompt + invocation of update_admin_password.
tests/smartcam/test_smartcamdevice.py Adds extensive unit tests validating request payloads for LV2/LV3 and fallback behavior for both admin password and credentials updates.

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

Comment thread kasa/cli/device.py Outdated
Comment thread tests/smartcam/test_smartcamdevice.py Outdated
@oliv3r

oliv3r commented May 18, 2026

Copy link
Copy Markdown

Works for me; though the --username requirement is a bit odd, the camera accept anything (translates it to admin).

@rytilahti I just bought one of these and was super frustrating to see half the stuff not working on master (well the pip release was even more confusing :) so what else can we do to help get this merged? :)

@rytilahti rytilahti added this to the 0.11 milestone Jul 5, 2026
@rytilahti rytilahti added the enhancement New feature or request label Jul 5, 2026

@rytilahti 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.

I did not yet review the tests, because I think it makes sense to simplify the logic inside update_credentials before doing that. Let me know what do you think about my suggestions inline!

Comment thread kasa/smartcam/smartcamdevice.py Outdated
Comment thread kasa/smartcam/smartcamdevice.py Outdated
@ZeliardM
ZeliardM force-pushed the feature/smartcam-update-credentials branch from d215861 to e9e33c9 Compare July 8, 2026 01:48
Comment thread tests/smartcam/test_smartcamdevice.py Fixed
@ZeliardM
ZeliardM requested a review from rytilahti July 8, 2026 03:25

@rytilahti 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.

LGTM, feel free to merge as you wish! I added a quick nit on the way the candidates are collected as I think it makes no sense to optimize here, feel free to act on it or merge as is.

Comment thread kasa/smartcam/smartcamdevice.py Outdated
@oliv3r

oliv3r commented Jul 11, 2026

Copy link
Copy Markdown

after commenting, i spent quite some time on getting stuff working. well not me, claude ;) so i got a lot of the features to work. I haven't had time to play with it over the past month, but in a few weeks I have some time again to clean stuff up.

@ZeliardM

Copy link
Copy Markdown
Collaborator Author

@oliv3r What stuff working? Just curious. Is this PR still working for you?

@ZeliardM
ZeliardM force-pushed the feature/smartcam-update-credentials branch from c12fd8a to d7b91f3 Compare July 11, 2026 20:46
Comment thread tests/smartcam/test_smartcamdevice.py Fixed
Comment thread tests/smartcam/test_smartcamdevice.py Fixed
Comment thread tests/smartcam/test_smartcamdevice.py Fixed
Comment thread tests/smartcam/test_smartcamdevice.py Fixed
Comment thread tests/smartcam/test_smartcamdevice.py Fixed
@ZeliardM
ZeliardM force-pushed the feature/smartcam-update-credentials branch from 54c37d1 to 0e9d545 Compare July 11, 2026 20:59
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.

5 participants