Skip to content

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

Description

@markoceri

Overview

Home Assistant entity fields in the configuration forms should display a fixed, non-editable domain prefix (e.g. sensor., switch.) as a chip, so the user only types the entity id and cannot enter an inconsistent/invalid prefix.

This already exists for Energy Monitor and Energy Load History Provider via the sensorPrefix flag on ConfigSchemaForm, but it has two limitations:

  1. It is hardcoded to sensor. — every entity field gets the same sensor. prefix.
  2. It is not enabled everywhere — Forecast Provider, Energy Load Forecast Provider and Miner Controller currently render the full entity id as free text.

Problem

The single sensor. prefix cannot represent forms that mix entity domains. The clearest example is the Generic Socket (Home Assistant) miner controller, whose config mixes:

  • entity_switchswitch.miner_socket (domain switch.)
  • entity_powersensor.miner_power (domain sensor.)

A global sensor. prefix would be wrong for entity_switch.

Proposed solution

  • Make the fixed prefix per-field instead of a single global sensor.: derive the entity domain for each field (e.g. from the field's default value such as switch.miner_socketswitch., or sensor.…sensor.), falling back to sensor. when no hint is available.
  • Render that per-field prefix as the fixed chip, with the user typing only the entity id (object id) after it.
  • Enable the prefix on the remaining Home Assistant forms: Forecast Provider, Energy Load Forecast Provider and Miner Controller, for a consistent experience across all HA-based configuration forms.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions