Add mjpeg camera stream_source (#86908)

Co-authored-by: J. Nick Koston <nick@koston.org>
pull/88041/head^2
Assaf Inbal 2023-02-14 00:12:12 +02:00 committed by GitHub
parent 4ca0a24f87
commit d8ec259e9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -10,6 +10,7 @@ from aiohttp import web
import async_timeout
import requests
from requests.auth import HTTPBasicAuth, HTTPDigestAuth
from yarl import URL
from homeassistant.components.camera import Camera
from homeassistant.config_entries import ConfigEntry
@ -118,6 +119,15 @@ class MjpegCamera(Camera):
if device_info is not None:
self._attr_device_info = device_info
async def stream_source(self) -> str:
"""Return the stream source."""
url = URL(self._mjpeg_url)
if self._username:
url = url.with_user(self._username)
if self._password:
url = url.with_password(self._password)
return str(url)
async def async_camera_image(
self, width: int | None = None, height: int | None = None
) -> bytes | None: