Add PowerfoxPrivacyError handling for Powerfox integration (#164100)

This commit is contained in:
Klaas Schoute
2026-02-25 20:28:56 +01:00
committed by GitHub
parent 17e0fd1885
commit 390b62551d
2 changed files with 24 additions and 3 deletions
@@ -11,6 +11,7 @@ from powerfox import (
PowerfoxAuthenticationError,
PowerfoxConnectionError,
PowerfoxNoDataError,
PowerfoxPrivacyError,
Poweropti,
)
@@ -56,9 +57,21 @@ class PowerfoxBaseCoordinator[T](DataUpdateCoordinator[T]):
try:
return await self._async_fetch_data()
except PowerfoxAuthenticationError as err:
raise ConfigEntryAuthFailed(err) from err
except (PowerfoxConnectionError, PowerfoxNoDataError) as err:
raise UpdateFailed(err) from err
raise ConfigEntryAuthFailed(
translation_domain=DOMAIN,
translation_key="invalid_auth",
translation_placeholders={"error": str(err)},
) from err
except (
PowerfoxConnectionError,
PowerfoxNoDataError,
PowerfoxPrivacyError,
) as err:
raise UpdateFailed(
translation_domain=DOMAIN,
translation_key="update_failed",
translation_placeholders={"error": str(err)},
) from err
async def _async_fetch_data(self) -> T:
"""Fetch data from the Powerfox API."""
@@ -114,5 +114,13 @@
"name": "Warm water"
}
}
},
"exceptions": {
"invalid_auth": {
"message": "Error while authenticating with the Powerfox service: {error}"
},
"update_failed": {
"message": "Error while updating the Powerfox service: {error}"
}
}
}