Skip to content

Releases: johro897/electricity-cost-card

Updated Readme

Choose a tag to compare

@johro897 johro897 released this 27 Jun 12:58
a253fb8

Updated installations instructions in Readme to support that the integration now is officially in HACS

2.1 - Improved support for other currencies

Choose a tag to compare

@johro897 johro897 released this 24 Jun 06:24
f9bb793

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.105.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_min manual override works alongside auto-detected currency

Files changed

  • electricity-cost-card.js — currency/unit auto-detection, scalable gauge/slider, editor Advanced section
  • README.md — new config options, EUR example, currency/unit auto-detection table, changelog

Beta Release to validate fix for Issue#6

Choose a tag to compare

@johro897 johro897 released this 23 Jun 08:25
4ad2af5

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.105.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_min manual override works alongside auto-detected currency

Files changed

  • electricity-cost-card.js — currency/unit auto-detection, scalable gauge/slider, editor Advanced section
  • README.md — new config options, EUR example, currency/unit auto-detection table, changelog

Released prepared for Official HACS

Choose a tag to compare

@johro897 johro897 released this 12 Apr 13:00
3c6d93b
2.0

Update hacs.json

New release based on user feedback

Choose a tag to compare

@johro897 johro897 released this 06 Apr 15:02
541d161

Fixed items found by users but also added values to the Y-axis showing the actual price

Fixing issues found

Fixing issues found Pre-release
Pre-release

Choose a tag to compare

@johro897 johro897 released this 30 Mar 07:36
174eea1

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

Choose a tag to compare

@johro897 johro897 released this 22 Mar 19:23
4465a19

Fixed the simulator

Beta Test Help link

Beta Test Help link Pre-release
Pre-release

Choose a tag to compare

@johro897 johro897 released this 17 Mar 07:22
100a318

Changed help link, wrong approach

First Release

Choose a tag to compare

@johro897 johro897 released this 16 Mar 19:56
a48fc9f

First real version.