mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +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()
|
await self._connect()
|
||||||
data = await self.api.async_update()
|
data = await self.api.async_update()
|
||||||
except ConnectionFailedError as err:
|
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:
|
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:
|
except (InvalidXMLError, ResponseError) as err:
|
||||||
raise UpdateFailed(
|
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
|
) from err
|
||||||
except PlugwiseError as 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:
|
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)
|
self._async_add_remove_devices(data, self.config_entry)
|
||||||
return data
|
return data
|
||||||
|
@ -19,7 +19,7 @@ rules:
|
|||||||
comment: Verify entity for async_added_to_hass usage (discard?)
|
comment: Verify entity for async_added_to_hass usage (discard?)
|
||||||
docs-high-level-description:
|
docs-high-level-description:
|
||||||
status: todo
|
status: todo
|
||||||
comment: Rewrite top section, docs PR prepared
|
comment: Rewrite top section, docs PR prepared waiting for 36087 merge
|
||||||
docs-installation-instructions:
|
docs-installation-instructions:
|
||||||
status: todo
|
status: todo
|
||||||
comment: Docs PR 36087
|
comment: Docs PR 36087
|
||||||
@ -56,9 +56,7 @@ rules:
|
|||||||
discovery: done
|
discovery: done
|
||||||
stale-devices: done
|
stale-devices: done
|
||||||
diagnostics: done
|
diagnostics: done
|
||||||
exception-translations:
|
exception-translations: done
|
||||||
status: todo
|
|
||||||
comment: Add coordinator, util exceptions (climate done in core 132175)
|
|
||||||
icon-translations: done
|
icon-translations: done
|
||||||
reconfiguration-flow:
|
reconfiguration-flow:
|
||||||
status: todo
|
status: todo
|
||||||
@ -70,23 +68,23 @@ rules:
|
|||||||
comment: This integration does not have repairs
|
comment: This integration does not have repairs
|
||||||
docs-use-cases:
|
docs-use-cases:
|
||||||
status: todo
|
status: todo
|
||||||
comment: Check for completeness, PR prepared
|
comment: Check for completeness, PR prepared waiting for 36087 merge
|
||||||
docs-supported-devices:
|
docs-supported-devices:
|
||||||
status: todo
|
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:
|
docs-supported-functions:
|
||||||
status: todo
|
status: todo
|
||||||
comment: Check for completeness
|
comment: Check for completeness, PR prepared waiting for 36087 merge
|
||||||
docs-data-update: done
|
docs-data-update: done
|
||||||
docs-known-limitations:
|
docs-known-limitations:
|
||||||
status: todo
|
status: todo
|
||||||
comment: Partial in 36087 but could be more elaborate
|
comment: Partial in 36087 but could be more elaborate
|
||||||
docs-troubleshooting:
|
docs-troubleshooting:
|
||||||
status: todo
|
status: todo
|
||||||
comment: Check for completeness, PR prepared
|
comment: Check for completeness, PR prepared waiting for 36087 merge
|
||||||
docs-examples:
|
docs-examples:
|
||||||
status: todo
|
status: todo
|
||||||
comment: Check for completeness
|
comment: Check for completeness, PR prepared waiting for 36087 merge
|
||||||
## Platinum
|
## Platinum
|
||||||
async-dependency: done
|
async-dependency: done
|
||||||
inject-websession: done
|
inject-websession: done
|
||||||
|
@ -286,8 +286,23 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"exceptions": {
|
"exceptions": {
|
||||||
"invalid_temperature_change_requested": {
|
"authentication_failed": {
|
||||||
"message": "Invalid temperature change requested."
|
"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": {
|
"unsupported_hvac_mode_requested": {
|
||||||
"message": "Unsupported mode {hvac_mode} requested, valid modes are: {hvac_modes}."
|
"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 homeassistant.exceptions import HomeAssistantError
|
||||||
|
|
||||||
|
from .const import DOMAIN
|
||||||
from .entity import PlugwiseEntity
|
from .entity import PlugwiseEntity
|
||||||
|
|
||||||
|
|
||||||
@ -24,10 +25,14 @@ def plugwise_command[_PlugwiseEntityT: PlugwiseEntity, **_P, _R](
|
|||||||
) -> _R:
|
) -> _R:
|
||||||
try:
|
try:
|
||||||
return await func(self, *args, **kwargs)
|
return await func(self, *args, **kwargs)
|
||||||
except PlugwiseException as error:
|
except PlugwiseException as err:
|
||||||
raise HomeAssistantError(
|
raise HomeAssistantError(
|
||||||
f"Error communicating with API: {error}"
|
translation_domain=DOMAIN,
|
||||||
) from error
|
translation_key="error_communicating_with_api",
|
||||||
|
translation_placeholders={
|
||||||
|
"error": str(err),
|
||||||
|
},
|
||||||
|
) from err
|
||||||
finally:
|
finally:
|
||||||
await self.coordinator.async_request_refresh()
|
await self.coordinator.async_request_refresh()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user