mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 13:47:35 +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 (
|
from .const import (
|
||||||
DEFAULT_BRAND,
|
DEFAULT_BRAND,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
|
SERVICE_RECORD,
|
||||||
SERVICE_SAVE_RECENT_CLIPS,
|
SERVICE_SAVE_RECENT_CLIPS,
|
||||||
SERVICE_SAVE_VIDEO,
|
SERVICE_SAVE_VIDEO,
|
||||||
SERVICE_TRIGGER,
|
SERVICE_TRIGGER,
|
||||||
@ -50,6 +51,7 @@ async def async_setup_entry(
|
|||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
platform = entity_platform.async_get_current_platform()
|
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_TRIGGER, {}, "trigger_camera")
|
||||||
platform.async_register_entity_service(
|
platform.async_register_entity_service(
|
||||||
SERVICE_SAVE_RECENT_CLIPS,
|
SERVICE_SAVE_RECENT_CLIPS,
|
||||||
@ -94,7 +96,6 @@ class BlinkCamera(CoordinatorEntity[BlinkUpdateCoordinator], Camera):
|
|||||||
"""Enable motion detection for the camera."""
|
"""Enable motion detection for the camera."""
|
||||||
try:
|
try:
|
||||||
await self._camera.async_arm(True)
|
await self._camera.async_arm(True)
|
||||||
|
|
||||||
except TimeoutError as er:
|
except TimeoutError as er:
|
||||||
raise HomeAssistantError(
|
raise HomeAssistantError(
|
||||||
translation_domain=DOMAIN,
|
translation_domain=DOMAIN,
|
||||||
@ -127,6 +128,18 @@ class BlinkCamera(CoordinatorEntity[BlinkUpdateCoordinator], Camera):
|
|||||||
"""Return the camera brand."""
|
"""Return the camera brand."""
|
||||||
return DEFAULT_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:
|
async def trigger_camera(self) -> None:
|
||||||
"""Trigger camera to take a snapshot."""
|
"""Trigger camera to take a snapshot."""
|
||||||
try:
|
try:
|
||||||
|
@ -20,6 +20,7 @@ TYPE_TEMPERATURE = "temperature"
|
|||||||
TYPE_BATTERY = "battery"
|
TYPE_BATTERY = "battery"
|
||||||
TYPE_WIFI_STRENGTH = "wifi_strength"
|
TYPE_WIFI_STRENGTH = "wifi_strength"
|
||||||
|
|
||||||
|
SERVICE_RECORD = "record"
|
||||||
SERVICE_REFRESH = "blink_update"
|
SERVICE_REFRESH = "blink_update"
|
||||||
SERVICE_TRIGGER = "trigger_camera"
|
SERVICE_TRIGGER = "trigger_camera"
|
||||||
SERVICE_SAVE_VIDEO = "save_video"
|
SERVICE_SAVE_VIDEO = "save_video"
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
},
|
},
|
||||||
"services": {
|
"services": {
|
||||||
"blink_update": "mdi:update",
|
"blink_update": "mdi:update",
|
||||||
|
"record": "mdi:video-box",
|
||||||
"trigger_camera": "mdi:image-refresh",
|
"trigger_camera": "mdi:image-refresh",
|
||||||
"save_video": "mdi:file-video",
|
"save_video": "mdi:file-video",
|
||||||
"save_recent_clips": "mdi:file-video",
|
"save_recent_clips": "mdi:file-video",
|
||||||
|
@ -8,6 +8,12 @@ blink_update:
|
|||||||
device:
|
device:
|
||||||
integration: blink
|
integration: blink
|
||||||
|
|
||||||
|
record:
|
||||||
|
target:
|
||||||
|
entity:
|
||||||
|
integration: blink
|
||||||
|
domain: camera
|
||||||
|
|
||||||
trigger_camera:
|
trigger_camera:
|
||||||
target:
|
target:
|
||||||
entity:
|
entity:
|
||||||
|
@ -65,6 +65,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"record": {
|
||||||
|
"name": "Record",
|
||||||
|
"description": "Requests camera to record a clip."
|
||||||
|
},
|
||||||
"trigger_camera": {
|
"trigger_camera": {
|
||||||
"name": "Trigger camera",
|
"name": "Trigger camera",
|
||||||
"description": "Requests camera to take new image."
|
"description": "Requests camera to take new image."
|
||||||
@ -123,6 +127,9 @@
|
|||||||
"failed_disarm": {
|
"failed_disarm": {
|
||||||
"message": "Blink failed to disarm camera."
|
"message": "Blink failed to disarm camera."
|
||||||
},
|
},
|
||||||
|
"failed_clip": {
|
||||||
|
"message": "Blink failed to record a clip."
|
||||||
|
},
|
||||||
"failed_snap": {
|
"failed_snap": {
|
||||||
"message": "Blink failed to snap a picture."
|
"message": "Blink failed to snap a picture."
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user