Repository navigation
feat: add thermostat temperature history - #174
matt-thepie wants to merge 2 commits into
Conversation
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 Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #174 +/- ##
======================================
Coverage ? 99.96%
======================================
Files ? 30
Lines ? 2672
Branches ? 313
======================================
Hits ? 2671
Misses ? 0
Partials ? 1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
| if self.session.config.file: | ||
| return [] | ||
| try: | ||
| resp = await self.session.api.get_heating_history( |
There was a problem hiding this comment.
🤖 Claude Code Review
The docstring says this returns an empty list "if … the request fails", but only HiveApiError is caught. HiveApiAsync._call_endpoint re-raises asyncio.TimeoutError. request() raises HiveAuthError on 401/403 and NoApiToken when no token is stored.
Failure scenario: a Hive timeout, or a token that has expired between polls, makes get_temperature_history raise instead of returning []. This method also never refreshes tokens, unlike the _execute_state_change path.
Suggested fix: either catch (HiveApiError, asyncio.TimeoutError) here, or update the docstring to say that timeout and auth errors propagate. If it's meant to be callable on its own, refresh the token first the way the other handlers do.
Minor: for TRV zones the documented 404 is logged at ERROR by request() before this WARNING, so callers get noisy duplicate logs. Consider gating on device.hive_type == "heating".
🤖 Claude Code ReviewVerdict: Small, well-tested additive change. One robustness issue to fix and no other bugs found. Bugs
Other findings
Home Assistant check: I fetched Not reviewed: I did not run the test suite and did not check the generated sync package. Automated review by Claude Code · workflow run |
Summary
Adds thermostat temperature history, requested in #34.
HiveApiAsync.get_heating_historyandHiveApi.get_heating_history(node_id, start, end, time_unit="HOURS", rate=1)call/history/heating/<id>withstart/endin milliseconds since the epoch.operationis fixed toAVG, 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, onHiveApiError, and for malformed responses, so callers never see an exception for a zone without history.getTemperatureHistoryonHeatingCompatMixin.Home Assistant impact
Additive only. Nothing in the HA
hiveintegration calls these methods;climate.pyondevusesgetClimate,setMode,setTargetTemperatureandsetBoostOn/Offonly. No existing method, return shape ordevice.statuskey changes.Testing
heatingzone: 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 itsboilermoduleparent ID work; thethermostatuiand hub IDs return 404.trvcontrolzones 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