Translate UpdateFailed error in AVM Fritz/BOX Tools (#131466)

translate UpdateFailed error
This commit is contained in:
Michael 2024-11-24 18:32:37 +01:00 committed by GitHub
parent d790a2d74c
commit b7e960f0bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 3 deletions

View File

@ -326,7 +326,11 @@ class FritzBoxTools(DataUpdateCoordinator[UpdateCoordinatorDataType]):
"call_deflections"
] = await self.async_update_call_deflections()
except FRITZ_EXCEPTIONS as ex:
raise UpdateFailed(ex) from ex
raise UpdateFailed(
translation_domain=DOMAIN,
translation_key="update_failed",
translation_placeholders={"error": str(ex)},
) from ex
_LOGGER.debug("enity_data: %s", entity_data)
return entity_data

View File

@ -176,6 +176,9 @@
},
"unable_to_connect": {
"message": "Unable to establish a connection"
},
"update_failed": {
"message": "Error while uptaing the data: {error}"
}
}
}

View File

@ -43,7 +43,7 @@ async def test_sensor_setup(
async def test_sensor_update_fail(
hass: HomeAssistant, fc_class_mock, fh_class_mock
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, fc_class_mock, fh_class_mock
) -> None:
"""Test failed update of Fritz!Tools sensors."""
@ -53,10 +53,12 @@ async def test_sensor_update_fail(
await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
fc_class_mock().call_action_side_effect(FritzConnectionException)
fc_class_mock().call_action_side_effect(FritzConnectionException("Boom"))
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(seconds=300))
await hass.async_block_till_done(wait_background_tasks=True)
assert "Error while uptaing the data: Boom" in caplog.text
sensors = hass.states.async_all(SENSOR_DOMAIN)
for sensor in sensors:
assert sensor.state == STATE_UNAVAILABLE