Skip to content

Commit 4099b79

Browse files
committed
Fix handling of no local emission data
1 parent d352d7e commit 4099b79

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

simvue/eco/emissions_monitor.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,17 +232,17 @@ def estimate_co2_emissions(
232232
_co2_units = "kgCO2/kWh"
233233
else:
234234
self.check_refresh()
235+
# If no local data yet then return
236+
if not (_country_codes := list(self._local_data.keys())):
237+
self._logger.warning(
238+
"No CO2 emission data recorded as no CO2 intensity value "
239+
"has been provided and there is no local intensity data available."
240+
)
241+
return
242+
235243
if self._client:
236244
_country_code = self._client.country_code
237245
else:
238-
# If no local data yet then return
239-
if not (_country_codes := list(self._local_data.keys())):
240-
self._logger.warning(
241-
"No CO2 emission data recorded as no CO2 intensity value "
242-
"has been provided and there is no local intensity data available."
243-
)
244-
return
245-
246246
_country_code = _country_codes[0]
247247
self._logger.debug(
248248
f"🗂️ Using data for region '{_country_code}' from local cache for offline estimation."

0 commit comments

Comments
 (0)