Skip to content

feat: add holiday mode support (get/set/cancel)#149

Open
nsleigh wants to merge 6 commits into
Pyhass:devfrom
nsleigh:dev
Open

feat: add holiday mode support (get/set/cancel)#149
nsleigh wants to merge 6 commits into
Pyhass:devfrom
nsleigh:dev

Conversation

@nsleigh

@nsleigh nsleigh commented Jul 11, 2026

Copy link
Copy Markdown

Summary

  • Adds get_holiday_mode() / set_holiday_mode() / cancel_holiday_mode() to both the async (HiveApiAsync) and sync (HiveApi) API layers, plus a HiveHub convenience wrapper (set_holiday_mode takes datetime start/end and converts to epoch-ms internally).
  • The /holiday-mode endpoint was previously unimplemented in this library (only the URL constant existed, going back to 2021) — the request/response shape (GET/POST/DELETE, epoch-millisecond start/end, temperature) was confirmed from a HAR capture of Hive's own website, then verified end-to-end against a real account.
  • Also extends the sync HiveApi.request() to support DELETE (previously only GET/POST), needed for cancel_holiday_mode().
  • Related: this investigation started from [BUG] Heat on demand fails Hive-Custom-Component#204 (Heat On Demand MALFORMED_REQUEST). Root cause turned out to be that autoBoost is not a client-writable field — it appears to be a server-side side effect of Holiday Mode, which is why this PR adds real Holiday Mode support instead of patching that field directly.
  • Known behavior worth noting: Hive's backend does not reject a past start time (confirmed live) — that's only enforced client-side by the Hive app/website UI, not the API. Left set_holiday_mode as a thin wrapper matching the real API contract rather than adding client-side validation.

Test plan

  • New unit tests for get_holiday_mode/set_holiday_mode/cancel_holiday_mode in both tests/unit/test_hive_async_api.py and tests/unit/test_hive_api.py
  • New module tests for the HiveHub wrapper in tests/module/test_hub.py
  • Full suite passes (1018/1018), ruff clean, mypy clean
  • Verified live end-to-end against a real Hive account: scheduled a 7-day holiday window starting in 1 hour, confirmed via GET /holiday-mode readback that start/end matched, then cancelled and confirmed cancellation; also confirmed a past-start-time request is accepted by the API (not rejected)

🤖 Generated with Claude Code

nsleigh and others added 4 commits July 11, 2026 13:40
Adds get_holiday_mode/set_holiday_mode/cancel_holiday_mode to the async and
sync API layers and a HiveHub wrapper accepting datetime start/end. Payload
shape (GET/POST/DELETE on /holiday-mode, epoch-ms start/end + temperature)
was confirmed via a HAR capture of Hive's own website, since this endpoint
was previously unimplemented. Includes the diagnostic scripts used to
reverse-engineer it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Exercises HiveHub.get_holiday_mode/set_holiday_mode/cancel_holiday_mode
against a real Hive account: schedules a 7-day window starting in an hour
(verified via GET readback, then cancelled before it can go active), and
a second window starting an hour in the past to check whether the backend
rejects it (it doesn't -- only the app's UI enforces that, not the API).
Prints both UTC and local time so results are directly comparable against
the Hive app/website.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Not intended to be committed to the repo -- kept locally only.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Not intended to be committed to the repo -- kept locally only.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.96%. Comparing base (8d97dca) to head (412d32c).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##              dev     #149   +/-   ##
=======================================
  Coverage   99.96%   99.96%           
=======================================
  Files          30       30           
  Lines        2508     2563   +55     
  Branches      292      296    +4     
=======================================
+ Hits         2507     2562   +55     
  Partials        1        1           
Flag Coverage Δ
unittests 99.96% <100.00%> (+<0.01%) ⬆️

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

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

@KJonline

Copy link
Copy Markdown
Contributor

@nsleigh please can you fix the linting errors please

Two dict literals in test_hub.py exceeded ruff format's line-wrap
threshold, failing the Lint CI check (ruff check itself was clean,
since E501 is ignored, but ruff format still wants the wrap).
@nsleigh

nsleigh commented Jul 12, 2026

Copy link
Copy Markdown
Author

@nsleigh please can you fix the linting errors please

@KJonline I believe they are fixed now

@nsleigh

nsleigh commented Jul 12, 2026

Copy link
Copy Markdown
Author

@nsleigh please can you fix the linting errors please

@KJonline I believe they are fixed now

They're not, I'll spend some more time on this soon.

@KJonline

Copy link
Copy Markdown
Contributor

@nsleigh there is just the 2 pylint ones

`

  • hook id: pylint
  • exit code: 4

************* Module tests.unit.test_hive_api
tests/unit/test_hive_api.py:659:20: W0612: Unused variable 'url_arg' (unused-variable)
************* Module tests.unit.test_hive_async_api
tests/unit/test_hive_async_api.py:570:8: W0404: Reimport 'json' (imported line 4) (reimported)
`

- test_hive_api.py: drop unused url_arg from tuple-unpack, index the
  two needed values individually (matches existing pattern elsewhere
  in this file) — fixes W0612 unused-variable
- test_hive_async_api.py: remove redundant local 'import json', module
  already imports it at the top — fixes W0404 reimported
@nsleigh

nsleigh commented Jul 13, 2026

Copy link
Copy Markdown
Author

I am hoping they are ok now - relying too much on AI!

@nsleigh

nsleigh commented Jul 14, 2026

Copy link
Copy Markdown
Author

@KJonline all fixed on my side. The new failure is due to the workflow not working on a branch.

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.

2 participants