Skip to content

fix: restore missing camelCase getter aliases for HA core compatibility - #158

Open
nsleigh wants to merge 2 commits into
Pyhass:devfrom
nsleigh:fix/compat-alias-missing-getters
Open

nsleigh wants to merge 2 commits into
Pyhass:devfrom
nsleigh:fix/compat-alias-missing-getters

Conversation

@nsleigh

@nsleigh nsleigh commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Summary

The camelCase → snake_case rename left helper/compat_aliases.py covering only the setters (setMode, setBoostOn, …) plus getClimate/getLight/etc. Most getters were never aliased.

Home Assistant core's built-in hive integration (sensor/binary_sensor platforms) still uses the camelCase API. It calls getters directly for its diagnostic entities, e.g. hive.heating.getMode(device). With this library on dev, those calls raise AttributeError. As a result, these entities go unavailable:

  • Mode / State / Boost sensors on heating zones, TRVs and hot water
  • The hub's Smoke / Dog Bark / Glass Break binary sensors

Current/Target Temperature keep working because core reads them from the pre-computed device.status dict instead of calling a getter.

Changes

All changes are in src/helper/compat_aliases.py except the HiveHub wiring. Every new method is a one-line delegate to its existing snake_case method.

  • HeatingCompatMixin: getMinTemperature, getMaxTemperature, getCurrentTemperature, getTargetTemperature, getMode, getState, getCurrentOperation, getBoostStatus, getBoostTime, getHeatOnDemand, setHeatOnDemand, getOperationModes, getScheduleNowNextLater, minmaxTemperature
  • WaterHeaterCompatMixin: getBoost, getBoostTime, getMode, getState, getOperationModes, getScheduleNowNextLater
  • LightCompatMixin: getState, getBrightness, getMinColorTemp, getMaxColorTemp, getColorTemp, getColor, getColorMode
  • SwitchCompatMixin: getState, getPowerUsage, getSwitchState
  • SensorCompatMixin / ActionCompatMixin: getState
  • New HubCompatMixin: getSmokeStatus, getDogBarkStatus, getGlassBreakStatus, mixed into HiveHub in src/devices/hub.py

Note on WaterHeaterCompatMixin.get_boost

The existing alias was named get_boost (snake_case), but HA core calls getBoost. This PR adds getBoost and keeps get_boost, because devices/sensor.py (Hotwater_Boost) still calls the snake_case name. Renaming it instead would break that sensor.

Testing

  • Added test_camelcase_get_boost_delegates_to_get_boost_status. The full suite passes (1023 tests).
  • I checked that every new alias delegates to a method that exists on dev.
  • Ran against a live Home Assistant install with a real Hive account (thermostat, 10 TRVs, hot water, hub):
    • All previously-unavailable Mode / Boost / State sensors and the hub status binary sensor came back.
    • The other ~120 Hive entities showed no regressions.

🤖 Generated with Claude Code

nsleigh and others added 2 commits September 28, 2026 11:17
The camelCase -> snake_case rename left compat_aliases.py covering only
setters (setMode, setBoostOn, ...) plus getClimate/getLight/etc. Home
Assistant core's built-in hive sensor/binary_sensor platforms are written
against the old camelCase API and call getter methods directly (e.g.
hive.heating.getMode(device)) to populate diagnostic entities such as
Mode, State, and Boost sensors, and the hub's Smoke/Dog Bark/Glass Break
binary_sensors. Those calls now raise AttributeError since the methods
only exist as get_mode()/get_state()/etc, so the entities silently stop
updating and go unavailable after the object holding the last cached
state is dropped (e.g. on next HA restart).

Current/Target Temperature sensors were unaffected because core reads
those from the pre-computed device.status dict rather than calling a
getter directly.

Also fixes an existing gap: WaterHeaterCompatMixin only offered the
snake_case get_boost (still used by the Hotwater_Boost sensor), not the
camelCase getBoost that HA core calls, so it now provides both.

Changes:
- HeatingCompatMixin: add getMinTemperature, getMaxTemperature,
  getCurrentTemperature, getTargetTemperature, getMode, getState,
  getCurrentOperation, getBoostStatus, getBoostTime, getHeatOnDemand,
  setHeatOnDemand, getOperationModes, getScheduleNowNextLater,
  minmaxTemperature
- WaterHeaterCompatMixin: add getBoost alongside get_boost (bugfix),
  getBoostTime, getMode, getState, getOperationModes,
  getScheduleNowNextLater
- LightCompatMixin: add getState, getBrightness, getMinColorTemp,
  getMaxColorTemp, getColorTemp, getColor, getColorMode
- SwitchCompatMixin: add getState, getPowerUsage, getSwitchState
- SensorCompatMixin: add getState
- ActionCompatMixin: add getState
- New HubCompatMixin (getSmokeStatus, getDogBarkStatus,
  getGlassBreakStatus), wired into HiveHub in devices/hub.py

Verified in a Home Assistant instance: all previously-unavailable
sensor.*_mode / sensor.*_boost / sensor.*_state entities (10 TRVs +
thermostat) and the hub's binary_sensor.hive_hub_status came back after
this change, with no regressions to entities that were already working.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The alias commit only tested getBoost, leaving 34 new delegates
uncovered and dropping total coverage to 98.95%, below the 99%
fail_under gate. Add one parametrized test asserting each alias calls
its snake_case method with the same arguments and returns its result.

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

codecov Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.96%. Comparing base (91d96b4) to head (a16f33a).
⚠️ Report is 1 commits behind head on dev.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##              dev     #158   +/-   ##
=======================================
  Coverage   99.96%   99.96%           
=======================================
  Files          30       30           
  Lines        2571     2643   +72     
  Branches      297      297           
=======================================
+ Hits         2570     2642   +72     
  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/devices/hub.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 5, 2026

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

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.

2 participants