Add service in Nord Pool for fetching normalized price indices (#147979)

This commit is contained in:
G Johansson 2025-07-05 21:39:48 +02:00 committed by GitHub
parent 160e4e4d05
commit e304022560
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 1726 additions and 9 deletions

View File

@ -12,3 +12,4 @@ PLATFORMS = [Platform.SENSOR]
DEFAULT_NAME = "Nord Pool" DEFAULT_NAME = "Nord Pool"
CONF_AREAS = "areas" CONF_AREAS = "areas"
ATTR_RESOLUTION = "resolution"

View File

@ -42,6 +42,9 @@
"services": { "services": {
"get_prices_for_date": { "get_prices_for_date": {
"service": "mdi:cash-multiple" "service": "mdi:cash-multiple"
},
"get_price_indices_for_date": {
"service": "mdi:cash-multiple"
} }
} }
} }

View File

@ -2,16 +2,21 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import Callable
from datetime import date, datetime from datetime import date, datetime
from functools import partial
import logging import logging
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from pynordpool import ( from pynordpool import (
AREAS, AREAS,
Currency, Currency,
DeliveryPeriodData,
NordPoolAuthenticationError, NordPoolAuthenticationError,
NordPoolClient,
NordPoolEmptyResponseError, NordPoolEmptyResponseError,
NordPoolError, NordPoolError,
PriceIndicesData,
) )
import voluptuous as vol import voluptuous as vol
@ -32,7 +37,7 @@ from homeassistant.util.json import JsonValueType
if TYPE_CHECKING: if TYPE_CHECKING:
from . import NordPoolConfigEntry from . import NordPoolConfigEntry
from .const import DOMAIN from .const import ATTR_RESOLUTION, DOMAIN
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
ATTR_CONFIG_ENTRY = "config_entry" ATTR_CONFIG_ENTRY = "config_entry"
@ -40,6 +45,7 @@ ATTR_AREAS = "areas"
ATTR_CURRENCY = "currency" ATTR_CURRENCY = "currency"
SERVICE_GET_PRICES_FOR_DATE = "get_prices_for_date" SERVICE_GET_PRICES_FOR_DATE = "get_prices_for_date"
SERVICE_GET_PRICE_INDICES_FOR_DATE = "get_price_indices_for_date"
SERVICE_GET_PRICES_SCHEMA = vol.Schema( SERVICE_GET_PRICES_SCHEMA = vol.Schema(
{ {
vol.Required(ATTR_CONFIG_ENTRY): ConfigEntrySelector({"integration": DOMAIN}), vol.Required(ATTR_CONFIG_ENTRY): ConfigEntrySelector({"integration": DOMAIN}),
@ -50,6 +56,13 @@ SERVICE_GET_PRICES_SCHEMA = vol.Schema(
), ),
} }
) )
SERVICE_GET_PRICE_INDICES_SCHEMA = SERVICE_GET_PRICES_SCHEMA.extend(
{
vol.Optional(ATTR_RESOLUTION, default=60): vol.All(
cv.positive_int, vol.All(vol.Coerce(int), vol.In((15, 30, 60)))
),
}
)
def get_config_entry(hass: HomeAssistant, entry_id: str) -> NordPoolConfigEntry: def get_config_entry(hass: HomeAssistant, entry_id: str) -> NordPoolConfigEntry:
@ -71,11 +84,13 @@ def get_config_entry(hass: HomeAssistant, entry_id: str) -> NordPoolConfigEntry:
def async_setup_services(hass: HomeAssistant) -> None: def async_setup_services(hass: HomeAssistant) -> None:
"""Set up services for Nord Pool integration.""" """Set up services for Nord Pool integration."""
async def get_prices_for_date(call: ServiceCall) -> ServiceResponse: def get_service_params(
"""Get price service.""" call: ServiceCall,
) -> tuple[NordPoolClient, date, str, list[str], int]:
"""Return the parameters for the service."""
entry = get_config_entry(hass, call.data[ATTR_CONFIG_ENTRY]) entry = get_config_entry(hass, call.data[ATTR_CONFIG_ENTRY])
asked_date: date = call.data[ATTR_DATE]
client = entry.runtime_data.client client = entry.runtime_data.client
asked_date: date = call.data[ATTR_DATE]
areas: list[str] = entry.data[ATTR_AREAS] areas: list[str] = entry.data[ATTR_AREAS]
if _areas := call.data.get(ATTR_AREAS): if _areas := call.data.get(ATTR_AREAS):
@ -85,15 +100,56 @@ def async_setup_services(hass: HomeAssistant) -> None:
if _currency := call.data.get(ATTR_CURRENCY): if _currency := call.data.get(ATTR_CURRENCY):
currency = _currency currency = _currency
resolution: int = 60
if _resolution := call.data.get(ATTR_RESOLUTION):
resolution = _resolution
areas = [area.upper() for area in areas] areas = [area.upper() for area in areas]
currency = currency.upper() currency = currency.upper()
try: return (client, asked_date, currency, areas, resolution)
price_data = await client.async_get_delivery_period(
async def get_prices_for_date(
client: NordPoolClient,
asked_date: date,
currency: str,
areas: list[str],
resolution: int,
) -> DeliveryPeriodData:
"""Get prices."""
return await client.async_get_delivery_period(
datetime.combine(asked_date, dt_util.utcnow().time()), datetime.combine(asked_date, dt_util.utcnow().time()),
Currency(currency), Currency(currency),
areas, areas,
) )
async def get_price_indices_for_date(
client: NordPoolClient,
asked_date: date,
currency: str,
areas: list[str],
resolution: int,
) -> PriceIndicesData:
"""Get prices."""
return await client.async_get_price_indices(
datetime.combine(asked_date, dt_util.utcnow().time()),
Currency(currency),
areas,
resolution=resolution,
)
async def get_prices(func: Callable, call: ServiceCall) -> ServiceResponse:
"""Get price service."""
client, asked_date, currency, areas, resolution = get_service_params(call)
try:
price_data = await func(
client,
asked_date,
currency,
areas,
resolution,
)
except NordPoolAuthenticationError as error: except NordPoolAuthenticationError as error:
raise ServiceValidationError( raise ServiceValidationError(
translation_domain=DOMAIN, translation_domain=DOMAIN,
@ -122,7 +178,14 @@ def async_setup_services(hass: HomeAssistant) -> None:
hass.services.async_register( hass.services.async_register(
DOMAIN, DOMAIN,
SERVICE_GET_PRICES_FOR_DATE, SERVICE_GET_PRICES_FOR_DATE,
get_prices_for_date, partial(get_prices, get_prices_for_date),
schema=SERVICE_GET_PRICES_SCHEMA, schema=SERVICE_GET_PRICES_SCHEMA,
supports_response=SupportsResponse.ONLY, supports_response=SupportsResponse.ONLY,
) )
hass.services.async_register(
DOMAIN,
SERVICE_GET_PRICE_INDICES_FOR_DATE,
partial(get_prices, get_price_indices_for_date),
schema=SERVICE_GET_PRICE_INDICES_SCHEMA,
supports_response=SupportsResponse.ONLY,
)

View File

@ -46,3 +46,59 @@ get_prices_for_date:
- "PLN" - "PLN"
- "SEK" - "SEK"
mode: dropdown mode: dropdown
get_price_indices_for_date:
fields:
config_entry:
required: true
selector:
config_entry:
integration: nordpool
date:
required: true
selector:
date:
areas:
selector:
select:
options:
- "EE"
- "LT"
- "LV"
- "AT"
- "BE"
- "FR"
- "GER"
- "NL"
- "PL"
- "DK1"
- "DK2"
- "FI"
- "NO1"
- "NO2"
- "NO3"
- "NO4"
- "NO5"
- "SE1"
- "SE2"
- "SE3"
- "SE4"
- "SYS"
mode: dropdown
currency:
selector:
select:
options:
- "DKK"
- "EUR"
- "NOK"
- "PLN"
- "SEK"
mode: dropdown
resolution:
selector:
select:
options:
- "15"
- "30"
- "60"
mode: dropdown

View File

@ -114,6 +114,32 @@
"description": "Currency to get prices in. If left empty it will use the currency already configured." "description": "Currency to get prices in. If left empty it will use the currency already configured."
} }
} }
},
"get_price_indices_for_date": {
"name": "Get price indices for date",
"description": "Retrieves the price indices for a specific date.",
"fields": {
"config_entry": {
"name": "Config entry",
"description": "The Nord Pool configuration entry for this action."
},
"date": {
"name": "Date",
"description": "Only dates two months in the past and one day in the future is allowed."
},
"areas": {
"name": "Areas",
"description": "One or multiple areas to get prices for. If left empty it will use the areas already configured."
},
"currency": {
"name": "Currency",
"description": "Currency to get prices in. If left empty it will use the currency already configured."
},
"resolution": {
"name": "Resolution",
"description": "Resolution time for the prices, can be any of 15, 30 and 60 minutes."
}
}
} }
}, },
"exceptions": { "exceptions": {

View File

@ -0,0 +1,689 @@
{
"deliveryDateCET": "2025-07-06",
"version": 2,
"updatedAt": "2025-07-05T10:56:42.3755929Z",
"market": "DayAhead",
"indexNames": ["SE3"],
"currency": "SEK",
"resolutionInMinutes": 15,
"areaStates": [
{
"state": "Preliminary",
"areas": ["SE3"]
}
],
"multiIndexEntries": [
{
"deliveryStart": "2025-07-05T22:00:00Z",
"deliveryEnd": "2025-07-05T22:15:00Z",
"entryPerArea": {
"SE3": 43.57
}
},
{
"deliveryStart": "2025-07-05T22:15:00Z",
"deliveryEnd": "2025-07-05T22:30:00Z",
"entryPerArea": {
"SE3": 43.57
}
},
{
"deliveryStart": "2025-07-05T22:30:00Z",
"deliveryEnd": "2025-07-05T22:45:00Z",
"entryPerArea": {
"SE3": 43.57
}
},
{
"deliveryStart": "2025-07-05T22:45:00Z",
"deliveryEnd": "2025-07-05T23:00:00Z",
"entryPerArea": {
"SE3": 43.57
}
},
{
"deliveryStart": "2025-07-05T23:00:00Z",
"deliveryEnd": "2025-07-05T23:15:00Z",
"entryPerArea": {
"SE3": 36.47
}
},
{
"deliveryStart": "2025-07-05T23:15:00Z",
"deliveryEnd": "2025-07-05T23:30:00Z",
"entryPerArea": {
"SE3": 36.47
}
},
{
"deliveryStart": "2025-07-05T23:30:00Z",
"deliveryEnd": "2025-07-05T23:45:00Z",
"entryPerArea": {
"SE3": 36.47
}
},
{
"deliveryStart": "2025-07-05T23:45:00Z",
"deliveryEnd": "2025-07-06T00:00:00Z",
"entryPerArea": {
"SE3": 36.47
}
},
{
"deliveryStart": "2025-07-06T00:00:00Z",
"deliveryEnd": "2025-07-06T00:15:00Z",
"entryPerArea": {
"SE3": 35.57
}
},
{
"deliveryStart": "2025-07-06T00:15:00Z",
"deliveryEnd": "2025-07-06T00:30:00Z",
"entryPerArea": {
"SE3": 35.57
}
},
{
"deliveryStart": "2025-07-06T00:30:00Z",
"deliveryEnd": "2025-07-06T00:45:00Z",
"entryPerArea": {
"SE3": 35.57
}
},
{
"deliveryStart": "2025-07-06T00:45:00Z",
"deliveryEnd": "2025-07-06T01:00:00Z",
"entryPerArea": {
"SE3": 35.57
}
},
{
"deliveryStart": "2025-07-06T01:00:00Z",
"deliveryEnd": "2025-07-06T01:15:00Z",
"entryPerArea": {
"SE3": 30.73
}
},
{
"deliveryStart": "2025-07-06T01:15:00Z",
"deliveryEnd": "2025-07-06T01:30:00Z",
"entryPerArea": {
"SE3": 30.73
}
},
{
"deliveryStart": "2025-07-06T01:30:00Z",
"deliveryEnd": "2025-07-06T01:45:00Z",
"entryPerArea": {
"SE3": 30.73
}
},
{
"deliveryStart": "2025-07-06T01:45:00Z",
"deliveryEnd": "2025-07-06T02:00:00Z",
"entryPerArea": {
"SE3": 30.73
}
},
{
"deliveryStart": "2025-07-06T02:00:00Z",
"deliveryEnd": "2025-07-06T02:15:00Z",
"entryPerArea": {
"SE3": 32.42
}
},
{
"deliveryStart": "2025-07-06T02:15:00Z",
"deliveryEnd": "2025-07-06T02:30:00Z",
"entryPerArea": {
"SE3": 32.42
}
},
{
"deliveryStart": "2025-07-06T02:30:00Z",
"deliveryEnd": "2025-07-06T02:45:00Z",
"entryPerArea": {
"SE3": 32.42
}
},
{
"deliveryStart": "2025-07-06T02:45:00Z",
"deliveryEnd": "2025-07-06T03:00:00Z",
"entryPerArea": {
"SE3": 32.42
}
},
{
"deliveryStart": "2025-07-06T03:00:00Z",
"deliveryEnd": "2025-07-06T03:15:00Z",
"entryPerArea": {
"SE3": 38.73
}
},
{
"deliveryStart": "2025-07-06T03:15:00Z",
"deliveryEnd": "2025-07-06T03:30:00Z",
"entryPerArea": {
"SE3": 38.73
}
},
{
"deliveryStart": "2025-07-06T03:30:00Z",
"deliveryEnd": "2025-07-06T03:45:00Z",
"entryPerArea": {
"SE3": 38.73
}
},
{
"deliveryStart": "2025-07-06T03:45:00Z",
"deliveryEnd": "2025-07-06T04:00:00Z",
"entryPerArea": {
"SE3": 38.73
}
},
{
"deliveryStart": "2025-07-06T04:00:00Z",
"deliveryEnd": "2025-07-06T04:15:00Z",
"entryPerArea": {
"SE3": 42.78
}
},
{
"deliveryStart": "2025-07-06T04:15:00Z",
"deliveryEnd": "2025-07-06T04:30:00Z",
"entryPerArea": {
"SE3": 42.78
}
},
{
"deliveryStart": "2025-07-06T04:30:00Z",
"deliveryEnd": "2025-07-06T04:45:00Z",
"entryPerArea": {
"SE3": 42.78
}
},
{
"deliveryStart": "2025-07-06T04:45:00Z",
"deliveryEnd": "2025-07-06T05:00:00Z",
"entryPerArea": {
"SE3": 42.78
}
},
{
"deliveryStart": "2025-07-06T05:00:00Z",
"deliveryEnd": "2025-07-06T05:15:00Z",
"entryPerArea": {
"SE3": 54.71
}
},
{
"deliveryStart": "2025-07-06T05:15:00Z",
"deliveryEnd": "2025-07-06T05:30:00Z",
"entryPerArea": {
"SE3": 54.71
}
},
{
"deliveryStart": "2025-07-06T05:30:00Z",
"deliveryEnd": "2025-07-06T05:45:00Z",
"entryPerArea": {
"SE3": 54.71
}
},
{
"deliveryStart": "2025-07-06T05:45:00Z",
"deliveryEnd": "2025-07-06T06:00:00Z",
"entryPerArea": {
"SE3": 54.71
}
},
{
"deliveryStart": "2025-07-06T06:00:00Z",
"deliveryEnd": "2025-07-06T06:15:00Z",
"entryPerArea": {
"SE3": 83.87
}
},
{
"deliveryStart": "2025-07-06T06:15:00Z",
"deliveryEnd": "2025-07-06T06:30:00Z",
"entryPerArea": {
"SE3": 83.87
}
},
{
"deliveryStart": "2025-07-06T06:30:00Z",
"deliveryEnd": "2025-07-06T06:45:00Z",
"entryPerArea": {
"SE3": 83.87
}
},
{
"deliveryStart": "2025-07-06T06:45:00Z",
"deliveryEnd": "2025-07-06T07:00:00Z",
"entryPerArea": {
"SE3": 83.87
}
},
{
"deliveryStart": "2025-07-06T07:00:00Z",
"deliveryEnd": "2025-07-06T07:15:00Z",
"entryPerArea": {
"SE3": 78.8
}
},
{
"deliveryStart": "2025-07-06T07:15:00Z",
"deliveryEnd": "2025-07-06T07:30:00Z",
"entryPerArea": {
"SE3": 78.8
}
},
{
"deliveryStart": "2025-07-06T07:30:00Z",
"deliveryEnd": "2025-07-06T07:45:00Z",
"entryPerArea": {
"SE3": 78.8
}
},
{
"deliveryStart": "2025-07-06T07:45:00Z",
"deliveryEnd": "2025-07-06T08:00:00Z",
"entryPerArea": {
"SE3": 78.8
}
},
{
"deliveryStart": "2025-07-06T08:00:00Z",
"deliveryEnd": "2025-07-06T08:15:00Z",
"entryPerArea": {
"SE3": 92.09
}
},
{
"deliveryStart": "2025-07-06T08:15:00Z",
"deliveryEnd": "2025-07-06T08:30:00Z",
"entryPerArea": {
"SE3": 92.09
}
},
{
"deliveryStart": "2025-07-06T08:30:00Z",
"deliveryEnd": "2025-07-06T08:45:00Z",
"entryPerArea": {
"SE3": 92.09
}
},
{
"deliveryStart": "2025-07-06T08:45:00Z",
"deliveryEnd": "2025-07-06T09:00:00Z",
"entryPerArea": {
"SE3": 92.09
}
},
{
"deliveryStart": "2025-07-06T09:00:00Z",
"deliveryEnd": "2025-07-06T09:15:00Z",
"entryPerArea": {
"SE3": 104.92
}
},
{
"deliveryStart": "2025-07-06T09:15:00Z",
"deliveryEnd": "2025-07-06T09:30:00Z",
"entryPerArea": {
"SE3": 104.92
}
},
{
"deliveryStart": "2025-07-06T09:30:00Z",
"deliveryEnd": "2025-07-06T09:45:00Z",
"entryPerArea": {
"SE3": 104.92
}
},
{
"deliveryStart": "2025-07-06T09:45:00Z",
"deliveryEnd": "2025-07-06T10:00:00Z",
"entryPerArea": {
"SE3": 104.92
}
},
{
"deliveryStart": "2025-07-06T10:00:00Z",
"deliveryEnd": "2025-07-06T10:15:00Z",
"entryPerArea": {
"SE3": 72.5
}
},
{
"deliveryStart": "2025-07-06T10:15:00Z",
"deliveryEnd": "2025-07-06T10:30:00Z",
"entryPerArea": {
"SE3": 72.5
}
},
{
"deliveryStart": "2025-07-06T10:30:00Z",
"deliveryEnd": "2025-07-06T10:45:00Z",
"entryPerArea": {
"SE3": 72.5
}
},
{
"deliveryStart": "2025-07-06T10:45:00Z",
"deliveryEnd": "2025-07-06T11:00:00Z",
"entryPerArea": {
"SE3": 72.5
}
},
{
"deliveryStart": "2025-07-06T11:00:00Z",
"deliveryEnd": "2025-07-06T11:15:00Z",
"entryPerArea": {
"SE3": 63.49
}
},
{
"deliveryStart": "2025-07-06T11:15:00Z",
"deliveryEnd": "2025-07-06T11:30:00Z",
"entryPerArea": {
"SE3": 63.49
}
},
{
"deliveryStart": "2025-07-06T11:30:00Z",
"deliveryEnd": "2025-07-06T11:45:00Z",
"entryPerArea": {
"SE3": 63.49
}
},
{
"deliveryStart": "2025-07-06T11:45:00Z",
"deliveryEnd": "2025-07-06T12:00:00Z",
"entryPerArea": {
"SE3": 63.49
}
},
{
"deliveryStart": "2025-07-06T12:00:00Z",
"deliveryEnd": "2025-07-06T12:15:00Z",
"entryPerArea": {
"SE3": 91.64
}
},
{
"deliveryStart": "2025-07-06T12:15:00Z",
"deliveryEnd": "2025-07-06T12:30:00Z",
"entryPerArea": {
"SE3": 91.64
}
},
{
"deliveryStart": "2025-07-06T12:30:00Z",
"deliveryEnd": "2025-07-06T12:45:00Z",
"entryPerArea": {
"SE3": 91.64
}
},
{
"deliveryStart": "2025-07-06T12:45:00Z",
"deliveryEnd": "2025-07-06T13:00:00Z",
"entryPerArea": {
"SE3": 91.64
}
},
{
"deliveryStart": "2025-07-06T13:00:00Z",
"deliveryEnd": "2025-07-06T13:15:00Z",
"entryPerArea": {
"SE3": 111.79
}
},
{
"deliveryStart": "2025-07-06T13:15:00Z",
"deliveryEnd": "2025-07-06T13:30:00Z",
"entryPerArea": {
"SE3": 111.79
}
},
{
"deliveryStart": "2025-07-06T13:30:00Z",
"deliveryEnd": "2025-07-06T13:45:00Z",
"entryPerArea": {
"SE3": 111.79
}
},
{
"deliveryStart": "2025-07-06T13:45:00Z",
"deliveryEnd": "2025-07-06T14:00:00Z",
"entryPerArea": {
"SE3": 111.79
}
},
{
"deliveryStart": "2025-07-06T14:00:00Z",
"deliveryEnd": "2025-07-06T14:15:00Z",
"entryPerArea": {
"SE3": 234.04
}
},
{
"deliveryStart": "2025-07-06T14:15:00Z",
"deliveryEnd": "2025-07-06T14:30:00Z",
"entryPerArea": {
"SE3": 234.04
}
},
{
"deliveryStart": "2025-07-06T14:30:00Z",
"deliveryEnd": "2025-07-06T14:45:00Z",
"entryPerArea": {
"SE3": 234.04
}
},
{
"deliveryStart": "2025-07-06T14:45:00Z",
"deliveryEnd": "2025-07-06T15:00:00Z",
"entryPerArea": {
"SE3": 234.04
}
},
{
"deliveryStart": "2025-07-06T15:00:00Z",
"deliveryEnd": "2025-07-06T15:15:00Z",
"entryPerArea": {
"SE3": 435.33
}
},
{
"deliveryStart": "2025-07-06T15:15:00Z",
"deliveryEnd": "2025-07-06T15:30:00Z",
"entryPerArea": {
"SE3": 435.33
}
},
{
"deliveryStart": "2025-07-06T15:30:00Z",
"deliveryEnd": "2025-07-06T15:45:00Z",
"entryPerArea": {
"SE3": 435.33
}
},
{
"deliveryStart": "2025-07-06T15:45:00Z",
"deliveryEnd": "2025-07-06T16:00:00Z",
"entryPerArea": {
"SE3": 435.33
}
},
{
"deliveryStart": "2025-07-06T16:00:00Z",
"deliveryEnd": "2025-07-06T16:15:00Z",
"entryPerArea": {
"SE3": 431.84
}
},
{
"deliveryStart": "2025-07-06T16:15:00Z",
"deliveryEnd": "2025-07-06T16:30:00Z",
"entryPerArea": {
"SE3": 431.84
}
},
{
"deliveryStart": "2025-07-06T16:30:00Z",
"deliveryEnd": "2025-07-06T16:45:00Z",
"entryPerArea": {
"SE3": 431.84
}
},
{
"deliveryStart": "2025-07-06T16:45:00Z",
"deliveryEnd": "2025-07-06T17:00:00Z",
"entryPerArea": {
"SE3": 431.84
}
},
{
"deliveryStart": "2025-07-06T17:00:00Z",
"deliveryEnd": "2025-07-06T17:15:00Z",
"entryPerArea": {
"SE3": 423.73
}
},
{
"deliveryStart": "2025-07-06T17:15:00Z",
"deliveryEnd": "2025-07-06T17:30:00Z",
"entryPerArea": {
"SE3": 423.73
}
},
{
"deliveryStart": "2025-07-06T17:30:00Z",
"deliveryEnd": "2025-07-06T17:45:00Z",
"entryPerArea": {
"SE3": 423.73
}
},
{
"deliveryStart": "2025-07-06T17:45:00Z",
"deliveryEnd": "2025-07-06T18:00:00Z",
"entryPerArea": {
"SE3": 423.73
}
},
{
"deliveryStart": "2025-07-06T18:00:00Z",
"deliveryEnd": "2025-07-06T18:15:00Z",
"entryPerArea": {
"SE3": 437.92
}
},
{
"deliveryStart": "2025-07-06T18:15:00Z",
"deliveryEnd": "2025-07-06T18:30:00Z",
"entryPerArea": {
"SE3": 437.92
}
},
{
"deliveryStart": "2025-07-06T18:30:00Z",
"deliveryEnd": "2025-07-06T18:45:00Z",
"entryPerArea": {
"SE3": 437.92
}
},
{
"deliveryStart": "2025-07-06T18:45:00Z",
"deliveryEnd": "2025-07-06T19:00:00Z",
"entryPerArea": {
"SE3": 437.92
}
},
{
"deliveryStart": "2025-07-06T19:00:00Z",
"deliveryEnd": "2025-07-06T19:15:00Z",
"entryPerArea": {
"SE3": 416.42
}
},
{
"deliveryStart": "2025-07-06T19:15:00Z",
"deliveryEnd": "2025-07-06T19:30:00Z",
"entryPerArea": {
"SE3": 416.42
}
},
{
"deliveryStart": "2025-07-06T19:30:00Z",
"deliveryEnd": "2025-07-06T19:45:00Z",
"entryPerArea": {
"SE3": 416.42
}
},
{
"deliveryStart": "2025-07-06T19:45:00Z",
"deliveryEnd": "2025-07-06T20:00:00Z",
"entryPerArea": {
"SE3": 416.42
}
},
{
"deliveryStart": "2025-07-06T20:00:00Z",
"deliveryEnd": "2025-07-06T20:15:00Z",
"entryPerArea": {
"SE3": 414.39
}
},
{
"deliveryStart": "2025-07-06T20:15:00Z",
"deliveryEnd": "2025-07-06T20:30:00Z",
"entryPerArea": {
"SE3": 414.39
}
},
{
"deliveryStart": "2025-07-06T20:30:00Z",
"deliveryEnd": "2025-07-06T20:45:00Z",
"entryPerArea": {
"SE3": 414.39
}
},
{
"deliveryStart": "2025-07-06T20:45:00Z",
"deliveryEnd": "2025-07-06T21:00:00Z",
"entryPerArea": {
"SE3": 414.39
}
},
{
"deliveryStart": "2025-07-06T21:00:00Z",
"deliveryEnd": "2025-07-06T21:15:00Z",
"entryPerArea": {
"SE3": 396.38
}
},
{
"deliveryStart": "2025-07-06T21:15:00Z",
"deliveryEnd": "2025-07-06T21:30:00Z",
"entryPerArea": {
"SE3": 396.38
}
},
{
"deliveryStart": "2025-07-06T21:30:00Z",
"deliveryEnd": "2025-07-06T21:45:00Z",
"entryPerArea": {
"SE3": 396.38
}
},
{
"deliveryStart": "2025-07-06T21:45:00Z",
"deliveryEnd": "2025-07-06T22:00:00Z",
"entryPerArea": {
"SE3": 396.38
}
}
]
}

View File

@ -0,0 +1,185 @@
{
"deliveryDateCET": "2025-07-06",
"version": 2,
"updatedAt": "2025-07-05T10:56:44.6936838Z",
"market": "DayAhead",
"indexNames": ["SE3"],
"currency": "SEK",
"resolutionInMinutes": 60,
"areaStates": [
{
"state": "Preliminary",
"areas": ["SE3"]
}
],
"multiIndexEntries": [
{
"deliveryStart": "2025-07-05T22:00:00Z",
"deliveryEnd": "2025-07-05T23:00:00Z",
"entryPerArea": {
"SE3": 43.57
}
},
{
"deliveryStart": "2025-07-05T23:00:00Z",
"deliveryEnd": "2025-07-06T00:00:00Z",
"entryPerArea": {
"SE3": 36.47
}
},
{
"deliveryStart": "2025-07-06T00:00:00Z",
"deliveryEnd": "2025-07-06T01:00:00Z",
"entryPerArea": {
"SE3": 35.57
}
},
{
"deliveryStart": "2025-07-06T01:00:00Z",
"deliveryEnd": "2025-07-06T02:00:00Z",
"entryPerArea": {
"SE3": 30.73
}
},
{
"deliveryStart": "2025-07-06T02:00:00Z",
"deliveryEnd": "2025-07-06T03:00:00Z",
"entryPerArea": {
"SE3": 32.42
}
},
{
"deliveryStart": "2025-07-06T03:00:00Z",
"deliveryEnd": "2025-07-06T04:00:00Z",
"entryPerArea": {
"SE3": 38.73
}
},
{
"deliveryStart": "2025-07-06T04:00:00Z",
"deliveryEnd": "2025-07-06T05:00:00Z",
"entryPerArea": {
"SE3": 42.78
}
},
{
"deliveryStart": "2025-07-06T05:00:00Z",
"deliveryEnd": "2025-07-06T06:00:00Z",
"entryPerArea": {
"SE3": 54.71
}
},
{
"deliveryStart": "2025-07-06T06:00:00Z",
"deliveryEnd": "2025-07-06T07:00:00Z",
"entryPerArea": {
"SE3": 83.87
}
},
{
"deliveryStart": "2025-07-06T07:00:00Z",
"deliveryEnd": "2025-07-06T08:00:00Z",
"entryPerArea": {
"SE3": 78.8
}
},
{
"deliveryStart": "2025-07-06T08:00:00Z",
"deliveryEnd": "2025-07-06T09:00:00Z",
"entryPerArea": {
"SE3": 92.09
}
},
{
"deliveryStart": "2025-07-06T09:00:00Z",
"deliveryEnd": "2025-07-06T10:00:00Z",
"entryPerArea": {
"SE3": 104.92
}
},
{
"deliveryStart": "2025-07-06T10:00:00Z",
"deliveryEnd": "2025-07-06T11:00:00Z",
"entryPerArea": {
"SE3": 72.5
}
},
{
"deliveryStart": "2025-07-06T11:00:00Z",
"deliveryEnd": "2025-07-06T12:00:00Z",
"entryPerArea": {
"SE3": 63.49
}
},
{
"deliveryStart": "2025-07-06T12:00:00Z",
"deliveryEnd": "2025-07-06T13:00:00Z",
"entryPerArea": {
"SE3": 91.64
}
},
{
"deliveryStart": "2025-07-06T13:00:00Z",
"deliveryEnd": "2025-07-06T14:00:00Z",
"entryPerArea": {
"SE3": 111.79
}
},
{
"deliveryStart": "2025-07-06T14:00:00Z",
"deliveryEnd": "2025-07-06T15:00:00Z",
"entryPerArea": {
"SE3": 234.04
}
},
{
"deliveryStart": "2025-07-06T15:00:00Z",
"deliveryEnd": "2025-07-06T16:00:00Z",
"entryPerArea": {
"SE3": 435.33
}
},
{
"deliveryStart": "2025-07-06T16:00:00Z",
"deliveryEnd": "2025-07-06T17:00:00Z",
"entryPerArea": {
"SE3": 431.84
}
},
{
"deliveryStart": "2025-07-06T17:00:00Z",
"deliveryEnd": "2025-07-06T18:00:00Z",
"entryPerArea": {
"SE3": 423.73
}
},
{
"deliveryStart": "2025-07-06T18:00:00Z",
"deliveryEnd": "2025-07-06T19:00:00Z",
"entryPerArea": {
"SE3": 437.92
}
},
{
"deliveryStart": "2025-07-06T19:00:00Z",
"deliveryEnd": "2025-07-06T20:00:00Z",
"entryPerArea": {
"SE3": 416.42
}
},
{
"deliveryStart": "2025-07-06T20:00:00Z",
"deliveryEnd": "2025-07-06T21:00:00Z",
"entryPerArea": {
"SE3": 414.39
}
},
{
"deliveryStart": "2025-07-06T21:00:00Z",
"deliveryEnd": "2025-07-06T22:00:00Z",
"entryPerArea": {
"SE3": 396.38
}
}
]
}

View File

@ -131,3 +131,615 @@
]), ]),
}) })
# --- # ---
# name: test_service_call_for_price_indices[get_price_indices_for_date_15]
dict({
'SE3': list([
dict({
'end': '2025-07-05T22:15:00+00:00',
'price': 43.57,
'start': '2025-07-05T22:00:00+00:00',
}),
dict({
'end': '2025-07-05T22:30:00+00:00',
'price': 43.57,
'start': '2025-07-05T22:15:00+00:00',
}),
dict({
'end': '2025-07-05T22:45:00+00:00',
'price': 43.57,
'start': '2025-07-05T22:30:00+00:00',
}),
dict({
'end': '2025-07-05T23:00:00+00:00',
'price': 43.57,
'start': '2025-07-05T22:45:00+00:00',
}),
dict({
'end': '2025-07-05T23:15:00+00:00',
'price': 36.47,
'start': '2025-07-05T23:00:00+00:00',
}),
dict({
'end': '2025-07-05T23:30:00+00:00',
'price': 36.47,
'start': '2025-07-05T23:15:00+00:00',
}),
dict({
'end': '2025-07-05T23:45:00+00:00',
'price': 36.47,
'start': '2025-07-05T23:30:00+00:00',
}),
dict({
'end': '2025-07-06T00:00:00+00:00',
'price': 36.47,
'start': '2025-07-05T23:45:00+00:00',
}),
dict({
'end': '2025-07-06T00:15:00+00:00',
'price': 35.57,
'start': '2025-07-06T00:00:00+00:00',
}),
dict({
'end': '2025-07-06T00:30:00+00:00',
'price': 35.57,
'start': '2025-07-06T00:15:00+00:00',
}),
dict({
'end': '2025-07-06T00:45:00+00:00',
'price': 35.57,
'start': '2025-07-06T00:30:00+00:00',
}),
dict({
'end': '2025-07-06T01:00:00+00:00',
'price': 35.57,
'start': '2025-07-06T00:45:00+00:00',
}),
dict({
'end': '2025-07-06T01:15:00+00:00',
'price': 30.73,
'start': '2025-07-06T01:00:00+00:00',
}),
dict({
'end': '2025-07-06T01:30:00+00:00',
'price': 30.73,
'start': '2025-07-06T01:15:00+00:00',
}),
dict({
'end': '2025-07-06T01:45:00+00:00',
'price': 30.73,
'start': '2025-07-06T01:30:00+00:00',
}),
dict({
'end': '2025-07-06T02:00:00+00:00',
'price': 30.73,
'start': '2025-07-06T01:45:00+00:00',
}),
dict({
'end': '2025-07-06T02:15:00+00:00',
'price': 32.42,
'start': '2025-07-06T02:00:00+00:00',
}),
dict({
'end': '2025-07-06T02:30:00+00:00',
'price': 32.42,
'start': '2025-07-06T02:15:00+00:00',
}),
dict({
'end': '2025-07-06T02:45:00+00:00',
'price': 32.42,
'start': '2025-07-06T02:30:00+00:00',
}),
dict({
'end': '2025-07-06T03:00:00+00:00',
'price': 32.42,
'start': '2025-07-06T02:45:00+00:00',
}),
dict({
'end': '2025-07-06T03:15:00+00:00',
'price': 38.73,
'start': '2025-07-06T03:00:00+00:00',
}),
dict({
'end': '2025-07-06T03:30:00+00:00',
'price': 38.73,
'start': '2025-07-06T03:15:00+00:00',
}),
dict({
'end': '2025-07-06T03:45:00+00:00',
'price': 38.73,
'start': '2025-07-06T03:30:00+00:00',
}),
dict({
'end': '2025-07-06T04:00:00+00:00',
'price': 38.73,
'start': '2025-07-06T03:45:00+00:00',
}),
dict({
'end': '2025-07-06T04:15:00+00:00',
'price': 42.78,
'start': '2025-07-06T04:00:00+00:00',
}),
dict({
'end': '2025-07-06T04:30:00+00:00',
'price': 42.78,
'start': '2025-07-06T04:15:00+00:00',
}),
dict({
'end': '2025-07-06T04:45:00+00:00',
'price': 42.78,
'start': '2025-07-06T04:30:00+00:00',
}),
dict({
'end': '2025-07-06T05:00:00+00:00',
'price': 42.78,
'start': '2025-07-06T04:45:00+00:00',
}),
dict({
'end': '2025-07-06T05:15:00+00:00',
'price': 54.71,
'start': '2025-07-06T05:00:00+00:00',
}),
dict({
'end': '2025-07-06T05:30:00+00:00',
'price': 54.71,
'start': '2025-07-06T05:15:00+00:00',
}),
dict({
'end': '2025-07-06T05:45:00+00:00',
'price': 54.71,
'start': '2025-07-06T05:30:00+00:00',
}),
dict({
'end': '2025-07-06T06:00:00+00:00',
'price': 54.71,
'start': '2025-07-06T05:45:00+00:00',
}),
dict({
'end': '2025-07-06T06:15:00+00:00',
'price': 83.87,
'start': '2025-07-06T06:00:00+00:00',
}),
dict({
'end': '2025-07-06T06:30:00+00:00',
'price': 83.87,
'start': '2025-07-06T06:15:00+00:00',
}),
dict({
'end': '2025-07-06T06:45:00+00:00',
'price': 83.87,
'start': '2025-07-06T06:30:00+00:00',
}),
dict({
'end': '2025-07-06T07:00:00+00:00',
'price': 83.87,
'start': '2025-07-06T06:45:00+00:00',
}),
dict({
'end': '2025-07-06T07:15:00+00:00',
'price': 78.8,
'start': '2025-07-06T07:00:00+00:00',
}),
dict({
'end': '2025-07-06T07:30:00+00:00',
'price': 78.8,
'start': '2025-07-06T07:15:00+00:00',
}),
dict({
'end': '2025-07-06T07:45:00+00:00',
'price': 78.8,
'start': '2025-07-06T07:30:00+00:00',
}),
dict({
'end': '2025-07-06T08:00:00+00:00',
'price': 78.8,
'start': '2025-07-06T07:45:00+00:00',
}),
dict({
'end': '2025-07-06T08:15:00+00:00',
'price': 92.09,
'start': '2025-07-06T08:00:00+00:00',
}),
dict({
'end': '2025-07-06T08:30:00+00:00',
'price': 92.09,
'start': '2025-07-06T08:15:00+00:00',
}),
dict({
'end': '2025-07-06T08:45:00+00:00',
'price': 92.09,
'start': '2025-07-06T08:30:00+00:00',
}),
dict({
'end': '2025-07-06T09:00:00+00:00',
'price': 92.09,
'start': '2025-07-06T08:45:00+00:00',
}),
dict({
'end': '2025-07-06T09:15:00+00:00',
'price': 104.92,
'start': '2025-07-06T09:00:00+00:00',
}),
dict({
'end': '2025-07-06T09:30:00+00:00',
'price': 104.92,
'start': '2025-07-06T09:15:00+00:00',
}),
dict({
'end': '2025-07-06T09:45:00+00:00',
'price': 104.92,
'start': '2025-07-06T09:30:00+00:00',
}),
dict({
'end': '2025-07-06T10:00:00+00:00',
'price': 104.92,
'start': '2025-07-06T09:45:00+00:00',
}),
dict({
'end': '2025-07-06T10:15:00+00:00',
'price': 72.5,
'start': '2025-07-06T10:00:00+00:00',
}),
dict({
'end': '2025-07-06T10:30:00+00:00',
'price': 72.5,
'start': '2025-07-06T10:15:00+00:00',
}),
dict({
'end': '2025-07-06T10:45:00+00:00',
'price': 72.5,
'start': '2025-07-06T10:30:00+00:00',
}),
dict({
'end': '2025-07-06T11:00:00+00:00',
'price': 72.5,
'start': '2025-07-06T10:45:00+00:00',
}),
dict({
'end': '2025-07-06T11:15:00+00:00',
'price': 63.49,
'start': '2025-07-06T11:00:00+00:00',
}),
dict({
'end': '2025-07-06T11:30:00+00:00',
'price': 63.49,
'start': '2025-07-06T11:15:00+00:00',
}),
dict({
'end': '2025-07-06T11:45:00+00:00',
'price': 63.49,
'start': '2025-07-06T11:30:00+00:00',
}),
dict({
'end': '2025-07-06T12:00:00+00:00',
'price': 63.49,
'start': '2025-07-06T11:45:00+00:00',
}),
dict({
'end': '2025-07-06T12:15:00+00:00',
'price': 91.64,
'start': '2025-07-06T12:00:00+00:00',
}),
dict({
'end': '2025-07-06T12:30:00+00:00',
'price': 91.64,
'start': '2025-07-06T12:15:00+00:00',
}),
dict({
'end': '2025-07-06T12:45:00+00:00',
'price': 91.64,
'start': '2025-07-06T12:30:00+00:00',
}),
dict({
'end': '2025-07-06T13:00:00+00:00',
'price': 91.64,
'start': '2025-07-06T12:45:00+00:00',
}),
dict({
'end': '2025-07-06T13:15:00+00:00',
'price': 111.79,
'start': '2025-07-06T13:00:00+00:00',
}),
dict({
'end': '2025-07-06T13:30:00+00:00',
'price': 111.79,
'start': '2025-07-06T13:15:00+00:00',
}),
dict({
'end': '2025-07-06T13:45:00+00:00',
'price': 111.79,
'start': '2025-07-06T13:30:00+00:00',
}),
dict({
'end': '2025-07-06T14:00:00+00:00',
'price': 111.79,
'start': '2025-07-06T13:45:00+00:00',
}),
dict({
'end': '2025-07-06T14:15:00+00:00',
'price': 234.04,
'start': '2025-07-06T14:00:00+00:00',
}),
dict({
'end': '2025-07-06T14:30:00+00:00',
'price': 234.04,
'start': '2025-07-06T14:15:00+00:00',
}),
dict({
'end': '2025-07-06T14:45:00+00:00',
'price': 234.04,
'start': '2025-07-06T14:30:00+00:00',
}),
dict({
'end': '2025-07-06T15:00:00+00:00',
'price': 234.04,
'start': '2025-07-06T14:45:00+00:00',
}),
dict({
'end': '2025-07-06T15:15:00+00:00',
'price': 435.33,
'start': '2025-07-06T15:00:00+00:00',
}),
dict({
'end': '2025-07-06T15:30:00+00:00',
'price': 435.33,
'start': '2025-07-06T15:15:00+00:00',
}),
dict({
'end': '2025-07-06T15:45:00+00:00',
'price': 435.33,
'start': '2025-07-06T15:30:00+00:00',
}),
dict({
'end': '2025-07-06T16:00:00+00:00',
'price': 435.33,
'start': '2025-07-06T15:45:00+00:00',
}),
dict({
'end': '2025-07-06T16:15:00+00:00',
'price': 431.84,
'start': '2025-07-06T16:00:00+00:00',
}),
dict({
'end': '2025-07-06T16:30:00+00:00',
'price': 431.84,
'start': '2025-07-06T16:15:00+00:00',
}),
dict({
'end': '2025-07-06T16:45:00+00:00',
'price': 431.84,
'start': '2025-07-06T16:30:00+00:00',
}),
dict({
'end': '2025-07-06T17:00:00+00:00',
'price': 431.84,
'start': '2025-07-06T16:45:00+00:00',
}),
dict({
'end': '2025-07-06T17:15:00+00:00',
'price': 423.73,
'start': '2025-07-06T17:00:00+00:00',
}),
dict({
'end': '2025-07-06T17:30:00+00:00',
'price': 423.73,
'start': '2025-07-06T17:15:00+00:00',
}),
dict({
'end': '2025-07-06T17:45:00+00:00',
'price': 423.73,
'start': '2025-07-06T17:30:00+00:00',
}),
dict({
'end': '2025-07-06T18:00:00+00:00',
'price': 423.73,
'start': '2025-07-06T17:45:00+00:00',
}),
dict({
'end': '2025-07-06T18:15:00+00:00',
'price': 437.92,
'start': '2025-07-06T18:00:00+00:00',
}),
dict({
'end': '2025-07-06T18:30:00+00:00',
'price': 437.92,
'start': '2025-07-06T18:15:00+00:00',
}),
dict({
'end': '2025-07-06T18:45:00+00:00',
'price': 437.92,
'start': '2025-07-06T18:30:00+00:00',
}),
dict({
'end': '2025-07-06T19:00:00+00:00',
'price': 437.92,
'start': '2025-07-06T18:45:00+00:00',
}),
dict({
'end': '2025-07-06T19:15:00+00:00',
'price': 416.42,
'start': '2025-07-06T19:00:00+00:00',
}),
dict({
'end': '2025-07-06T19:30:00+00:00',
'price': 416.42,
'start': '2025-07-06T19:15:00+00:00',
}),
dict({
'end': '2025-07-06T19:45:00+00:00',
'price': 416.42,
'start': '2025-07-06T19:30:00+00:00',
}),
dict({
'end': '2025-07-06T20:00:00+00:00',
'price': 416.42,
'start': '2025-07-06T19:45:00+00:00',
}),
dict({
'end': '2025-07-06T20:15:00+00:00',
'price': 414.39,
'start': '2025-07-06T20:00:00+00:00',
}),
dict({
'end': '2025-07-06T20:30:00+00:00',
'price': 414.39,
'start': '2025-07-06T20:15:00+00:00',
}),
dict({
'end': '2025-07-06T20:45:00+00:00',
'price': 414.39,
'start': '2025-07-06T20:30:00+00:00',
}),
dict({
'end': '2025-07-06T21:00:00+00:00',
'price': 414.39,
'start': '2025-07-06T20:45:00+00:00',
}),
dict({
'end': '2025-07-06T21:15:00+00:00',
'price': 396.38,
'start': '2025-07-06T21:00:00+00:00',
}),
dict({
'end': '2025-07-06T21:30:00+00:00',
'price': 396.38,
'start': '2025-07-06T21:15:00+00:00',
}),
dict({
'end': '2025-07-06T21:45:00+00:00',
'price': 396.38,
'start': '2025-07-06T21:30:00+00:00',
}),
dict({
'end': '2025-07-06T22:00:00+00:00',
'price': 396.38,
'start': '2025-07-06T21:45:00+00:00',
}),
]),
})
# ---
# name: test_service_call_for_price_indices[get_price_indices_for_date_60]
dict({
'SE3': list([
dict({
'end': '2025-07-05T23:00:00+00:00',
'price': 43.57,
'start': '2025-07-05T22:00:00+00:00',
}),
dict({
'end': '2025-07-06T00:00:00+00:00',
'price': 36.47,
'start': '2025-07-05T23:00:00+00:00',
}),
dict({
'end': '2025-07-06T01:00:00+00:00',
'price': 35.57,
'start': '2025-07-06T00:00:00+00:00',
}),
dict({
'end': '2025-07-06T02:00:00+00:00',
'price': 30.73,
'start': '2025-07-06T01:00:00+00:00',
}),
dict({
'end': '2025-07-06T03:00:00+00:00',
'price': 32.42,
'start': '2025-07-06T02:00:00+00:00',
}),
dict({
'end': '2025-07-06T04:00:00+00:00',
'price': 38.73,
'start': '2025-07-06T03:00:00+00:00',
}),
dict({
'end': '2025-07-06T05:00:00+00:00',
'price': 42.78,
'start': '2025-07-06T04:00:00+00:00',
}),
dict({
'end': '2025-07-06T06:00:00+00:00',
'price': 54.71,
'start': '2025-07-06T05:00:00+00:00',
}),
dict({
'end': '2025-07-06T07:00:00+00:00',
'price': 83.87,
'start': '2025-07-06T06:00:00+00:00',
}),
dict({
'end': '2025-07-06T08:00:00+00:00',
'price': 78.8,
'start': '2025-07-06T07:00:00+00:00',
}),
dict({
'end': '2025-07-06T09:00:00+00:00',
'price': 92.09,
'start': '2025-07-06T08:00:00+00:00',
}),
dict({
'end': '2025-07-06T10:00:00+00:00',
'price': 104.92,
'start': '2025-07-06T09:00:00+00:00',
}),
dict({
'end': '2025-07-06T11:00:00+00:00',
'price': 72.5,
'start': '2025-07-06T10:00:00+00:00',
}),
dict({
'end': '2025-07-06T12:00:00+00:00',
'price': 63.49,
'start': '2025-07-06T11:00:00+00:00',
}),
dict({
'end': '2025-07-06T13:00:00+00:00',
'price': 91.64,
'start': '2025-07-06T12:00:00+00:00',
}),
dict({
'end': '2025-07-06T14:00:00+00:00',
'price': 111.79,
'start': '2025-07-06T13:00:00+00:00',
}),
dict({
'end': '2025-07-06T15:00:00+00:00',
'price': 234.04,
'start': '2025-07-06T14:00:00+00:00',
}),
dict({
'end': '2025-07-06T16:00:00+00:00',
'price': 435.33,
'start': '2025-07-06T15:00:00+00:00',
}),
dict({
'end': '2025-07-06T17:00:00+00:00',
'price': 431.84,
'start': '2025-07-06T16:00:00+00:00',
}),
dict({
'end': '2025-07-06T18:00:00+00:00',
'price': 423.73,
'start': '2025-07-06T17:00:00+00:00',
}),
dict({
'end': '2025-07-06T19:00:00+00:00',
'price': 437.92,
'start': '2025-07-06T18:00:00+00:00',
}),
dict({
'end': '2025-07-06T20:00:00+00:00',
'price': 416.42,
'start': '2025-07-06T19:00:00+00:00',
}),
dict({
'end': '2025-07-06T21:00:00+00:00',
'price': 414.39,
'start': '2025-07-06T20:00:00+00:00',
}),
dict({
'end': '2025-07-06T22:00:00+00:00',
'price': 396.38,
'start': '2025-07-06T21:00:00+00:00',
}),
]),
})
# ---

View File

@ -1,8 +1,10 @@
"""Test services in Nord Pool.""" """Test services in Nord Pool."""
import json
from unittest.mock import patch from unittest.mock import patch
from pynordpool import ( from pynordpool import (
API,
NordPoolAuthenticationError, NordPoolAuthenticationError,
NordPoolEmptyResponseError, NordPoolEmptyResponseError,
NordPoolError, NordPoolError,
@ -15,13 +17,16 @@ from homeassistant.components.nordpool.services import (
ATTR_AREAS, ATTR_AREAS,
ATTR_CONFIG_ENTRY, ATTR_CONFIG_ENTRY,
ATTR_CURRENCY, ATTR_CURRENCY,
ATTR_RESOLUTION,
SERVICE_GET_PRICE_INDICES_FOR_DATE,
SERVICE_GET_PRICES_FOR_DATE, SERVICE_GET_PRICES_FOR_DATE,
) )
from homeassistant.const import ATTR_DATE from homeassistant.const import ATTR_DATE
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ServiceValidationError from homeassistant.exceptions import ServiceValidationError
from tests.common import MockConfigEntry from tests.common import MockConfigEntry, async_load_fixture
from tests.test_util.aiohttp import AiohttpClientMocker
TEST_SERVICE_DATA = { TEST_SERVICE_DATA = {
ATTR_CONFIG_ENTRY: "to_replace", ATTR_CONFIG_ENTRY: "to_replace",
@ -33,6 +38,20 @@ TEST_SERVICE_DATA_USE_DEFAULTS = {
ATTR_CONFIG_ENTRY: "to_replace", ATTR_CONFIG_ENTRY: "to_replace",
ATTR_DATE: "2024-11-05", ATTR_DATE: "2024-11-05",
} }
TEST_SERVICE_INDICES_DATA_60 = {
ATTR_CONFIG_ENTRY: "to_replace",
ATTR_DATE: "2025-07-06",
ATTR_AREAS: "SE3",
ATTR_CURRENCY: "SEK",
ATTR_RESOLUTION: 60,
}
TEST_SERVICE_INDICES_DATA_15 = {
ATTR_CONFIG_ENTRY: "to_replace",
ATTR_DATE: "2025-07-06",
ATTR_AREAS: "SE3",
ATTR_CURRENCY: "SEK",
ATTR_RESOLUTION: 15,
}
@pytest.mark.freeze_time("2024-11-05T18:00:00+00:00") @pytest.mark.freeze_time("2024-11-05T18:00:00+00:00")
@ -163,3 +182,66 @@ async def test_service_call_config_entry_bad_state(
return_response=True, return_response=True,
) )
assert err.value.translation_key == "entry_not_loaded" assert err.value.translation_key == "entry_not_loaded"
@pytest.mark.freeze_time("2024-11-05T18:00:00+00:00")
async def test_service_call_for_price_indices(
hass: HomeAssistant,
load_int: MockConfigEntry,
snapshot: SnapshotAssertion,
aioclient_mock: AiohttpClientMocker,
) -> None:
"""Test get_price_indices_for_date service call."""
fixture_60 = json.loads(await async_load_fixture(hass, "indices_60.json", DOMAIN))
fixture_15 = json.loads(await async_load_fixture(hass, "indices_15.json", DOMAIN))
aioclient_mock.request(
"GET",
url=API + "/DayAheadPriceIndices",
params={
"date": "2025-07-06",
"market": "DayAhead",
"indexNames": "SE3",
"currency": "SEK",
"resolutionInMinutes": "60",
},
json=fixture_60,
)
aioclient_mock.request(
"GET",
url=API + "/DayAheadPriceIndices",
params={
"date": "2025-07-06",
"market": "DayAhead",
"indexNames": "SE3",
"currency": "SEK",
"resolutionInMinutes": "15",
},
json=fixture_15,
)
service_data = TEST_SERVICE_INDICES_DATA_60.copy()
service_data[ATTR_CONFIG_ENTRY] = load_int.entry_id
response = await hass.services.async_call(
DOMAIN,
SERVICE_GET_PRICE_INDICES_FOR_DATE,
service_data,
blocking=True,
return_response=True,
)
assert response == snapshot(name="get_price_indices_for_date_60")
service_data = TEST_SERVICE_INDICES_DATA_15.copy()
service_data[ATTR_CONFIG_ENTRY] = load_int.entry_id
response = await hass.services.async_call(
DOMAIN,
SERVICE_GET_PRICE_INDICES_FOR_DATE,
service_data,
blocking=True,
return_response=True,
)
assert response == snapshot(name="get_price_indices_for_date_15")