@@ -98,6 +98,23 @@ def __iter__(self) -> Iterator[MetricSample]:
9898                    metric = met ,
9999                    value = value ,
100100                )
101+                 for  i , bound  in  enumerate (msample .bounds ):
102+                     if  bound .lower :
103+                         yield  MetricSample (
104+                             timestamp = ts ,
105+                             microgrid_id = mid ,
106+                             component_id = cid ,
107+                             metric = f"{ met } { i }  ,
108+                             value = bound .lower ,
109+                         )
110+                     if  bound .upper :
111+                         yield  MetricSample (
112+                             timestamp = ts ,
113+                             microgrid_id = mid ,
114+                             component_id = cid ,
115+                             metric = f"{ met } { i }  ,
116+                             value = bound .upper ,
117+                         )
101118            for  state  in  cdata .states :
102119                ts  =  state .sampled_at .ToDatetime ()
103120                for  name , category  in  {
@@ -140,6 +157,7 @@ async def list_single_component_data(
140157        end_dt : datetime ,
141158        resolution : int  |  None ,
142159        include_states : bool  =  False ,
160+         include_bounds : bool  =  False ,
143161    ) ->  AsyncIterator [MetricSample ]:
144162        """Iterate over the data for a single metric. 
145163
@@ -151,6 +169,7 @@ async def list_single_component_data(
151169            end_dt: The end date and time. 
152170            resolution: The resampling resolution for the data, represented in seconds. 
153171            include_states: Whether to include the state data. 
172+             include_bounds: Whether to include the bound data. 
154173
155174        Yields: 
156175            A named tuple with the following fields: 
@@ -164,6 +183,7 @@ async def list_single_component_data(
164183            end_dt = end_dt ,
165184            resolution = resolution ,
166185            include_states = include_states ,
186+             include_bounds = include_bounds ,
167187        ):
168188            for  entry  in  batch :
169189                yield  entry 
@@ -178,6 +198,7 @@ async def list_microgrid_components_data(
178198        end_dt : datetime ,
179199        resolution : int  |  None ,
180200        include_states : bool  =  False ,
201+         include_bounds : bool  =  False ,
181202    ) ->  AsyncIterator [MetricSample ]:
182203        """Iterate over the data for multiple microgrids and components. 
183204
@@ -189,6 +210,7 @@ async def list_microgrid_components_data(
189210            end_dt: The end date and time. 
190211            resolution: The resampling resolution for the data, represented in seconds. 
191212            include_states: Whether to include the state data. 
213+             include_bounds: Whether to include the bound data. 
192214
193215        Yields: 
194216            A named tuple with the following fields: 
@@ -205,6 +227,7 @@ async def list_microgrid_components_data(
205227            end_dt = end_dt ,
206228            resolution = resolution ,
207229            include_states = include_states ,
230+             include_bounds = include_bounds ,
208231        ):
209232            for  entry  in  batch :
210233                yield  entry 
@@ -220,6 +243,7 @@ async def _list_microgrid_components_data_batch(
220243        end_dt : datetime ,
221244        resolution : int  |  None ,
222245        include_states : bool  =  False ,
246+         include_bounds : bool  =  False ,
223247    ) ->  AsyncIterator [ComponentsDataBatch ]:
224248        """Iterate over the component data batches in the stream. 
225249
@@ -233,6 +257,7 @@ async def _list_microgrid_components_data_batch(
233257            end_dt: The end date and time. 
234258            resolution: The resampling resolution for the data, represented in seconds. 
235259            include_states: Whether to include the state data. 
260+             include_bounds: Whether to include the bound data. 
236261
237262        Yields: 
238263            A ComponentsDataBatch object of microgrid components data. 
@@ -257,7 +282,13 @@ def dt2ts(dt: datetime) -> PBTimestamp:
257282            if  include_states 
258283            else  PBIncludeOptions .FilterOption .FILTER_OPTION_EXCLUDE 
259284        )
285+         incl_bounds  =  (
286+             PBIncludeOptions .FilterOption .FILTER_OPTION_INCLUDE 
287+             if  include_bounds 
288+             else  PBIncludeOptions .FilterOption .FILTER_OPTION_EXCLUDE 
289+         )
260290        include_options  =  PBIncludeOptions (
291+             bounds = incl_bounds ,
261292            states = incl_states ,
262293        )
263294
0 commit comments