Skip to content

feat: add holiday mode services and sensors - #222

Draft
nsleigh wants to merge 3 commits into
Pyhass:masterfrom
nsleigh:feature/holiday-mode
Draft

nsleigh wants to merge 3 commits into
Pyhass:masterfrom
nsleigh:feature/holiday-mode

Conversation

@nsleigh

@nsleigh nsleigh commented Oct 21, 2026

Copy link
Copy Markdown

What does this change?

Adds Hive's whole-home holiday mode to the integration, building on the hub holiday API added to the library in Pyhass/Pyhive#149.

Services

  • hive.set_holiday_mode: start, end and temperature (7–35 °C). Start and end are truncated to the minute, as in the Hive app.
  • hive.cancel_holiday_mode

A rejected request or an API error is raised as HomeAssistantError.

Sensors (on the hub device)

  • Holiday Mode: off / scheduled / active, with start, end and temperature attributes
  • Holiday Date Start and Holiday Date End: timestamps

The three sensors share one cached fetch and poll every 30 minutes. They also refresh at a scheduled start and a few times after a set or cancel, because Hive's backend takes a few minutes to change state. If Hive omits start, end or temperature from a response, the last known values are kept.

The services and any pending refreshes are removed when the entry unloads.

Depends on a library beta. This needs pyhive-integration==2.0.0b4, the first release containing #149, so manifest.json is pinned to it. I've opened this as a draft until a 2.0 release is ready. I checked that every hive.<object>.<method> call in the integration exists in 2.0.0b4.

I've been running this code on my own system since July (on a fork that bundles the library). This PR contains only the holiday mode changes, plus the cleanup on unload, which is new.

Related issues

Relates to #73 (closed as not planned).

Checklist

  • Tests added or updated. New tests/test_holiday_mode.py covers the sensor states, partial responses, unavailability, both services, error handling, temperature validation and cleanup on unload. conftest.py now gives the mocked Hive a hub and a holiday response, and two "no sensors" assertions now allow for the hub's holiday sensors.
  • script/test: run locally against 2.0.0b4, 90 pass and 4 fail. The same 4 fail on master (test_setup_failures ×2, test_translations ×2).
  • script/lint --check: this PR adds no new lint or formatting issues; the ones already on master are unchanged. I haven't regenerated translations/en.json, because doing so rewrites the whole file and would undo its restoration in 5e63418. I can add that here or in a separate PR if you'd like.
  • version not bumped. This isn't meant for a release yet.

🤖 Generated with Claude Code

Adds whole-home holiday mode support on top of pyhive-integration's
hub holiday API (Pyhass/Pyhive#149, first released in 2.0.0b4):

- hive.set_holiday_mode (start, end, temperature 7-35) and
  hive.cancel_holiday_mode services. Start/end are truncated to the
  minute, matching the Hive app; failures raise HomeAssistantError.
- Holiday Mode (off/scheduled/active), Holiday Date Start and Holiday
  Date End sensors on the hub. They share one cached fetch, poll every
  30 minutes, refresh at a scheduled start, and run a short catch-up
  burst after set/cancel because Hive's backend lags the request. A
  partial API response keeps the last known start/end/temperature.
- Services, and any pending catch-up refreshes, are removed on unload.
- Requires pyhive-integration==2.0.0b4. Every hive.<object>.<method>
  call the integration makes was checked to exist in 2.0.0b4.

Tests: new tests/test_holiday_mode.py; the mocked Hive now has a hub
and holiday response, and two "no sensors" assertions now allow the
hub's holiday sensors. The 4 failures that already occur on master
(test_setup_failures x2, test_translations x2) are unchanged.

Ported from nsleigh/Hive-Custom-Component feature/vendor-apyhiveapi-dev
(a2ac9b9, 1e4e88a, 4ae6cba, fe2d5a9, b24c3da, 57c1ff3), without the
vendored library or unrelated fixes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The holiday mode sensors are added with update_before_add, so an
exception from get_holiday_mode() during setup (e.g. Hive's cloud timing
out at boot) stopped HA adding them at all until the next restart. Catch
TimeoutError, aiohttp ClientError and HiveApiError in async_update and
go unavailable instead; the 30-minute poll and dispatcher refreshes
bring them back.

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

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.

2 participants