Skip to content

Forecast Provider (Home Assistant Api): optional entity fields cause runtime errors when partially filled #31

@markoceri

Description

@markoceri

When adding a Forecast Provider of type "Home Assistant Api", the configuration form marks entity fields as optional. However, if only some of these fields are filled in while others are left empty, the adapter fails to initialize at runtime with an error that is only visible in the core service logs — not in the UI.

Image

Current Behavior

  1. User creates a Forecast Provider with adapter type "Home Assistant Api".
  2. Some entity fields are filled in, while other "optional" fields are left empty.
  3. The form submits successfully without any validation error.
  4. At runtime, the adapter fails to initialize with the following error in the core log:
edge-mining-1  | 2026-04-02 12:00:28 | ERROR    | Failed to initialize adapter 'Forecast Solar ARAN HA' (Type: ForecastProviderAdapter.HOME_ASSISTANT_API) using factory: Entity ID for actual solar power forecast is required.
  1. The user has no feedback in the UI that the Forecast Provider is misconfigured.

Current Pain Points

  • Misleading "optional" labels: The fields are presented as optional in the form, but in practice they are conditionally required — leaving some empty causes a runtime failure.

  • No validation at submission time: The form does not validate field dependencies before saving, allowing an invalid configuration to be persisted.

  • Error only visible in logs: The user must inspect the core service logs to discover the misconfiguration. There is no feedback in the UI (e.g., a status indicator or alert on the Forecast Provider entity).

Proposed Changes

  1. Clarify field optionality: Review and update the entity fields for the Home Assistant Api forecast provider. Fields that are actually required for the adapter to function should be marked as required, not optional. If certain fields are truly optional (i.e., the adapter can work without them), this should be clearly documented in the helper text.

  2. Add form-level validation: Implement validation logic that checks field dependencies before saving. If a combination of filled/empty fields would result in an invalid configuration, show a clear validation error in the form at submission time.

  3. Surface runtime adapter errors in the UI: When an adapter fails to initialize, the error status should be visible on the entity's detail page or in a status indicator (e.g., a badge or warning icon), so the user does not need to check logs manually.

Acceptance Criteria

  • Entity fields that are required for the Home Assistant Api adapter to function are correctly marked as required in the configuration form.
  • If a field is truly optional, the helper text explains what happens when it is left empty (e.g., "If not set, forecast data for this metric will not be available").
  • The form validates field dependencies at submission time and prevents saving an invalid configuration.
  • A clear validation error message is displayed in the UI if the user submits a partially filled configuration that would fail at runtime.
  • Adapter initialization errors are surfaced in the UI (e.g., a status badge or warning on the Forecast Provider entity) rather than only being logged.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions