diff --git a/src/gort/overwatcher/calibration.py b/src/gort/overwatcher/calibration.py index d05d2ff..926f290 100644 --- a/src/gort/overwatcher/calibration.py +++ b/src/gort/overwatcher/calibration.py @@ -550,20 +550,29 @@ async def run_calibration(self, calibration: Calibration): dome_current = await self.overwatcher.gort.enclosure.is_open() needs_dome_change = dome_new != dome_current - if needs_dome_change and not self.overwatcher.state.enabled: - await self._fail_calibration( - calibration, - f"Cannot move dome for {name!r}. Overwatcher is disabled.", - level="error", - ) - return - - if dome == "open" and not dome_current: - await notify("Opening the dome for calibration.") - await self.overwatcher.gort.enclosure.open() - elif dome == "closed" and dome_current: - await notify("Closing the dome for calibration.") - await self.overwatcher.gort.enclosure.close() + if needs_dome_change: + if not self.overwatcher.state.enabled: + await self._fail_calibration( + calibration, + f"Cannot move dome for {name!r}. Overwatcher is disabled.", + level="error", + ) + return + + if dome == "open" and not self.overwatcher.state.safe: + await self._fail_calibration( + calibration, + f"Cannot move dome for {name!r}. Weather is not safe.", + level="warning", + ) + return + + if dome == "open" and not dome_current: + await notify("Opening the dome for calibration.") + await self.overwatcher.gort.enclosure.open() + elif dome == "closed" and dome_current: + await notify("Closing the dome for calibration.") + await self.overwatcher.gort.enclosure.close() await notify(f"Running recipe {recipe!r} for calibration {name!r}.") await self.overwatcher.gort.execute_recipe(recipe)