@@ -59,6 +59,7 @@ class Electricity:
5959 """Object representing electricity data."""
6060
6161 prices : dict [datetime , float ]
62+ resolution : timedelta
6263 time_zone : ZoneInfo
6364
6465 @property
@@ -257,12 +258,19 @@ def prices_today(self) -> dict[datetime, float]:
257258
258259 """
259260 today = self .now_in_timezone ().astimezone ().date ()
260- return {
261+ prices = {
261262 timestamp : price
262263 for timestamp , price in self .prices .items ()
263264 if timestamp .date () == today
264265 }
265266
267+ if (self .resolution == timedelta (minutes = 15 ) and len (prices ) == 96 ) or (
268+ self .resolution == timedelta (minutes = 60 ) and len (prices ) == 24
269+ ):
270+ return prices
271+
272+ return {}
273+
266274 def prices_tomorrow (self ) -> dict [datetime , float ]:
267275 """Return the prices for tomorrow.
268276
@@ -272,12 +280,19 @@ def prices_tomorrow(self) -> dict[datetime, float]:
272280
273281 """
274282 tomorrow = (self .now_in_timezone () + timedelta (days = 1 )).astimezone ().date ()
275- return {
283+ prices = {
276284 timestamp : price
277285 for timestamp , price in self .prices .items ()
278286 if timestamp .date () == tomorrow
279287 }
280288
289+ if (self .resolution == timedelta (minutes = 15 ) and len (prices ) == 96 ) or (
290+ self .resolution == timedelta (minutes = 60 ) and len (prices ) == 24
291+ ):
292+ return prices
293+
294+ return {}
295+
281296 def now_in_timezone (self ) -> datetime :
282297 """Return the current timestamp in the current timezone.
283298
@@ -329,13 +344,16 @@ def price_at_time(self, moment: datetime) -> float | None:
329344 def from_dict (
330345 cls : type [Electricity ],
331346 data : list [dict [str , Any ]],
347+ resolution : timedelta ,
332348 time_zone : ZoneInfo ,
333349 ) -> Electricity :
334350 """Create an Electricity object from a dictionary.
335351
336352 Args:
337353 ----
338354 data: A dictionary with the data from the API.
355+ resolution: The price resolution, default is 60 minutes. Supported options
356+ are 15 and 60 minutes.
339357 time_zone: The timezone to use for determining "today" and "tomorrow".
340358
341359 Returns:
@@ -350,5 +368,6 @@ def from_dict(
350368 ]
351369 return cls (
352370 prices = prices ,
371+ resolution = resolution ,
353372 time_zone = time_zone ,
354373 )
0 commit comments