Skip to content

feat: Greenely Nord Pool Price sensor — SEM-compatible (Solar Energy Management) - #5

Open
tintinz wants to merge 2 commits into
feat/fix-and-modernizefrom
feat/nordpool-price-sensor
Open

feat: Greenely Nord Pool Price sensor — SEM-compatible (Solar Energy Management)#5
tintinz wants to merge 2 commits into
feat/fix-and-modernizefrom
feat/nordpool-price-sensor

Conversation

@tintinz

@tintinz tintinz commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Greenely Nord Pool Price sensor — SEM-kompatibel (Solar Energy Management)

En ny Greenely Nord Pool Price-sensor som låter dig driva SEM (Solar Energy Management)
direkt på Greenelys riktiga spotpriser — ingen Nordpool-/Tibber-integration behövs.

🎯 Varför den här PR:en (SEM-fix)

Patriks HA kör SEM (traktore-org/sem-community) för batteri-toppning/EV-laddning på spotpris.
SEM får priskurvan från sensorns today/tomorrow-attribut, men accepterar bara dict-element
({"start": <ISO>, "value": <pris>}) — alla andra format ignoreras tyst.

Den här PR:en:

  1. Lägger till GreenelyNordpoolPriceSensor som bygger 96-punkts (15-min) dag-/imorgonkruvor från
    Greenelys spot-price + quarters_prices.
  2. Exponentera kurvan i SEM-kompatibelt dict-format (start+value) för today/tomorrow/
    raw_today/raw_tomorrow — så SEM direkt kan konsumera den som dynamisk tariff/priskälla.
  3. native_value = aktuellt pris SEK/kWh (läses av SEM som nutidspris från state).

✅ Verifierat

  • Konceptbevis: SEM:s exakta _read_prices_list-parse-logik replikerad mot vår output →
    96/96 punkter hämtade, sorterade, ISO-giltiga.
  • Enhetstest: test_sem_parses_curve_from_attributes + test_full_day_series (96 punkter,
    dict-shape). 7 passed.
  • Live: spotpris från Greenely bekräftat (kvartpriser quarters_prices {q1..q4} per timme).

🔗 Länkar

  • SEM (Solar Energy Management): https://github.com/traktore-org/sem-community
  • Pekar du SEM:s Dynamic / price sensorsensor.greenely_nordpool_price så tar SEM in hela
    dygnskurvan för planering + aktuellt pris direkt från Greenely.

📦 Vad sensorn exponerar

today/tomorrow (96×15-min, dict {"start","value"}), raw_today/raw_tomorrow, current_price,
min/max/mean/average, off_peak_1/peak/off_peak_2, low_price,
price_percent_to_average, tomorrow_valid, Tibber-price_level, intraday_price_ranking.
MONETARY, SEK/kWh.

Baseras på feat/fix-and-modernize (async-omskrivningen). 2 commits. Bump → 2.4.1.

tintinz added 2 commits August 4, 2026 19:47
Adds a new MONETARY sensor (Greenely Nord Pool Price) that exposes Greenely's
real spot prices — including 15-minute quarter prices — in the same attribute
format as the popular Nordpool custom component and the Tibber price sensor.
An energy platform can point its EV charging / arbitrage logic from `nordpool`
or `tibber` to this sensor without changing any logic.

Exposed attributes:
- today / tomorrow and raw_today / raw_tomorrow as 96 x 15-minute [ts, price] points
- current_price, min, max, mean, average
- off_peak_1 / peak / off_peak_2 (Nordpool fixed blocks)
- low_price, price_percent_to_average, tomorrow_valid
- Tibber-style price_level (LOW/NORMAL/HIGH) and intraday_price_ranking

Implementation:
- New pure-Python module nordpool_format.py (no HA import) that expands each
  hourly entry's quarters_prices {q1..q4} into 15-minute points, with fallback
  to the hourly mean when a quarter is missing. Unit-testable standalone.
- Verified against live Greenely data (current 1.15 SEK/kWh, 96 pts today and
  tomorrow, tomorrow_valid true) and an on-file unit test.

Bump to v2.4.0.
SEMP Meter (Solar Energy Management) parses the day-ahead curve from
today/tomorrow/raw_today/raw_tomorrow attributes and only accepts list
items that are DICTS with a "start" ISO timestamp and a "value" price
key (tariff_provider._read_prices_list). The previous tuple-pair format
([ts, price]) was silently dropped by SEM, leaving its battery/EV
planning with an empty curve and a fallback constant price.

Change build_price_series to emit each 15-min point as
{"start": "<ISO>", "value": <SEK/kWh>} for today/tomorrow and
raw_today/raw_tomorrow, keeping all other fields (current_price,
min/max/mean/average, off_peak_1/peak/off_peak_2, low_price,
price_percent_to_average, tomorrow_valid, price_level,
intraday_price_ranking) unchanged.

Now both the current-price read (state) and the full day-ahead curve
(attributes) feed SEM directly from the Greenely sensor.

Verified with a concept-proof replaying SEM's exact dict-parse logic
against the emitted attributes: 96/96 today + 96/96 raw_today points
parsed, sorted, timestamps ISO-valid.

Bump manifest to 2.4.1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant