Add translations for devolo Home Network exceptions (#105755)
* Add translations for devolo Home Network exceptions * Add translations for ConfigEntryAuthFailed * Update homeassistant/components/devolo_home_network/switch.py Co-authored-by: Erik Montnemery <erik@montnemery.com> --------- Co-authored-by: Erik Montnemery <erik@montnemery.com>pull/113569/head
parent
53a76fc792
commit
b96bceadfa
|
@ -69,7 +69,10 @@ async def async_setup_entry( # noqa: C901
|
|||
)
|
||||
except DeviceNotFound as err:
|
||||
raise ConfigEntryNotReady(
|
||||
f"Unable to connect to {entry.data[CONF_IP_ADDRESS]}"
|
||||
f"Unable to connect to {entry.data[CONF_IP_ADDRESS]}",
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="connection_failed",
|
||||
translation_placeholders={"ip_address": entry.data[CONF_IP_ADDRESS]},
|
||||
) from err
|
||||
|
||||
hass.data[DOMAIN][entry.entry_id] = {"device": device}
|
||||
|
@ -101,7 +104,9 @@ async def async_setup_entry( # noqa: C901
|
|||
except DeviceUnavailable as err:
|
||||
raise UpdateFailed(err) from err
|
||||
except DevicePasswordProtected as err:
|
||||
raise ConfigEntryAuthFailed(err) from err
|
||||
raise ConfigEntryAuthFailed(
|
||||
err, translation_domain=DOMAIN, translation_key="password_wrong"
|
||||
) from err
|
||||
|
||||
async def async_update_led_status() -> bool:
|
||||
"""Fetch data from API endpoint."""
|
||||
|
|
|
@ -117,9 +117,15 @@ class DevoloButtonEntity(DevoloEntity, ButtonEntity):
|
|||
except DevicePasswordProtected as ex:
|
||||
self.entry.async_start_reauth(self.hass)
|
||||
raise HomeAssistantError(
|
||||
f"Device {self.entry.title} require re-authenticatication to set or change the password"
|
||||
f"Device {self.entry.title} require re-authenticatication to set or change the password",
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="password_protected",
|
||||
translation_placeholders={"title": self.entry.title},
|
||||
) from ex
|
||||
except DeviceUnavailable as ex:
|
||||
raise HomeAssistantError(
|
||||
f"Device {self.entry.title} did not respond"
|
||||
f"Device {self.entry.title} did not respond",
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="no_response",
|
||||
translation_placeholders={"title": self.entry.title},
|
||||
) from ex
|
||||
|
|
|
@ -78,5 +78,19 @@
|
|||
"name": "Enable LEDs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"exceptions": {
|
||||
"connection_failed": {
|
||||
"message": "Unable to connect to {ip_address}"
|
||||
},
|
||||
"no_response": {
|
||||
"message": "Device {title} did not respond"
|
||||
},
|
||||
"password_protected": {
|
||||
"message": "Device {title} requires re-authenticatication to set or change the password"
|
||||
},
|
||||
"password_wrong": {
|
||||
"message": "The used password is wrong"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,7 +109,10 @@ class DevoloSwitchEntity(DevoloCoordinatorEntity[_DataT], SwitchEntity):
|
|||
except DevicePasswordProtected as ex:
|
||||
self.entry.async_start_reauth(self.hass)
|
||||
raise HomeAssistantError(
|
||||
f"Device {self.entry.title} require re-authenticatication to set or change the password"
|
||||
f"Device {self.entry.title} require re-authenticatication to set or change the password",
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="password_protected",
|
||||
translation_placeholders={"title": self.entry.title},
|
||||
) from ex
|
||||
except DeviceUnavailable:
|
||||
pass # The coordinator will handle this
|
||||
|
@ -122,7 +125,10 @@ class DevoloSwitchEntity(DevoloCoordinatorEntity[_DataT], SwitchEntity):
|
|||
except DevicePasswordProtected as ex:
|
||||
self.entry.async_start_reauth(self.hass)
|
||||
raise HomeAssistantError(
|
||||
f"Device {self.entry.title} require re-authenticatication to set or change the password"
|
||||
f"Device {self.entry.title} require re-authenticatication to set or change the password",
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="password_protected",
|
||||
translation_placeholders={"title": self.entry.title},
|
||||
) from ex
|
||||
except DeviceUnavailable:
|
||||
pass # The coordinator will handle this
|
||||
|
|
|
@ -117,9 +117,15 @@ class DevoloUpdateEntity(DevoloCoordinatorEntity, UpdateEntity):
|
|||
except DevicePasswordProtected as ex:
|
||||
self.entry.async_start_reauth(self.hass)
|
||||
raise HomeAssistantError(
|
||||
f"Device {self.entry.title} require re-authentication to set or change the password"
|
||||
f"Device {self.entry.title} require re-authenticatication to set or change the password",
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="password_protected",
|
||||
translation_placeholders={"title": self.entry.title},
|
||||
) from ex
|
||||
except DeviceUnavailable as ex:
|
||||
raise HomeAssistantError(
|
||||
f"Device {self.entry.title} did not respond"
|
||||
f"Device {self.entry.title} did not respond",
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="no_response",
|
||||
translation_placeholders={"title": self.entry.title},
|
||||
) from ex
|
||||
|
|
Loading…
Reference in New Issue