@@ -563,28 +563,31 @@ async def get_meter_reading(self, *, cost_type: str) -> MeterReading:
563563 kind = kind ,
564564 )
565565
566- async def get_meter_readings (self ) -> list [ MeterReading ]:
566+ async def get_meter_readings (self ) -> dict [ str , MeterReading ]:
567567 """
568- Convenience helper: return meter readings for the first HZ.. and WW.. cost types.
568+ Convenience helper: return meter readings for *all* HZ.. and WW.. cost types.
569+
570+ Output is keyed by `cost_type` (stable mapping for HA entity IDs).
569571 """
570572 dates = await self .get_dashboard_dates ()
571573 results = (dates .get ("d" ) or {}).get ("results" ) or []
572574 period = next ((p for p in results if isinstance (p , dict )), None )
573575 if not period :
574- return []
576+ return {}
577+
575578 unit_rows = ((period .get ("Units" ) or {}).get ("results" ) or [])
576- cost_types = [
577- r . get ( "CostType" )
578- for r in unit_rows
579- if isinstance ( r , dict ) and isinstance ( r . get ( "CostType" ), str )
580- ]
581- hz = next (( ct for ct in cost_types if ct . startswith ( "HZ" )), None )
582- ww = next (( ct for ct in cost_types if ct . startswith ( "WW" )), None )
583- out : list [ MeterReading ] = []
584- if hz :
585- out . append ( await self . get_meter_reading ( cost_type = hz ))
586- if ww :
587- out . append ( await self .get_meter_reading (cost_type = ww ) )
579+ all_cost_types = sorted (
580+ {
581+ r [ "CostType" ]
582+ for r in unit_rows
583+ if isinstance ( r , dict ) and isinstance ( r . get ( "CostType" ), str )
584+ }
585+ )
586+ wanted = [ct for ct in all_cost_types if ct . startswith (( "HZ" , "WW" )) ]
587+
588+ out : dict [ str , MeterReading ] = {}
589+ for ct in wanted :
590+ out [ ct ] = await self .get_meter_reading (cost_type = ct )
588591 return out
589592
590593 async def get_supported_cost_types (self ) -> dict [str , set [str ]]:
@@ -682,6 +685,39 @@ async def get_monthly_consumption(
682685
683686 return []
684687
688+ async def get_monthly_consumptions (
689+ self ,
690+ kind : ReadingKind ,
691+ * ,
692+ in_kwh : bool = True ,
693+ ) -> dict [str , list [Reading ]]:
694+ """
695+ Fetch monthly consumption series for *all* cost types matching `kind`.
696+
697+ Output is keyed by `cost_type` (e.g. HZ01, HZ02, WW01...).
698+ """
699+ dates = await self .get_dashboard_dates ()
700+ results = (dates .get ("d" ) or {}).get ("results" ) or []
701+ period = next ((p for p in results if isinstance (p , dict )), None )
702+ if not period :
703+ return {}
704+
705+ unit_rows = ((period .get ("Units" ) or {}).get ("results" ) or [])
706+ all_cost_types = sorted (
707+ {
708+ r ["CostType" ]
709+ for r in unit_rows
710+ if isinstance (r , dict ) and isinstance (r .get ("CostType" ), str )
711+ }
712+ )
713+ prefix = "HZ" if kind == ReadingKind .heating else "WW"
714+ wanted = [ct for ct in all_cost_types if ct .startswith (prefix )]
715+
716+ out : dict [str , list [Reading ]] = {}
717+ for ct in wanted :
718+ out [ct ] = await self .get_monthly_consumption (cost_type = ct , in_kwh = in_kwh )
719+ return out
720+
685721 async def get_current_consumption (self , kind : ReadingKind ) -> CurrentConsumption :
686722 """
687723 Returns the value shown in the dashboard cards:
0 commit comments