@@ -183,23 +183,20 @@ async def save_api_call_to_db(self, url: str, authdata: dict[str, str]) -> None:
183183 async def get_substations (
184184 self ,
185185 authdata : dict [str , str ],
186- ) -> list [models .Site ]:
186+ ) -> list [models .Substation ]:
187187 req = dp .ListLocationsRequest (
188188 energy_source_filter = dp .EnergySource .SOLAR ,
189189 location_type_filter = dp .LocationType .PRIMARY_SUBSTATION ,
190190 user_oauth_id_filter = authdata ["sub" ],
191191 )
192192 resp = await self .dp_client .list_locations (req )
193193 return [
194- models .Site (
195- site_uuid = loc .location_uuid ,
196- client_site_name = loc .location_name ,
197- orientation = loc .metadata .fields ["orientation" ].number_value
198- if "orientation" in loc .metadata .fields
199- else None ,
200- tilt = loc .metadata .fields ["tilt" ].number_value
201- if "tilt" in loc .metadata .fields
202- else None ,
194+ models .Substation (
195+ substation_uuid = loc .location_uuid ,
196+ substation_name = loc .location_name ,
197+ substation_type = "primary"
198+ if loc .location_type == dp .LocationType .PRIMARY_SUBSTATION
199+ else "unknown" ,
203200 capacity_kw = loc .effective_capacity_watts // 1000.0 ,
204201 latitude = loc .latlng .latitude ,
205202 longitude = loc .latlng .longitude ,
@@ -213,7 +210,6 @@ async def get_substation_forecast(
213210 substation_uuid : UUID ,
214211 authdata : dict [str , str ],
215212 ) -> list [models .PredictedPower ]:
216-
217213 # Get the substation
218214 req = dp .ListLocationsRequest (
219215 location_uuids_filter = [substation_uuid ],
@@ -249,25 +245,25 @@ async def get_substation_forecast(
249245 )
250246
251247 # Scale the forecast to the substation capacity
252- scale_factor : float = (
253- substation .effective_capacity_watts / gsp .effective_capacity_watts
254- )
248+ scale_factor : float = substation .effective_capacity_watts / gsp .effective_capacity_watts
255249 for value in forecast :
256250 value .PowerKW = value .PowerKW * scale_factor
257251
258252 log .debug (
259253 "gsp=%s, substation=%s, scalefactor=%s, scaling GSP to substation" ,
260- gsp .location_uuid , substation .location_uuid , scale_factor ,
254+ gsp .location_uuid ,
255+ substation .location_uuid ,
256+ scale_factor ,
261257 )
262258
263259 return forecast
264260
265261 @override
266- async def get_location (
262+ async def get_substation (
267263 self ,
268264 location_uuid : UUID ,
269265 authdata : dict [str , str ],
270- ) -> models .SiteProperties :
266+ ) -> models .SubstationProperties :
271267 req = dp .ListLocationsRequest (
272268 location_uuids_filter = [location_uuid ],
273269 energy_source_filter = dp .EnergySource .SOLAR ,
@@ -281,15 +277,9 @@ async def get_location(
281277 )
282278 loc = resp .locations [0 ]
283279
284- return models .Site (
285- site_uuid = loc .location_uuid ,
286- client_site_name = loc .location_name ,
287- orientation = loc .metadata .fields ["orientation" ].number_value
288- if "orientation" in loc .metadata .fields
289- else None ,
290- tilt = loc .metadata .fields ["tilt" ].number_value
291- if "tilt" in loc .metadata .fields
292- else None ,
280+ return models .SubstationProperties (
281+ substation_name = loc .location_name ,
282+ substation_type = "primary" ,
293283 capacity_kw = loc .effective_capacity_watts // 1000.0 ,
294284 latitude = loc .latlng .latitude ,
295285 longitude = loc .latlng .longitude ,
@@ -339,7 +329,7 @@ async def _get_predicted_power_production_for_location(
339329 oauth_id : str | None ,
340330 forecast_horizon : models .ForecastHorizon = models .ForecastHorizon .latest ,
341331 forecast_horizon_minutes : int | None = None ,
342- smooth_flag : bool = True , # noqa: ARG002
332+ smooth_flag : bool = True , # noqa: ARG002
343333 ) -> list [models .PredictedPower ]:
344334 """Local function to retrieve predicted values regardless of energy type."""
345335 if oauth_id is not None :
0 commit comments