Skip to content

Commit ace04f0

Browse files
committed
Do not refresh if offline
1 parent 9c5317e commit ace04f0

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

simvue/eco/emissions_monitor.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def check_refresh(self) -> bool:
156156
whether a refresh of the CO2 intensity was requested
157157
from the CO2 Signal API.
158158
"""
159-
if not self.co2_intensity and (
159+
if (
160160
not self._local_data.setdefault(self._client.country_code, {})
161161
or self.outdated
162162
):
@@ -193,12 +193,11 @@ def estimate_co2_emissions(
193193
if not (_process := self._processes.get(process_id)):
194194
self._processes[process_id] = (_process := ProcessData())
195195

196-
self.check_refresh()
197-
198196
if self.co2_intensity:
199197
_current_co2_intensity = self.co2_intensity
200198
_co2_units = "kgCO2/kWh"
201199
else:
200+
self.check_refresh()
202201
self._current_co2_data = CO2SignalResponse(
203202
**self._local_data[self._client.country_code]
204203
)

0 commit comments

Comments
 (0)