Skip to content

feat(frontend): selectable Home Assistant entity-domain prefix (#39)#40

Open
markoceri wants to merge 5 commits into
edge-mining:mainfrom
markoceri:fix/issue-39-ha-entity-prefix
Open

feat(frontend): selectable Home Assistant entity-domain prefix (#39)#40
markoceri wants to merge 5 commits into
edge-mining:mainfrom
markoceri:fix/issue-39-ha-entity-prefix

Conversation

@markoceri

@markoceri markoceri commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes #39.

Entity fields in Home Assistant configuration forms now expose the entity domain (sensor., switch., …) as a dropdown next to the input, so the user types only the entity object id and cannot enter an inconsistent/invalid prefix.

Previously the prefix was hardcoded to a single sensor. and only enabled on some forms, which could not represent forms that mix domains — most notably the generic socket miner controller, whose config uses switch.<socket> and sensor.<power> together.

The fixed entity-domain prefix support has been extended to all configuration forms: every Home Assistant form that exposes entity fields now gets the prefix UI, for a consistent experience across the whole app.

image

Changes

  • getEntityPrefix derives the domain per field with this priority: domain carried by the current value → schema default → a hint from the field name (e.g. entity_switchswitch.) → fallback sensor..
  • The derived domain is the dropdown's default and can be overridden by the user; the override is sticky even while the object id is empty.
  • Any out-of-list domain carried by an existing saved value is preserved in the options (no data loss).
  • The prefix UI is now enabled across all Home Assistant configuration forms that expose entity fields — Forecast Provider and Miner Controller in addition to the already-covered Energy Monitor and Energy Load History Provider.

Testing

  • vue-tsc type-check and vite build pass.
  • New miner generic socket: entity_switch defaults to switch., entity_power to sensor.. Existing values keep their domain.

Note: this branch builds on the configuration-form refactor in #38 and is intended to be merged after it; until then the diff also shows #38's commits.

…ls (edge-mining#17, edge-mining#18)

Schema-driven configuration forms previously presented every field as a flat
list, with unit-of-measure fields rendered as free-text inputs (error-prone:
"w", "KW", "kw") and entity/unit fields split far apart.

This reworks ConfigSchemaForm so that, generically for all forms:

- entity_<x> fields are paired with their unit_<x> counterpart on the same
  row, keeping the value next to its unit of measure (edge-mining#17);
- rows are grouped by domain (Power / Energy / Hash Rate) when at least two
  domains are present, preserving the schema declaration (chronological)
  order within each group (edge-mining#17);
- unit fields are rendered as a segmented control whose options are inferred
  from the field's value family (power/energy/hash rate), instead of a
  free-text input (edge-mining#18).

Field rendering is extracted into a reusable ConfigFieldControl component and
the schema/unit helpers into core/utils/configSchema.ts. Field names and
helper texts are intentionally left unchanged (a separate naming issue).
…e-mining#17, edge-mining#18)

MinerControllerConfigForm had its own duplicated copy of the schema-driven
form renderer, so the miner controller add/edit modal did not get the
entity/unit pairing or the unit segmented controls. Home Assistant-based
controllers (e.g. generic socket) therefore showed entities and their unit
of measure as separate, unpaired free-text fields.

Replace the duplicated implementation with a delegation to the shared
ConfigSchemaForm (config-endpoint "miner-controllers"). sensorPrefix is left
disabled because these controllers mix entity prefixes (switch., sensor.) and
expect full entity ids.
…dge-mining#17)

The Configuration section rendered each entity and its unit as two separate
fields side by side; long titles and descriptions wrapped onto multiple lines
and broke the vertical alignment between the entity input and its unit.

Render the unit-of-measure segmented control inline as the entity field's
addon, so each paired row keeps a single (entity) label and helper text, with
the unit selector attached to the right of the input. This removes the
redundant unit labels/descriptions and keeps rows aligned regardless of text
length.

ConfigFieldControl gains hideLabel / hideDescription props and an "addon"
slot. Configuration modals are widened to max-w-3xl for more breathing room.
…mining#39)

Entity fields in Home Assistant configuration forms now show the entity
domain (sensor., switch., ...) as a dropdown next to the input, so the user
types only the entity object id and cannot enter an inconsistent prefix.

The previous behaviour hardcoded a single "sensor." prefix and only enabled
it on some forms, which could not represent controllers that mix domains
(the generic socket miner controller uses switch.<socket> and sensor.<power>).

- getEntityPrefix derives the domain per field from its current value, then
  its schema default, then a hint from the field name (e.g. entity_switch ->
  switch.), falling back to sensor.;
- the derived domain is the dropdown's default and can be overridden by the
  user (sticky even while the object id is empty);
- any out-of-list domain carried by an existing value is preserved;
- the prefix is now enabled on Forecast Provider and Miner Controller forms
  in addition to Energy Monitor and Energy Load History Provider.
@markoceri markoceri self-assigned this Jun 28, 2026
@markoceri markoceri added enhancement New feature or request UI/UX labels Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request UI/UX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fixed per-field entity-domain prefix (sensor./switch.) for Home Assistant config forms

1 participant