Skip to content

feat: add get_schedule/set_schedule for heating and hot water - #173

Open
matt-thepie wants to merge 2 commits into
Pyhass:devfrom
matt-thepie:feat/set-schedule
Open

matt-thepie wants to merge 2 commits into
Pyhass:devfrom
matt-thepie:feat/set-schedule

Conversation

@matt-thepie

Copy link
Copy Markdown
Contributor

Summary

Adds schedule writing for heating and hot water, requested in #19.

  • New ScheduleMixin (src/devices/schedule.py), composed into HiveHeating and HiveHotwater.
  • get_schedule(device) returns an editable deep copy of the seven-day schedule.
  • set_schedule(device, schedule) validates and normalises the week (drops extra keys the Hive web app adds, sorts slots, raises ValueError on bad input), posts all seven days (Hive only accepts full-week updates), then re-reads the product and returns False if Hive answered 200 but ignored the change.
  • camelCase aliases getSchedule / setSchedule in helper/compat_aliases.py.
  • README section and examples/example_set_schedule.py, a round-trip example that edits one slot, verifies it, and restores the original.

Home Assistant impact

Additive only. Nothing in the HA hive integration calls these methods; climate.py and water_heater.py on dev use setMode, setTargetTemperature, setBoostOn/Off only. No existing method, return shape or device.status key changes.

Testing

  • Full suite: 1091 passed, coverage 100%. ruff, mypy, pylint 10/10, bandit clean.
  • Live round trip on a trvcontrol zone: slot edit stored and restored correctly (set_schedule returned True both times, re-read schedules matched).
  • Hot water is covered by file-mode tests only; I have a combi boiler so no hotwater product to test against. Someone with a Hive hot water zone could confirm with the example (swap hive.heating for hive.hotwater).

Note: running the example against the live service today also needs #169, since the Hive SSO login page changed on 2026-10-20.

Closes #19

🤖 Generated with Claude Code

Adds ScheduleMixin (src/devices/schedule.py), composed into HiveHeating and
HiveHotwater. get_schedule returns an editable copy of the weekly schedule;
set_schedule validates and normalises the week, posts all seven days (Hive
only accepts full-week updates), then re-reads the product and returns False
if Hive silently ignored the change. camelCase aliases getSchedule/setSchedule
are included for HA compatibility.

Verified live on a trvcontrol zone: slot edit stored and restored correctly.

Closes Pyhass#19

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (dev@0294877). Learn more about missing BASE report.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff           @@
##             dev     #173   +/-   ##
======================================
  Coverage       ?   99.96%           
======================================
  Files          ?       31           
  Lines          ?     2717           
  Branches       ?      323           
======================================
  Hits           ?     2716           
  Misses         ?        0           
  Partials       ?        1           
Flag Coverage Δ
unittests 99.96% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/devices/heating.py 100.00% <100.00%> (ø)
src/devices/hotwater.py 100.00% <100.00%> (ø)
src/devices/schedule.py 100.00% <100.00%> (ø)
src/helper/compat_aliases.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] setting the schedule for heat & water

1 participant