Releases: johro897/electricity-cost-card
Release list
Updated Readme
2.1 - Improved support for other currencies
Configurable currency, unit, and price scale
Closes #6
Summary
Fixes the card being hardcoded to Swedish kronor (kr) and a fixed 0–5 price range. Reported by a user feeding the card a Nordpool sensor in EUR (Dutch all-in dynamic prices, ~0.10–0.50 €/kWh) — labels showed kr and the gauge/slider barely moved since they were scaled for a 0–5 range.
No breaking changes. Existing SEK dashboards render pixel-identical to v1.0.
Changes
✨ currency config key — with auto-detection
The card now reads the Nordpool sensor's attributes.currency (an ISO code like SEK or EUR) and maps it to a display symbol:
| ISO code | Displayed as |
|---|---|
| SEK, NOK, DKK | kr |
| EUR | € |
| GBP | £ |
| USD | $ |
Unknown codes are shown as-is. If neither the sensor nor the config provide a currency, it falls back to "kr" — identical to current behavior. Can be overridden explicitly via currency: "..." in YAML.
✨ unit config key
Same auto-detection pattern, reading attributes.unit, falling back to "kWh".
✨ price_max / price_min config keys — scalable gauge and slider
The gauge fill and simulation slider previously used a hardcoded (price / 5) * 100 and a 0.10–5.00 slider range. Both now scale against price_max / price_min.
price_max defaults to price_ok × 5/3 when not explicitly set. This was chosen over simply reusing price_ok directly (as suggested in the issue) because that would put the "Normal/High" threshold right at the top of the gauge, making the scale look perpetually red. The 5/3 factor reproduces the exact original default (price_ok=3.0 → price_max=5.0) while scaling proportionally for any other market — e.g. price_ok: 0.40 (EUR) auto-derives price_max ≈ 0.67.
✨ Editor: new "Advanced" section
Added optional fields for currency, unit, price_max, price_min in the visual editor. Left blank, they're omitted from generated YAML so auto-detection keeps working.
🔧 Internal
All hardcoded "kr" literals (activity cost strings, gauge labels, price-unit suffix, graph trend line) now resolve through _currencySuffix() / _unitSuffix().
Testing
- Verified with the reporter's EUR/Nordpool sensor via a beta build (auto-detected
€, scaled gauge/slider matched their ~0.10–0.50 range) - Confirmed existing SEK dashboard renders identically to v2.0
- Confirmed visual editor Advanced fields round-trip correctly into YAML
- Confirmed
price_max/price_minmanual override works alongside auto-detected currency
Files changed
electricity-cost-card.js— currency/unit auto-detection, scalable gauge/slider, editor Advanced sectionREADME.md— new config options, EUR example, currency/unit auto-detection table, changelog
Beta Release to validate fix for Issue#6
v2.1-beta.1 — Configurable currency, unit, and price scale
Closes #6
Summary
Fixes the card being hardcoded to Swedish kronor (kr) and a fixed 0–5 price range. Reported by a user feeding the card a Nordpool sensor in EUR (Dutch all-in dynamic prices, ~0.10–0.50 €/kWh) — labels showed kr and the gauge/slider barely moved since they were scaled for a 0–5 range.
No breaking changes. Existing SEK dashboards render pixel-identical to v1.0.
Changes
✨ currency config key — with auto-detection
The card now reads the Nordpool sensor's attributes.currency (an ISO code like SEK or EUR) and maps it to a display symbol:
| ISO code | Displayed as |
|---|---|
| SEK, NOK, DKK | kr |
| EUR | € |
| GBP | £ |
| USD | $ |
Unknown codes are shown as-is. If neither the sensor nor the config provide a currency, it falls back to "kr" — identical to current behavior. Can be overridden explicitly via currency: "..." in YAML.
✨ unit config key
Same auto-detection pattern, reading attributes.unit, falling back to "kWh".
✨ price_max / price_min config keys — scalable gauge and slider
The gauge fill and simulation slider previously used a hardcoded (price / 5) * 100 and a 0.10–5.00 slider range. Both now scale against price_max / price_min.
price_max defaults to price_ok × 5/3 when not explicitly set. This was chosen over simply reusing price_ok directly (as suggested in the issue) because that would put the "Normal/High" threshold right at the top of the gauge, making the scale look perpetually red. The 5/3 factor reproduces the exact original default (price_ok=3.0 → price_max=5.0) while scaling proportionally for any other market — e.g. price_ok: 0.40 (EUR) auto-derives price_max ≈ 0.67.
✨ Editor: new "Advanced" section
Added optional fields for currency, unit, price_max, price_min in the visual editor. Left blank, they're omitted from generated YAML so auto-detection keeps working.
🔧 Internal
All hardcoded "kr" literals (activity cost strings, gauge labels, price-unit suffix, graph trend line) now resolve through _currencySuffix() / _unitSuffix().
Testing
- Verified with the reporter's EUR/Nordpool sensor via a beta build (auto-detected
€, scaled gauge/slider matched their ~0.10–0.50 range) - Confirmed existing SEK dashboard renders identically to v1.0
- Confirmed visual editor Advanced fields round-trip correctly into YAML
- Confirmed
price_max/price_minmanual override works alongside auto-detected currency
Files changed
electricity-cost-card.js— currency/unit auto-detection, scalable gauge/slider, editor Advanced sectionREADME.md— new config options, EUR example, currency/unit auto-detection table, changelog
Released prepared for Official HACS
2.0 Update hacs.json
New release based on user feedback
Fixed items found by users but also added values to the Y-axis showing the actual price
Fixing issues found
fix editor focus + add title config
Typing in the editor kept losing focus — turned out every keystroke
was dispatching a config-changed event which made HA rebuild the whole
editor DOM. Split the activity listeners into input (updates config
silently while you type) and change (dispatches when you leave the
field).
Also added a title config option since "Electricity cost" hardcoded
isn't great when you have multiple dashboards or just want it in
your own language.
Fixed Simulator
Beta Test Help link
Changed help link, wrong approach