commit cfd8e6ad3c5d478d443752eab624eca447cf230e parent 96d07ad90e6c96ee10fc4bed97f201b16af97132 Author: Stéphan Kochen <git@stephank.nl> Date: Wed, 02 Sep 2026 08:18:49 +0200 Fix incomplete error messages
diff --git a/custom_components/hunter_btt/coordinator.py b/custom_components/hunter_btt/coordinator.py index a9e270756f1bdd8025574be43264bbc099bb39b4..c8c0ef59f5fd9eb36b5c44597b68c698f942cadd 100644 --- a/custom_components/hunter_btt/coordinator.py +++ b/custom_components/hunter_btt/coordinator.py @@ -43,6 +43,13 @@ type HunterBTTConfigEntry = ConfigEntry[HunterBTTCoordinator] +def _operation_failed(message: str, err: Exception) -> UpdateFailed: + """Log and retain the specific BLE or protocol error for HA.""" + _LOGGER.debug("%s", message, exc_info=err) + detail = str(err) or type(err).__name__ + return UpdateFailed(f"{message}: {detail}") + + @dataclass(frozen=True, slots=True) class HunterBTTData: """One disconnected status poll and its HA-calculated end time.""" @@ -88,9 +95,15 @@ """Connect, authenticate, read status, and disconnect.""" async with self._poll_lock: try: state = await self._async_read_status() - except BleakError, HunterBTTError, OSError, TimeoutError: + except ( + BleakError, + HunterBTTError, + OSError, + ProtocolError, + TimeoutError, + ) as err: msg = "Unable to refresh Hunter BTT status" - raise UpdateFailed(msg) from None + raise _operation_failed(msg, err) from err refreshed_at = dt_util.utcnow() data = HunterBTTData( @@ -138,9 +151,15 @@ """Run one authenticated manual command and publish its returned status.""" async with self._poll_lock: try: state = await self._async_execute_manual_command(duration_seconds) - except BleakError, HunterBTTError, OSError, ProtocolError, TimeoutError: + except ( + BleakError, + HunterBTTError, + OSError, + ProtocolError, + TimeoutError, + ) as err: msg = "Unable to change Hunter BTT watering" - raise UpdateFailed(msg) from None + raise _operation_failed(msg, err) from err refreshed_at = dt_util.utcnow() data = HunterBTTData(