mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Plugwise improve exception translations (#132663)
This commit is contained in:
parent
0c08e88953
commit
674d42d8a0
@ -73,17 +73,30 @@ class PlugwiseDataUpdateCoordinator(DataUpdateCoordinator[PlugwiseData]):
|
||||
await self._connect()
|
||||
data = await self.api.async_update()
|
||||
except ConnectionFailedError as err:
|
||||
raise UpdateFailed("Failed to connect") from err
|
||||
raise UpdateFailed(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="failed_to_connect",
|
||||
) from err
|
||||
except InvalidAuthentication as err:
|
||||
raise ConfigEntryError("Authentication failed") from err
|
||||
raise ConfigEntryError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="authentication_failed",
|
||||
) from err
|
||||
except (InvalidXMLError, ResponseError) as err:
|
||||
raise UpdateFailed(
|
||||
"Invalid XML data, or error indication received from the Plugwise Adam/Smile/Stretch"
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="invalid_xml_data",
|
||||
) from err
|
||||
except PlugwiseError as err:
|
||||
raise UpdateFailed("Data incomplete or missing") from err
|
||||
raise UpdateFailed(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="data_incomplete_or_missing",
|
||||
) from err
|
||||
except UnsupportedDeviceError as err:
|
||||
raise ConfigEntryError("Device with unsupported firmware") from err
|
||||
raise ConfigEntryError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="unsupported_firmware",
|
||||
) from err
|
||||
|
||||
self._async_add_remove_devices(data, self.config_entry)
|
||||
return data
|
||||
|
@ -19,7 +19,7 @@ rules:
|
||||
comment: Verify entity for async_added_to_hass usage (discard?)
|
||||
docs-high-level-description:
|
||||
status: todo
|
||||
comment: Rewrite top section, docs PR prepared
|
||||
comment: Rewrite top section, docs PR prepared waiting for 36087 merge
|
||||
docs-installation-instructions:
|
||||
status: todo
|
||||
comment: Docs PR 36087
|
||||
@ -56,9 +56,7 @@ rules:
|
||||
discovery: done
|
||||
stale-devices: done
|
||||
diagnostics: done
|
||||
exception-translations:
|
||||
status: todo
|
||||
comment: Add coordinator, util exceptions (climate done in core 132175)
|
||||
exception-translations: done
|
||||
icon-translations: done
|
||||
reconfiguration-flow:
|
||||
status: todo
|
||||
@ -70,23 +68,23 @@ rules:
|
||||
comment: This integration does not have repairs
|
||||
docs-use-cases:
|
||||
status: todo
|
||||
comment: Check for completeness, PR prepared
|
||||
comment: Check for completeness, PR prepared waiting for 36087 merge
|
||||
docs-supported-devices:
|
||||
status: todo
|
||||
comment: The list is there but could be improved for readability, PR prepared
|
||||
comment: The list is there but could be improved for readability, PR prepared waiting for 36087 merge
|
||||
docs-supported-functions:
|
||||
status: todo
|
||||
comment: Check for completeness
|
||||
comment: Check for completeness, PR prepared waiting for 36087 merge
|
||||
docs-data-update: done
|
||||
docs-known-limitations:
|
||||
status: todo
|
||||
comment: Partial in 36087 but could be more elaborate
|
||||
docs-troubleshooting:
|
||||
status: todo
|
||||
comment: Check for completeness, PR prepared
|
||||
comment: Check for completeness, PR prepared waiting for 36087 merge
|
||||
docs-examples:
|
||||
status: todo
|
||||
comment: Check for completeness
|
||||
comment: Check for completeness, PR prepared waiting for 36087 merge
|
||||
## Platinum
|
||||
async-dependency: done
|
||||
inject-websession: done
|
||||
|
@ -286,8 +286,23 @@
|
||||
}
|
||||
},
|
||||
"exceptions": {
|
||||
"invalid_temperature_change_requested": {
|
||||
"message": "Invalid temperature change requested."
|
||||
"authentication_failed": {
|
||||
"message": "[%key:common::config_flow::error::invalid_auth%]"
|
||||
},
|
||||
"data_incomplete_or_missing": {
|
||||
"message": "Data incomplete or missing."
|
||||
},
|
||||
"error_communicating_with_api": {
|
||||
"message": "Error communicating with API: {error}."
|
||||
},
|
||||
"failed_to_connect": {
|
||||
"message": "[%key:common::config_flow::error::cannot_connect%]"
|
||||
},
|
||||
"invalid_xml_data": {
|
||||
"message": "[%key:component::plugwise::config::error::response_error%]"
|
||||
},
|
||||
"unsupported_firmware": {
|
||||
"message": "[%key:component::plugwise::config::error::unsupported%]"
|
||||
},
|
||||
"unsupported_hvac_mode_requested": {
|
||||
"message": "Unsupported mode {hvac_mode} requested, valid modes are: {hvac_modes}."
|
||||
|
@ -7,6 +7,7 @@ from plugwise.exceptions import PlugwiseException
|
||||
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
||||
from .const import DOMAIN
|
||||
from .entity import PlugwiseEntity
|
||||
|
||||
|
||||
@ -24,10 +25,14 @@ def plugwise_command[_PlugwiseEntityT: PlugwiseEntity, **_P, _R](
|
||||
) -> _R:
|
||||
try:
|
||||
return await func(self, *args, **kwargs)
|
||||
except PlugwiseException as error:
|
||||
except PlugwiseException as err:
|
||||
raise HomeAssistantError(
|
||||
f"Error communicating with API: {error}"
|
||||
) from error
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="error_communicating_with_api",
|
||||
translation_placeholders={
|
||||
"error": str(err),
|
||||
},
|
||||
) from err
|
||||
finally:
|
||||
await self.coordinator.async_request_refresh()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user