Skip to content

fix: Nord Pool HACS continental areas misfire as Norway (NOK) + Currency field always read-only #171

Description

@johanzander

Background

PR #164 (merged) fixed _AREA_HINTS for continental Nord Pool areas when using the official HA integration, where the device identifier is already the short area code (e.g. NL).

Two gaps remain.


Gap 1 — HACS integration: continental areas silently map to Norway

File: core/bess/ha_api_controller.py:2354_parse_nordpool_area_from_entity_id

The regex only matches original Nord Pool members:

```python
r"(?:^|)(se[1-4]|no[1-5]|dk[12]|fi|ee|lt|lv)(?:|$)"
```

For HACS, the device identifier is the full entity_id string, e.g. nordpool_kwh_nl_eur_2_10_025. The regex returns None for any continental area, and the fallback or raw.upper() produces "NORDPOOL_KWH_NL_EUR_2_10_025". Then _hints_from_nordpool_area takes area[:2].upper()"NO" → matches Norway in _AREA_HINTS → wrong currency NOK.

Every HACS continental area identifier starts with nordpool_kwh_, so they all alias to Norway.

Fix: extend the regex to recognise continental area codes, e.g.:

```python
r"(?:^|)(se[1-4]|no[1-5]|dk[12]|fi|ee|lt|lv|nl|be|de(?:-lu)?|fr|at|pl)(?:|$)"
```

Add end-to-end tests using a nordpool_kwh_nl_eur_2_10_025-style identifier.


Gap 2 — Currency field is always read-only, even when auto-detect failed

File: frontend/src/components/settings/PricingFormSection.tsx:58,69

Both Nord Pool variants render Currency with readOnly: true unconditionally. When auto-detect returns nothing (unknown area, network error, etc.) the user sees the wrong currency and has no way to correct it.

Fix: remove the unconditional readOnly: true; lock the field only when a valid hint was actually returned (i.e. form.currency was set by discovery, not left as the bootstrap default).


Scope

These are independent — either can be fixed in isolation. The HACS regex fix is backend-only; the Currency read-only fix is frontend-only.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bot-analyzedTriage bot has processed this issueenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions