Skip to content

Add live entity validation during adapter configuration #29

Description

@markoceri

When configuring adapters that rely on Home Assistant entities (e.g., Forecast Providers, Energy Monitors, Miner Controllers), users currently have no way to verify whether the entered entity IDs are correct until the system actually tries to use them. This leads to a poor configuration experience where errors are only discovered at runtime.

Image

Current Pain Points

  • No immediate feedback: After entering an entity ID, users must save the configuration, assign it to the entity, and wait for the system to attempt data retrieval before discovering if the entity is valid.

  • Silent misconfiguration: A typo in the entity ID (e.g., sensor.inverter_pwr instead of sensor.inverter_power) goes unnoticed until the adapter fails to retrieve data.

  • No way to cross-check: Users must manually switch between the Edge Mining UI and the Home Assistant dashboard to verify that the correct entity was selected and that it returns the expected values.

Proposed Changes

Add a "Test" / "Fetch Live Value" button next to each entity input field in the configuration form for:

  • Forecast Providers
  • Energy Monitors
  • Miner Controllers

When clicked, the button should:

  1. Call the Home Assistant API using the entered entity ID.
  2. Display the live value returned by Home Assistant directly in the configuration UI.
  3. Allow the user to compare the displayed value with what they see in Home Assistant to confirm correctness.

Feedback Scenarios

Scenario Feedback
Entity exists and returns data Show the current value (e.g., 245.3 W) with a success indicator
Entity exists but returns unexpected data Show the value so the user can evaluate if it's the right entity
Entity does not exist or is unreachable Show a clear error message (e.g., "Entity not found" or "Unable to connect to Home Assistant")

Auto-fetch unit of measurement from Home Assistant

When the selected adapter type requires Home Assistant (e.g., "Home Assistant Api"), the configuration form currently asks the user to manually specify the unit of measurement for sensor entities (e.g., "Entity Production", "Entity Consumption", "Entity Power"). This is error-prone and redundant, since Home Assistant already exposes the unit_of_measurement attribute for each sensor entity.

Proposed behavior:

  1. Once the user enters a valid entity ID in a sensor field (e.g., sensor.inverter_production), the system should automatically query Home Assistant for that entity's unit_of_measurement attribute.
  2. The retrieved unit should be auto-populated in the corresponding unit field (e.g., W, kW, kWh), removing the need for the user to enter it manually.
  3. The auto-filled unit should still be editable, in case the user wants to override it.
  4. If the entity does not have a unit_of_measurement attribute, leave the field empty and let the user fill it in manually.

This applies to all configuration forms where a Home Assistant entity is paired with a unit field, including Energy Monitors (see screenshot: "Entity Production", "Entity Consumption") and Miner Controllers ("Entity Power" / "Unit Power").

Visual Reference

  • The "Test" button should be placed inline next to each entity input field within the configuration section, providing a non-intrusive way to validate the configuration in real time.
  • The unit of measurement field should be auto-filled when a valid Home Assistant entity is entered, with a visual hint indicating it was fetched automatically (e.g., a small label or icon).

Acceptance Criteria

  • A "Test" / "Fetch Live Value" button is available next to each Home Assistant entity input field during adapter configuration.
  • Clicking the button fetches the current state of the entered entity from Home Assistant and displays it in the UI.
  • If the entity does not exist or the connection fails, a clear and descriptive error message is shown.
  • The feature works for all adapter types that use Home Assistant entities (Forecast Providers, Energy Monitors, Miner Controllers).
  • The live validation does not interfere with the save/submit flow of the configuration form.
  • When a valid Home Assistant entity ID is entered in a sensor field, the system automatically fetches and populates the unit_of_measurement from Home Assistant.
  • The auto-filled unit field remains editable for manual override.
  • If the entity has no unit_of_measurement attribute, the unit field is left empty for manual input.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions