Add mjpeg camera stream_source (#86908)
Co-authored-by: J. Nick Koston <nick@koston.org>pull/88041/head^2
parent
4ca0a24f87
commit
d8ec259e9a
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue