Add exception translation in HomeWizard coordinator (#131404)

This commit is contained in:
Duco Sebel 2024-11-25 10:23:07 +01:00 committed by GitHub
parent d4071e7123
commit 904c3291d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 13 additions and 14 deletions

View File

@ -66,7 +66,9 @@ class HWEnergyDeviceUpdateCoordinator(DataUpdateCoordinator[DeviceResponseEntry]
) )
except RequestError as ex: except RequestError as ex:
raise UpdateFailed(ex) from ex raise UpdateFailed(
ex, translation_domain=DOMAIN, translation_key="communication_error"
) from ex
except DisabledError as ex: except DisabledError as ex:
if not self.api_disabled: if not self.api_disabled:
@ -79,7 +81,9 @@ class HWEnergyDeviceUpdateCoordinator(DataUpdateCoordinator[DeviceResponseEntry]
self.config_entry.entry_id self.config_entry.entry_id
) )
raise UpdateFailed(ex) from ex raise UpdateFailed(
ex, translation_domain=DOMAIN, translation_key="api_disabled"
) from ex
self.api_disabled = False self.api_disabled = False

View File

@ -67,12 +67,7 @@ rules:
entity-device-class: done entity-device-class: done
entity-disabled-by-default: done entity-disabled-by-default: done
entity-translations: done entity-translations: done
exception-translations: exception-translations: done
status: todo
comment: |
While the integration provides some of the exception translations, the
translation for the error raised in the update error of the coordinator
is missing.
icon-translations: done icon-translations: done
reconfiguration-flow: todo reconfiguration-flow: todo
repair-issues: repair-issues:

View File

@ -20,7 +20,7 @@
} }
}, },
"error": { "error": {
"api_not_enabled": "The API is not enabled. Enable API in the HomeWizard Energy App under settings", "api_not_enabled": "The local API is disabled. Go to the HomeWizard Energy app and enable the API in the device settings.",
"network_error": "Device unreachable, make sure that you have entered the correct IP address and that the device is available in your network" "network_error": "Device unreachable, make sure that you have entered the correct IP address and that the device is available in your network"
}, },
"abort": { "abort": {
@ -123,7 +123,7 @@
}, },
"exceptions": { "exceptions": {
"api_disabled": { "api_disabled": {
"message": "The local API of the HomeWizard device is disabled" "message": "The local API is disabled."
}, },
"communication_error": { "communication_error": {
"message": "An error occurred while communicating with HomeWizard device" "message": "An error occurred while communicating with HomeWizard device"

View File

@ -79,7 +79,7 @@ async def test_identify_button(
with pytest.raises( with pytest.raises(
HomeAssistantError, HomeAssistantError,
match=r"^The local API of the HomeWizard device is disabled$", match=r"^The local API is disabled$",
): ):
await hass.services.async_call( await hass.services.async_call(
button.DOMAIN, button.DOMAIN,

View File

@ -85,7 +85,7 @@ async def test_number_entities(
mock_homewizardenergy.state_set.side_effect = DisabledError mock_homewizardenergy.state_set.side_effect = DisabledError
with pytest.raises( with pytest.raises(
HomeAssistantError, HomeAssistantError,
match=r"^The local API of the HomeWizard device is disabled$", match=r"^The local API is disabled$",
): ):
await hass.services.async_call( await hass.services.async_call(
number.DOMAIN, number.DOMAIN,

View File

@ -174,7 +174,7 @@ async def test_switch_entities(
with pytest.raises( with pytest.raises(
HomeAssistantError, HomeAssistantError,
match=r"^The local API of the HomeWizard device is disabled$", match=r"^The local API is disabled$",
): ):
await hass.services.async_call( await hass.services.async_call(
switch.DOMAIN, switch.DOMAIN,
@ -185,7 +185,7 @@ async def test_switch_entities(
with pytest.raises( with pytest.raises(
HomeAssistantError, HomeAssistantError,
match=r"^The local API of the HomeWizard device is disabled$", match=r"^The local API is disabled$",
): ):
await hass.services.async_call( await hass.services.async_call(
switch.DOMAIN, switch.DOMAIN,