Fix SMARTCAM Time module and update tests by ZeliardM · Pull Request #1659 · python-kasa/python-kasa

Pull request overview

This PR fixes the SmartCam Time module's set_time method to properly set the device time manually. The fix addresses three key issues: formatting local_time in UTC (not machine local time), removing microseconds from the timestamp format, and switching timing_mode from "ntp" to "manual" so devices accept manual time updates.

Changes:

  • Fixed time formatting to use UTC without microseconds (format: 'YYYY-MM-DD HH:MM:SS')
  • Added logic to set timing_mode to "manual" before updating clock_status (for devices that support it)
  • Combined zone_id and timing_mode updates into a single API call for efficiency
  • Added comprehensive unit tests covering all device types (cameras with timing_mode, hubs without timing_mode)

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
kasa/smartcam/modules/time.py Rewrote set_time method to format time in UTC, set timing_mode to manual, and handle devices without timing_mode field
tests/test_common_modules.py Added three comprehensive unit tests verifying UTC formatting, ZoneInfo handling, and H200 hub compatibility
tests/fakeprotocol_smartcam.py Fixed variable shadowing issue by renaming nested 'section' variable to 'section_data'

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