mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Add exception translation in HomeWizard coordinator (#131404)
This commit is contained in:
parent
d4071e7123
commit
904c3291d9
@ -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
|
||||||
|
|
||||||
|
@ -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:
|
||||||
|
@ -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"
|
||||||
|
@ -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,
|
||||||
|
@ -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,
|
||||||
|
@ -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,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user