Skip to content

Support input_number.* entities for hardware setpoint writes (not just number.*) #372

Description

@johanzander

Problem

core/bess/ha_api_controller.py hardcodes the HA service domain "number" (number.set_value) at multiple call sites when writing setpoints to Home Assistant. If a user repoints one of these auto-discovered entities to an input_number.* helper (e.g. to tap into the value from a custom automation), the write fails because number.set_value is called against an input_number.* entity_id — that service is scoped to the number platform only.

Reported in #349: a user wants to route the VPP power setpoint through an input_number.vpp_power helper so a HA automation can read what BESS is about to write before it hits the inverter, but BESS Manager only supports number.*.

Affected call sites

All in core/bess/ha_api_controller.py, hardcoding "number" as the service domain:

  • charge/discharge stop SOC and power rate (~lines 1141, 1156, 1171, 1186)
  • SolaX active power / autorepeat duration (~lines 1631, 1638)
  • SolaX battery min SOC (~line 1679)
  • Growatt VPP power / VPP fallback time (~lines 1778, 1787)

Proposed fix

Add a single helper (e.g. _set_number_like(entity_id, value, ...)) that inspects the entity_id's domain and dispatches to number.set_value vs input_number.set_value accordingly, and use it at all 9 call sites — following the existing precedent in set_grid_charge (ha_api_controller.py:1201-1232), which already branches on entity_id.startswith("select.") vs the switch domain for an analogous problem.

Entity ID format validation (backend/api_dataclasses.py _ENTITY_ID_RE) already accepts any domain.object_id, so no config-layer change is needed — this is purely a write-path fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions