Skip to content

feat: add thermostat temperature history - #174

Merged
KJonline merged 3 commits into
Pyhass:devfrom
matt-thepie:feat/temperature-history
Nov 2, 2026
Merged

KJonline merged 3 commits into
Pyhass:devfrom
matt-thepie:feat/temperature-history

Conversation

@matt-thepie

Copy link
Copy Markdown
Contributor

Summary

Adds thermostat temperature history, requested in #34.

  • HiveApiAsync.get_heating_history and HiveApi.get_heating_history(node_id, start, end, time_unit="HOURS", rate=1) call /history/heating/<id> with start/end in milliseconds since the epoch. operation is fixed to AVG, the only value Hive accepts. Both layers are coded by hand since unasync does not cover the API modules.
  • Climate.get_temperature_history(device, start, end, time_unit="HOURS", rate=1) returns [{"date": <int ms>, "temperature": <float>}, ...] sorted by date. Hive returns dates as strings; they are cast to int. Returns [] in file mode, on HiveApiError, and for malformed responses, so callers never see an exception for a zone without history.
  • camelCase alias getTemperatureHistory on HeatingCompatMixin.
  • README snippet.

Home Assistant impact

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

Testing

  • Full suite: 1072 passed, coverage 100%. ruff, mypy, pylint 10/10, bandit clean.
  • Live against a heating zone: 24 hourly rows over the last day and 7 daily rows over the last week, values matching the Hive app's graph. Both the product ID and its boilermodule parent ID work; the thermostatui and hub IDs return 404.
  • trvcontrol zones return 404 ({"error": "NOT_FOUND"}), which the getter turns into [] with a warning. Hot water history was not tried; I have a combi boiler.

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

Closes #34

🤖 Generated with Claude Code

Adds get_heating_history to both API layers (async and sync), calling
/history/heating/<id> with start/end in ms since epoch, timeUnit and rate,
always with operation=AVG (the only value Hive accepts).

Adds Climate.get_temperature_history(device, start, end, time_unit, rate),
which returns [{"date": <int ms>, "temperature": <float>}, ...] sorted by
date, with int-cast dates (Hive returns them as strings). Returns [] in
file mode, on HiveApiError (Hive answers 404 for zones with no history,
including TRVs) and for malformed responses. camelCase alias
getTemperatureHistory included.

Verified live against a heating zone: 24 hourly rows over a day and 7 daily
rows over a week. TRV zones return 404 as noted in the issue.

Closes Pyhass#34

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     #174   +/-   ##
======================================
  Coverage       ?   99.96%           
======================================
  Files          ?       30           
  Lines          ?     2676           
  Branches       ?      313           
======================================
  Hits           ?     2675           
  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/api/hive_api.py 100.00% <100.00%> (ø)
src/api/hive_async_api.py 100.00% <100.00%> (ø)
src/devices/heating.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.

@KJonline KJonline added the claude-review Run Claude code review on this PR (required for fork PRs) label Oct 22, 2026
Comment thread src/devices/heating.py Resolved
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Claude Code Review

Verdict: Small, well-tested additive change. One robustness issue to fix and no other bugs found.

Bugs

  • get_temperature_history documents an empty list on request failure, but it only catches HiveApiError. asyncio.TimeoutError, HiveAuthError (401/403) and NoApiToken propagate to the caller. The method also does no token refresh. See the inline comment.

Other findings

  • Should fix: align the docstring with the real behaviour, or catch the extra exceptions.
  • Minor: a TRV zone's 404 is logged at ERROR by request() before the WARNING here. Consider checking hive_type.
  • Tests and coverage look fine. The sync hive_api.py counterpart is included.

Home Assistant check: I fetched climate.py. It only uses setMode, setTargetTemperature, setBoostOn, setBoostOff and getClimate. Nothing in Home Assistant calls the new method, so no existing behaviour breaks. The camelCase alias was added.

Not reviewed: I did not run the test suite and did not check the generated sync package.


Automated review by Claude Code · workflow run

Refresh tokens before the request, return [] on timeouts as the
docstring promised, let HiveAuthError propagate so the caller can
re-authenticate, and skip TRV zones whose history endpoint 404s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KJonline
KJonline merged commit 0c21b1a into Pyhass:dev Nov 2, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude-review Run Claude code review on this PR (required for fork PRs)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add thermostat temperature history

2 participants