Follow-ups from the #18 review. None of these are bugs — #18 is merged and shipped as
v1.4.0-beta.1. These are
complexity cleanups in custom_components/bosch/pointtapi_entities.py, listed roughly by payoff.
Two were already applied before the merge in bd6ee64 (the unreachable /programs/list branch
and a dead _attr_options = []), so they are not repeated here.
1. Number descriptions: two patterns for one problem
_pointtapi_number_descriptions re-indented the whole static NumberEntityDescription tuple
into a function body so two conditional entries (/energy/gas/annualGoal,
/energy/electricity/annualGoal) could be appended. ~120 lines of churn for two appends, and
any future edit to that tuple now conflicts against a reindent.
_pointtapi_select_descriptions solves the identical problem six lines long:
def _pointtapi_select_descriptions(data=None):
data = data or {}
return POINTTAPI_SELECT_DESCRIPTIONS + _pointtapi_zone_program_select_descriptions(data)
Same shape works for numbers: keep POINTTAPI_NUMBER_DESCRIPTIONS static, return it plus the
optional goals. The select version is the better one — worth making both look like it.
2. Two on/off parsers in one file
_appliance_error_flag is _resolve_on_off (further down the same file) plus int/float and
the "1"/"0"/"yes"/"no" spellings. Fold those two cases into _resolve_on_off and drop
_appliance_error_flag.
3. _appliance_status_available reads as a wrapped or chain
return any(
_val(data, f"/system/appliance/{k}") is not None
for k in ("displayCode", "causeCode", "blockingError", "lockingError")
)
4. _appliance_status_state and _appliance_status_attributes recompute the same six lookups
Both call _appliance_display_code, _appliance_cause_code and both error-flag/code helpers with
identical arguments, on every coordinator update. One _appliance_codes(data) helper, called by both.
Deliberately not on this list: the options_fn / current_option_fn / option_to_value_fn
hooks look like abstraction for a single implementation, but sensor descriptions in this file
already carry value_fn / available_fn / attributes_fn / device_info_fn — it is the house
pattern, and a dedicated subclass would not be shorter. The ~100-entry status table is data, not
code. The duplicate-label guard in _zone_program_option_map prevents a program being silently
dropped from the select; it stays.
@jfhautenauven no rush on any of this, and no obligation — happy to take it myself if you would
rather stay on features.
Follow-ups from the #18 review. None of these are bugs — #18 is merged and shipped as
v1.4.0-beta.1. These are
complexity cleanups in
custom_components/bosch/pointtapi_entities.py, listed roughly by payoff.Two were already applied before the merge in bd6ee64 (the unreachable
/programs/listbranchand a dead
_attr_options = []), so they are not repeated here.1. Number descriptions: two patterns for one problem
_pointtapi_number_descriptionsre-indented the whole staticNumberEntityDescriptiontupleinto a function body so two conditional entries (
/energy/gas/annualGoal,/energy/electricity/annualGoal) could be appended. ~120 lines of churn for two appends, andany future edit to that tuple now conflicts against a reindent.
_pointtapi_select_descriptionssolves the identical problem six lines long:Same shape works for numbers: keep
POINTTAPI_NUMBER_DESCRIPTIONSstatic, return it plus theoptional goals. The select version is the better one — worth making both look like it.
2. Two on/off parsers in one file
_appliance_error_flagis_resolve_on_off(further down the same file) plusint/floatandthe
"1"/"0"/"yes"/"no"spellings. Fold those two cases into_resolve_on_offand drop_appliance_error_flag.3.
_appliance_status_availablereads as a wrappedorchain4.
_appliance_status_stateand_appliance_status_attributesrecompute the same six lookupsBoth call
_appliance_display_code,_appliance_cause_codeand both error-flag/code helpers withidentical arguments, on every coordinator update. One
_appliance_codes(data)helper, called by both.Deliberately not on this list: the
options_fn/current_option_fn/option_to_value_fnhooks look like abstraction for a single implementation, but sensor descriptions in this file
already carry
value_fn/available_fn/attributes_fn/device_info_fn— it is the housepattern, and a dedicated subclass would not be shorter. The ~100-entry status table is data, not
code. The duplicate-label guard in
_zone_program_option_mapprevents a program being silentlydropped from the select; it stays.
@jfhautenauven no rush on any of this, and no obligation — happy to take it myself if you would
rather stay on features.