GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add thermostat schedule, temperature source and history modules by o-gent · Pull Request #1806 · python-kasa/python-kasa

Conversation

@o-gent

@o-gent o-gent commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Adds support for the KE100/KE110 thermostat schedule, which was asked for in #1601, along with a few other components these thermostats and the T310/T315 sensors report but python-kasa didn't support yet.

New modules

Module Component What it does
ThermostatSchedule smart_control_schedule Read and toggle the schedule (thermostat_schedule switch) and its mode (thermostat_schedule_mode: everyday, weekday_sat_sun, single_day). get_schedules() fetches the schedules for a mode and set_schedule() replaces one day's slots.
TemperatureCorrection temperature_correction set_external_sensor() makes the thermostat use another sensor on the same hub (e.g. a T310) as its temperature source, or None for the built-in sensor.
TemperatureRecords temp_record The thermostat's last 24h of temperatures in 15 minute steps.
TemperatureHumidityRecords temp_humidity_record The sensor's last 24h of temperature and humidity, with timestamps.

The request names and parameters (get_sc_schedule_info, get_sc_schedule_rules, edit_sc_schedule_rule, set_sc_schedule_info, get/set_temperature_correction, get_temperature_records) come from the Kasa Android app, and I checked them against real devices.

Device behaviour worth knowing

  • Only the active mode's schedules can be edited. edit_sc_schedule_rule for another mode returns -1001. The same edit succeeds once that mode is active, so set_schedule() rejects ids from other modes with a hint to call set_mode() first.
  • The schedules come back in pages (start_index/sum). _ChildProtocolWrapper doesn't iterate list pages, so the module pages through them itself and keeps schedule_mode on each request. (SmartProtocol._get_list_request would also drop schedule_mode on later pages.)
  • Slots aren't returned in time order, so they're sorted. A day must be covered without gaps, with at most day_segment slots (6 on the KE100).
  • Hub children only refresh module queries every 24h. The record modules override this to 15 minutes, which matches the device's own interval. The schedule and temperature correction setters update the cached state straight away.

Fix: hub child module data lost on partial updates

SmartChildDevice._update replaced _last_update with only the responses for the modules queried in that cycle, so modules that weren't due lost their data and raised You need to call update() prior accessing module data. This didn't show before because all child modules refreshed on the same daily cycle. With the 15 minute record modules it happened 15 minutes in. It now merges the responses, as SmartDevice already does. The regression test is in test_childdevice.py. It uses hub fixtures because standalone child fixtures load as plain SmartDevices, which is how this got past the existing tests.

Fixtures and tooling

  • New KE100(EU) and KE100(UK) 2.6.0 fixtures with responses for the new components.
  • dump_devinfo now queries the new components, and scrubs temp_sensor_device_id by mapping it to the scrubbed child id (it can point at another child). It's also added to the log redactors.
  • FIXTURE_MISSING_MAP defaults for the older KE100/KE110/T315 fixtures, and a fake handler for edit_sc_schedule_rule that, like the device, only accepts edits to the active mode.

Testing

  • The full test suite and ruff pass, and mypy reports no issues in the new modules.
  • On hardware: KH100(UK) hub (fw 1.8.0) with four KE100s (fw 2.6.0, EU and UK). I read every valve's schedule, temperature source and history, edited one schedule and confirmed the change in the Kasa app, and checked the active-mode restriction.
  • The hub needs the TPAP transport from TPAP Implementation #1592, so I tested on a branch that combines both. This PR doesn't depend on TPAP Implementation #1592 and has no TPAP changes.
  • The T310 module is tested against the existing T310/T315 fixtures. I haven't yet tested set_external_sensor() with a real T310; I'll report back once mine arrive.

Not included: the T310's comfort temperature/humidity settings (get/set_comfort_temp_config, get/set_comfort_humidity_config) and the KE100's other settings (window open detection, night mode, shutdown mode, early start). The request names are known, and I can follow up once I have real responses for the sensor ones.

🤖 Generated with Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
o-gent and others added 5 commits October 22, 2026 20:13
@o-gent @claude
Add thermostat schedule, temperature source and history modules
67bfd5b
Add smart modules for components found on KE100/KE110 thermostats and
T310/T315 sensors that were not yet supported:

- ThermostatSchedule (smart_control_schedule): read and toggle the
  schedule and its mode via get/set_sc_schedule_info, fetch the
  paginated schedules via get_sc_schedule_rules and replace a day's
  slots via edit_sc_schedule_rule, with validation that the slots
  cover the whole day. Devices only accept edits to the active mode's
  schedules, so set_schedule() rejects ids from other modes.
- TemperatureCorrection (temperature_correction): use another sensor on
  the same hub as the thermostat's temperature source.
- TemperatureRecords (temp_record): the thermostat's 24h temperature
  history in 15 minute steps.
- TemperatureHumidityRecords (temp_humidity_record): the sensor's 24h
  temperature and humidity history.

Hub children do not iterate list pages, so the schedule module pages
through get_sc_schedule_rules itself, keeping schedule_mode on each
request. dump_devinfo now queries the new components.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@o-gent @claude
Scrub thermostat temperature sensor ids in fixtures and logs
420da39
get_temperature_correction returns temp_sensor_device_id, the device id
of the thermostat itself or of another hub child used as its temperature
source. dump_devinfo now maps it to the scrubbed child id, keeping the
link between the thermostat and its sensor, and it is redacted in logs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@o-gent @claude
Add KE100(EU) and KE100(UK) 2.6.0 fixtures
fba1b05
Dumped from devices paired to a KH100(UK) hub, including the responses
for the schedule, temperature correction and temperature record
components. The schedule tests now check against whatever schedules a
fixture provides rather than assuming the default test data.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@o-gent @claude
Keep hub child module data across partial updates
97c7f52
SmartChildDevice._update replaced _last_update with the response for the
modules queried in that cycle, so modules that were not due lost their
data and raised "You need to call update()". This only showed once child
modules had different update intervals: the record modules refresh every
15 minutes while others refresh daily. Merge the response instead, as
SmartDevice already does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@o-gent @claude
Narrow the fake transport type in the thermostat schedule tests
981c215
Fixes mypy attr-defined errors for list_return_size and info.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@codecov

codecov Bot commented Oct 22, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.56%. Comparing base (e29864b) to head (972cf1e).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1806      +/-   ##
==========================================
+ Coverage   93.43%   93.56%   +0.13%     
==========================================
  Files         160      164       +4     
  Lines       10095    10305     +210     
  Branches     1042     1062      +20     
==========================================
+ Hits         9432     9642     +210     
  Misses        471      471              
  Partials      192      192              

☔ 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.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@o-gent @claude
Cover module paging, format detection and sensor selection in tests
972cf1e
Brings the new modules to full line and branch coverage.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
rytilahti
rytilahti requested changes Oct 24, 2026
View reviewed changes

@rytilahti rytilahti left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Hi @o-gent and thanks for the PR! Could you please split this up into several PRs to make it easier to review? One for the fixture, and one for every new module supported would be the best! If you want and it is needed to test the implementation, feel free to include the fixture in the first PR.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@o-gent

o-gent commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

hey @rytilahti, will do when i can !

rytilahti reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Oct 25, 2026
Add KE100 EU/UK 2.6.0 fixtures and capture support #1812
Merged
Preserve hub child module data across partial updates #1813
Open
Add TemperatureRecords module #1814
Merged
Add TemperatureCorrection module #1815
Open
Add ThermostatSchedule module #1816
Open
Add TemperatureHumidityRecords module #1817
Draft
@o-gent

o-gent commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

Hey @rytilahti - split this into 6 PRs. One PR is still marked as draft as it depends on a couple of the other PRs. Hopefully, each PR is now well scoped for review!

rytilahti reacted with rocket emoji
All reactions
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rytilahti

rytilahti commented Nov 1, 2026

Copy link
Copy Markdown
Member

Great, thank you @o-gent! I reviewed and merged already a couple of them, I think we can close this one now and continue getting those changes in in their respective PRs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rytilahti rytilahti closed this Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@rytilahti rytilahti rytilahti requested changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@o-gent @rytilahti
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.