fix: let a water heater's state be its operation mode - #40
Open
hacctarr wants to merge 1 commit into
Open
Conversation
WaterHeaterEntity.state returns current_operation. PoolWaterHeater overrode it to return on/idle/off, values that are never members of operation_list, so the frontend's water-heater-operation-modes feature could not resolve a selection: it reads the entity state and matches it against operation_list. The active heater therefore never highlighted whenever one was assigned, while an unheated body highlighted "off" correctly, which reads as the control being backwards. Nothing is lost by removing the override. HeaterBinarySensor already publishes the same predicate the override encoded (body ON, heater assigned to this body, HTMODE non-zero), and STATUS and HTMODE remain exposed as attributes on the entity. The former "idle" case is now the operation mode reading as the heater's name while that binary sensor reads off. BREAKING CHANGE: automations that test a water_heater entity for the states "on" or "idle" need to move to the heater's binary sensor.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
PoolWaterHeateroverridesstateto returnon/idle/off.WaterHeaterEntity.stateis defined to returncurrent_operation:https://github.com/home-assistant/core/blob/dev/homeassistant/components/water_heater/__init__.py
Because the override's return values are never members of
operation_list, the frontend'swater-heater-operation-modestile feature cannot resolve a selection. It builds its options fromoperation_listbut takes the selected value from the entity state:So the active heater never highlights when one is assigned, while an unheated body matches the literal
offoption and highlights correctly. The control reads as inverted: the body that is heating shows nothing selected, and the body that is not shows a selection.Two bodies on the same controller, before this change:
water_heater.spaonMasterTemp['off', 'MasterTemp']water_heater.pooloffoff['off', 'MasterTemp']offWhy removing the override loses nothing
HeaterBinarySensoralready publishes exactly the predicate the override encoded, against the same three attributes:STATUSandHTMODEalso stay exposed as entity attributes viaextraStateAttributes, so nothing has to be recomputed to recover the old value. The formeridlecase (heater assigned, not currently firing) is now the operation mode reading as the heater's name while that binary sensor readsoff.This also follows the approach suggested in #11 for the closely related manual-heat case: put "the heater is actually firing" in a binary sensor rather than in the water heater's state.
Verification
Live against an IntelliCenter with one MasterTemp shared between a pool and a spa body, spa heating at the time (
Status: ON,HEATER: H0001,HTMODE: 6).After:
water_heater.spaMasterTempMasterTemponwater_heater.pooloffoffon(shared heater, other body)Both tiles now highlight their active mode, and the firing signal is unchanged. No new errors from the integration in the log after reload.
Breaking change
Automations that test a
water_heaterentity for the statesonoridleneed to move to the heater's binary sensor. Tests foroffare unaffected, since an unassigned body already returnedofffrom both the override andcurrent_operation.Note on #25
If the migration to
climateentities in #25 lands, it supersedes this. This is a small fix for the entities that exist today and should be easy to drop later.