mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Add error translations to Blink (#115924)
* Add translations Catch timeout in snap * Grammer cleanup
This commit is contained in:
parent
ddb415b77e
commit
2620443a88
@ -3,7 +3,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Mapping
|
||||
import contextlib
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
@ -97,7 +96,10 @@ class BlinkCamera(CoordinatorEntity[BlinkUpdateCoordinator], Camera):
|
||||
await self._camera.async_arm(True)
|
||||
|
||||
except TimeoutError as er:
|
||||
raise HomeAssistantError("Blink failed to arm camera") from er
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="failed_arm",
|
||||
) from er
|
||||
|
||||
self._camera.motion_enabled = True
|
||||
await self.coordinator.async_refresh()
|
||||
@ -107,7 +109,10 @@ class BlinkCamera(CoordinatorEntity[BlinkUpdateCoordinator], Camera):
|
||||
try:
|
||||
await self._camera.async_arm(False)
|
||||
except TimeoutError as er:
|
||||
raise HomeAssistantError("Blink failed to disarm camera") from er
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="failed_disarm",
|
||||
) from er
|
||||
|
||||
self._camera.motion_enabled = False
|
||||
await self.coordinator.async_refresh()
|
||||
@ -124,8 +129,14 @@ class BlinkCamera(CoordinatorEntity[BlinkUpdateCoordinator], Camera):
|
||||
|
||||
async def trigger_camera(self) -> None:
|
||||
"""Trigger camera to take a snapshot."""
|
||||
with contextlib.suppress(TimeoutError):
|
||||
try:
|
||||
await self._camera.snap_picture()
|
||||
except TimeoutError as er:
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="failed_snap",
|
||||
) from er
|
||||
|
||||
self.async_write_ha_state()
|
||||
|
||||
def camera_image(
|
||||
|
@ -106,16 +106,31 @@
|
||||
},
|
||||
"exceptions": {
|
||||
"integration_not_found": {
|
||||
"message": "Integration \"{target}\" not found in registry"
|
||||
"message": "Integration \"{target}\" not found in registry."
|
||||
},
|
||||
"no_path": {
|
||||
"message": "Can't write to directory {target}, no access to path!"
|
||||
},
|
||||
"cant_write": {
|
||||
"message": "Can't write to file"
|
||||
"message": "Can't write to file."
|
||||
},
|
||||
"not_loaded": {
|
||||
"message": "{target} is not loaded"
|
||||
"message": "{target} is not loaded."
|
||||
},
|
||||
"failed_arm": {
|
||||
"message": "Blink failed to arm camera."
|
||||
},
|
||||
"failed_disarm": {
|
||||
"message": "Blink failed to disarm camera."
|
||||
},
|
||||
"failed_snap": {
|
||||
"message": "Blink failed to snap a picture."
|
||||
},
|
||||
"failed_arm_motion": {
|
||||
"message": "Blink failed to arm camera motion detection."
|
||||
},
|
||||
"failed_disarm_motion": {
|
||||
"message": "Blink failed to disarm camera motion detection."
|
||||
}
|
||||
},
|
||||
"issues": {
|
||||
|
@ -75,7 +75,8 @@ class BlinkSwitch(CoordinatorEntity[BlinkUpdateCoordinator], SwitchEntity):
|
||||
|
||||
except TimeoutError as er:
|
||||
raise HomeAssistantError(
|
||||
"Blink failed to arm camera motion detection"
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="failed_arm_motion",
|
||||
) from er
|
||||
|
||||
await self.coordinator.async_refresh()
|
||||
@ -87,7 +88,8 @@ class BlinkSwitch(CoordinatorEntity[BlinkUpdateCoordinator], SwitchEntity):
|
||||
|
||||
except TimeoutError as er:
|
||||
raise HomeAssistantError(
|
||||
"Blink failed to dis-arm camera motion detection"
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="failed_disarm_motion",
|
||||
) from er
|
||||
|
||||
await self.coordinator.async_refresh()
|
||||
|
Loading…
x
Reference in New Issue
Block a user