Skip to content

feat: Nordpool/Tibber-compatible Greenely price sensor (v2.4.0) - #3

Open
tintinz wants to merge 6 commits into
masterfrom
feat/nordpool-price-sensor
Open

feat: Nordpool/Tibber-compatible Greenely price sensor (v2.4.0)#3
tintinz wants to merge 6 commits into
masterfrom
feat/nordpool-price-sensor

Conversation

@tintinz

@tintinz tintinz commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a Nordpool/Tibber-compatible Greenely price sensor so an energy platform can use Greenely's real (VAT-inclusive) spot prices instead of Nordpool, without changing any logic.

New sensor: sensor.greenely_nordpool_price (Greenely Nord Pool Price, MONETARY, SEK/kWh).

Attribute format (matches Nordpool custom component + Tibber price sensor)

  • today / tomorrow96 × 15-minute [start_ts, price] points
  • raw_today / raw_tomorrow — same series
  • current_price, min, max, mean, average
  • off_peak_1 / peak / off_peak_2 (Nordpool fixed blocks 00-06 / 06-22 / 22-24)
  • low_price, price_percent_to_average, tomorrow_valid
  • Tibber-style price_level (LOW/NORMAL/HIGH) and intraday_price_ranking

Implementation

  • New pure-Python module custom_components/greenely/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.
  • New unit test tests/test_nordpool_format.py.
  • Version bumped to v2.4.0.

Verification

  • Live-tested against the real Greenely API (facility 619713): 96 points today and tomorrow, tomorrow_valid: True, current price ~1.15 SEK/kWh. Unit tests pass (python3 tests/test_nordpool_format.py → 3 passed).

Design note

Kept as a separate feature commit on its own branch (off feat/fix-and-modernize) so this is a single, gransknningsbar feature — separate from the earlier async-modernization work.

root and others added 5 commits August 4, 2026 08:20
…g fixes

- Rewrite GreenelyApi as a fully async httpx.AsyncClient client
  (fixes 'Blocking call to load_verify_locations in event loop')
- Add Greenely Current Price sensor (MONETARY, SEK/kWh) for the
  Energy dashboard and automations
- Fix config flow crash on unresolvable facility (fixes '500 Internal
  Server Error', adds CannotConnect handling)
- Move price conversion to a single testable helper (prices.py) with
  consistent raw->SEK/kWh mapping
- Make all sensors async, fix services JSON output bug
- Bump to v2.2.0, add unit tests and API verification tool
homeassistant.const in HA 2026.7 does not export CURRENCY_EURO_CENT,
which caused ImportError -> setup_error when the sensor platform loaded.
Also drop reliance on CURRENCY_SWEDISH_KRONA for safety.

Use the explicit constant UNIT_SEK_PER_KWH ("SEK/kWh") instead.
Bump to v2.2.1.
Keep only tools/verify_greenely.py which is documented in the README.
Temp websocket/REST debug scripts used during troubleshooting are not
meant to ship in the integration.
Greenely now provides quarter-of-hour spot prices in the hourly spot-price
payload (quarters_prices: {quarter1..quarter4}). Adds a new MONETARY sensor
`sensor.greenely_current_quarter_price` exposing the current 15-minute price
in SEK/kWh, falling back to the hourly mean when a quarter is missing.
Verified against live data (e.g. 0.398 SEK/kWh for the current quarter vs
0.4048 hourly mean). Bump to v2.3.0.
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