mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Add camera recording service to blink (#110612)
Add camera clip recording service to blink Revival of #46598 by @fronzbot, therefore: Co-authored-by: Kevin Fronczak <kfronczak@gmail.com>
This commit is contained in:
parent
61b906e29f
commit
4d5ae57390
@ -23,6 +23,7 @@ from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
from .const import (
|
||||
DEFAULT_BRAND,
|
||||
DOMAIN,
|
||||
SERVICE_RECORD,
|
||||
SERVICE_SAVE_RECENT_CLIPS,
|
||||
SERVICE_SAVE_VIDEO,
|
||||
SERVICE_TRIGGER,
|
||||
@ -50,6 +51,7 @@ async def async_setup_entry(
|
||||
async_add_entities(entities)
|
||||
|
||||
platform = entity_platform.async_get_current_platform()
|
||||
platform.async_register_entity_service(SERVICE_RECORD, {}, "record")
|
||||
platform.async_register_entity_service(SERVICE_TRIGGER, {}, "trigger_camera")
|
||||
platform.async_register_entity_service(
|
||||
SERVICE_SAVE_RECENT_CLIPS,
|
||||
@ -94,7 +96,6 @@ class BlinkCamera(CoordinatorEntity[BlinkUpdateCoordinator], Camera):
|
||||
"""Enable motion detection for the camera."""
|
||||
try:
|
||||
await self._camera.async_arm(True)
|
||||
|
||||
except TimeoutError as er:
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
@ -127,6 +128,18 @@ class BlinkCamera(CoordinatorEntity[BlinkUpdateCoordinator], Camera):
|
||||
"""Return the camera brand."""
|
||||
return DEFAULT_BRAND
|
||||
|
||||
async def record(self) -> None:
|
||||
"""Trigger camera to record a clip."""
|
||||
try:
|
||||
await self._camera.record()
|
||||
except TimeoutError as er:
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="failed_clip",
|
||||
) from er
|
||||
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def trigger_camera(self) -> None:
|
||||
"""Trigger camera to take a snapshot."""
|
||||
try:
|
||||
|
@ -20,6 +20,7 @@ TYPE_TEMPERATURE = "temperature"
|
||||
TYPE_BATTERY = "battery"
|
||||
TYPE_WIFI_STRENGTH = "wifi_strength"
|
||||
|
||||
SERVICE_RECORD = "record"
|
||||
SERVICE_REFRESH = "blink_update"
|
||||
SERVICE_TRIGGER = "trigger_camera"
|
||||
SERVICE_SAVE_VIDEO = "save_video"
|
||||
|
@ -13,6 +13,7 @@
|
||||
},
|
||||
"services": {
|
||||
"blink_update": "mdi:update",
|
||||
"record": "mdi:video-box",
|
||||
"trigger_camera": "mdi:image-refresh",
|
||||
"save_video": "mdi:file-video",
|
||||
"save_recent_clips": "mdi:file-video",
|
||||
|
@ -8,6 +8,12 @@ blink_update:
|
||||
device:
|
||||
integration: blink
|
||||
|
||||
record:
|
||||
target:
|
||||
entity:
|
||||
integration: blink
|
||||
domain: camera
|
||||
|
||||
trigger_camera:
|
||||
target:
|
||||
entity:
|
||||
|
@ -65,6 +65,10 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"record": {
|
||||
"name": "Record",
|
||||
"description": "Requests camera to record a clip."
|
||||
},
|
||||
"trigger_camera": {
|
||||
"name": "Trigger camera",
|
||||
"description": "Requests camera to take new image."
|
||||
@ -123,6 +127,9 @@
|
||||
"failed_disarm": {
|
||||
"message": "Blink failed to disarm camera."
|
||||
},
|
||||
"failed_clip": {
|
||||
"message": "Blink failed to record a clip."
|
||||
},
|
||||
"failed_snap": {
|
||||
"message": "Blink failed to snap a picture."
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user