mirror of
https://github.com/home-assistant/core.git
synced 2025-04-19 14:57:52 +00:00
Make remaining ESPHome exceptions translatable (#143184)
This commit is contained in:
parent
aa342eb476
commit
45022752a0
@ -28,6 +28,8 @@ from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
# Import config flow so that it's added to the registry
|
||||
from .entry_data import ESPHomeConfigEntry, RuntimeEntryData
|
||||
from .enum_mapper import EsphomeEnumMapper
|
||||
@ -167,7 +169,12 @@ def convert_api_error_ha_error[**_P, _R, _EntityT: EsphomeEntity[Any, Any]](
|
||||
return await func(self, *args, **kwargs)
|
||||
except APIConnectionError as error:
|
||||
raise HomeAssistantError(
|
||||
f"Error communicating with device: {error}"
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="error_communicating_with_device",
|
||||
translation_placeholders={
|
||||
"device_name": self._device_info.name,
|
||||
"error": str(error),
|
||||
},
|
||||
) from error
|
||||
|
||||
return handler
|
||||
|
@ -184,6 +184,15 @@
|
||||
"exceptions": {
|
||||
"action_call_failed": {
|
||||
"message": "Failed to execute the action call {call_name} on {device_name}: {error}"
|
||||
},
|
||||
"error_communicating_with_device": {
|
||||
"message": "Error communicating with the device {device_name}: {error}"
|
||||
},
|
||||
"error_compiling": {
|
||||
"message": "Error compiling {configuration}; Try again in ESPHome dashboard for more information."
|
||||
},
|
||||
"error_uploading": {
|
||||
"message": "Error during OTA of {configuration}; Try again in ESPHome dashboard for more information."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
from homeassistant.util.enum import try_parse_enum
|
||||
|
||||
from .const import DOMAIN
|
||||
from .coordinator import ESPHomeDashboardCoordinator
|
||||
from .dashboard import async_get_dashboard
|
||||
from .domain_data import DomainData
|
||||
@ -201,16 +202,23 @@ class ESPHomeDashboardUpdateEntity(
|
||||
api = coordinator.api
|
||||
device = coordinator.data.get(self._device_info.name)
|
||||
assert device is not None
|
||||
configuration = device["configuration"]
|
||||
try:
|
||||
if not await api.compile(device["configuration"]):
|
||||
if not await api.compile(configuration):
|
||||
raise HomeAssistantError(
|
||||
f"Error compiling {device['configuration']}; "
|
||||
"Try again in ESPHome dashboard for more information."
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="error_compiling",
|
||||
translation_placeholders={
|
||||
"configuration": configuration,
|
||||
},
|
||||
)
|
||||
if not await api.upload(device["configuration"], "OTA"):
|
||||
if not await api.upload(configuration, "OTA"):
|
||||
raise HomeAssistantError(
|
||||
f"Error updating {device['configuration']} via OTA; "
|
||||
"Try again in ESPHome dashboard for more information."
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="error_uploading",
|
||||
translation_placeholders={
|
||||
"configuration": configuration,
|
||||
},
|
||||
)
|
||||
finally:
|
||||
await self.coordinator.async_request_refresh()
|
||||
|
Loading…
x
Reference in New Issue
Block a user