feat(frontend): selectable Home Assistant entity-domain prefix (#39)#40
Open
markoceri wants to merge 5 commits into
Open
feat(frontend): selectable Home Assistant entity-domain prefix (#39)#40markoceri wants to merge 5 commits into
markoceri wants to merge 5 commits into
Conversation
…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.
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.
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 usesswitch.<socket>andsensor.<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.
Changes
getEntityPrefixderives the domain per field with this priority: domain carried by the current value → schema default → a hint from the field name (e.g.entity_switch→switch.) → fallbacksensor..Testing
vue-tsctype-check andvite buildpass.entity_switchdefaults toswitch.,entity_powertosensor.. Existing values keep their domain.