1 """Camera support for the Skybell HD Doorbell."""
3 from __future__
import annotations
5 from aiohttp
import web
6 from haffmpeg.camera
import CameraMjpeg
16 from .const
import DOMAIN
17 from .coordinator
import SkybellDataUpdateCoordinator
18 from .entity
import SkybellEntity
20 CAMERA_TYPES: tuple[CameraEntityDescription, ...] = (
23 translation_key=
"activity",
27 translation_key=
"camera",
33 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
35 """Set up Skybell camera."""
37 for description
in CAMERA_TYPES:
38 for coordinator
in hass.data[DOMAIN][entry.entry_id]:
39 if description.key ==
"avatar":
47 """A camera implementation for Skybell devices."""
51 coordinator: SkybellDataUpdateCoordinator,
52 description: EntityDescription,
54 """Initialize a camera for a Skybell device."""
55 super().
__init__(coordinator, description)
59 self, width: int |
None =
None, height: int |
None =
None
61 """Get the latest camera image."""
66 """A camera implementation for latest Skybell activity."""
69 self, request: web.Request
70 ) -> web.StreamResponse:
71 """Generate an HTTP MJPEG stream from the latest recorded activity."""
73 url = await self.coordinator.device.async_get_activity_video_url()
74 await stream.open_camera(url, extra_cmd=
"-r 210")
80 await stream.get_reader(),
web.StreamResponse handle_async_mjpeg_stream(self, web.Request request)
bytes|None async_camera_image(self, int|None width=None, int|None height=None)
None __init__(self, SkybellDataUpdateCoordinator coordinator, EntityDescription description)
SkybellDevice _device(self)
FFmpegManager get_ffmpeg_manager(HomeAssistant hass)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)
web.StreamResponse async_aiohttp_proxy_stream(HomeAssistant hass, web.BaseRequest request, aiohttp.StreamReader stream, str|None content_type, int buffer_size=102400, int timeout=10)