mirror of
https://github.com/home-assistant/core.git
synced 2025-07-12 15:57:06 +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 __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
import contextlib
|
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
@ -97,7 +96,10 @@ class BlinkCamera(CoordinatorEntity[BlinkUpdateCoordinator], Camera):
|
|||||||
await self._camera.async_arm(True)
|
await self._camera.async_arm(True)
|
||||||
|
|
||||||
except TimeoutError as er:
|
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
|
self._camera.motion_enabled = True
|
||||||
await self.coordinator.async_refresh()
|
await self.coordinator.async_refresh()
|
||||||
@ -107,7 +109,10 @@ class BlinkCamera(CoordinatorEntity[BlinkUpdateCoordinator], Camera):
|
|||||||
try:
|
try:
|
||||||
await self._camera.async_arm(False)
|
await self._camera.async_arm(False)
|
||||||
except TimeoutError as er:
|
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
|
self._camera.motion_enabled = False
|
||||||
await self.coordinator.async_refresh()
|
await self.coordinator.async_refresh()
|
||||||
@ -124,8 +129,14 @@ class BlinkCamera(CoordinatorEntity[BlinkUpdateCoordinator], Camera):
|
|||||||
|
|
||||||
async def trigger_camera(self) -> None:
|
async def trigger_camera(self) -> None:
|
||||||
"""Trigger camera to take a snapshot."""
|
"""Trigger camera to take a snapshot."""
|
||||||
with contextlib.suppress(TimeoutError):
|
try:
|
||||||
await self._camera.snap_picture()
|
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()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
def camera_image(
|
def camera_image(
|
||||||
|
@ -106,16 +106,31 @@
|
|||||||
},
|
},
|
||||||
"exceptions": {
|
"exceptions": {
|
||||||
"integration_not_found": {
|
"integration_not_found": {
|
||||||
"message": "Integration \"{target}\" not found in registry"
|
"message": "Integration \"{target}\" not found in registry."
|
||||||
},
|
},
|
||||||
"no_path": {
|
"no_path": {
|
||||||
"message": "Can't write to directory {target}, no access to path!"
|
"message": "Can't write to directory {target}, no access to path!"
|
||||||
},
|
},
|
||||||
"cant_write": {
|
"cant_write": {
|
||||||
"message": "Can't write to file"
|
"message": "Can't write to file."
|
||||||
},
|
},
|
||||||
"not_loaded": {
|
"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": {
|
"issues": {
|
||||||
|
@ -75,7 +75,8 @@ class BlinkSwitch(CoordinatorEntity[BlinkUpdateCoordinator], SwitchEntity):
|
|||||||
|
|
||||||
except TimeoutError as er:
|
except TimeoutError as er:
|
||||||
raise HomeAssistantError(
|
raise HomeAssistantError(
|
||||||
"Blink failed to arm camera motion detection"
|
translation_domain=DOMAIN,
|
||||||
|
translation_key="failed_arm_motion",
|
||||||
) from er
|
) from er
|
||||||
|
|
||||||
await self.coordinator.async_refresh()
|
await self.coordinator.async_refresh()
|
||||||
@ -87,7 +88,8 @@ class BlinkSwitch(CoordinatorEntity[BlinkUpdateCoordinator], SwitchEntity):
|
|||||||
|
|
||||||
except TimeoutError as er:
|
except TimeoutError as er:
|
||||||
raise HomeAssistantError(
|
raise HomeAssistantError(
|
||||||
"Blink failed to dis-arm camera motion detection"
|
translation_domain=DOMAIN,
|
||||||
|
translation_key="failed_disarm_motion",
|
||||||
) from er
|
) from er
|
||||||
|
|
||||||
await self.coordinator.async_refresh()
|
await self.coordinator.async_refresh()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user