Update ONVIF component to SUPPORT_STREAM (#22569)
* Update Onvif component to SUPPORT_STREAM * Update camera.py * Update camera.py * Update camera.py Remove extra spaces. * lookup URL when camera is added to hass and add extra guardspull/22688/head
parent
de16059365
commit
2e61ead4fd
|
@ -13,7 +13,8 @@ import voluptuous as vol
|
|||
from homeassistant.const import (
|
||||
CONF_NAME, CONF_HOST, CONF_USERNAME, CONF_PASSWORD, CONF_PORT,
|
||||
ATTR_ENTITY_ID)
|
||||
from homeassistant.components.camera import Camera, PLATFORM_SCHEMA
|
||||
from homeassistant.components.camera import (
|
||||
Camera, PLATFORM_SCHEMA, SUPPORT_STREAM)
|
||||
from homeassistant.components.camera.const import DOMAIN
|
||||
from homeassistant.components.ffmpeg import (
|
||||
DATA_FFMPEG, CONF_EXTRA_ARGUMENTS)
|
||||
|
@ -187,13 +188,14 @@ class ONVIFHassCamera(Camera):
|
|||
self.hass.data[ONVIF_DATA] = {}
|
||||
self.hass.data[ONVIF_DATA][ENTITIES] = []
|
||||
self.hass.data[ONVIF_DATA][ENTITIES].append(self)
|
||||
await self.hass.async_add_executor_job(self.obtain_input_uri)
|
||||
|
||||
async def async_camera_image(self):
|
||||
"""Return a still image response from the camera."""
|
||||
from haffmpeg.tools import ImageFrame, IMAGE_JPEG
|
||||
|
||||
if not self._input:
|
||||
await self.hass.async_add_job(self.obtain_input_uri)
|
||||
await self.hass.async_add_executor_job(self.obtain_input_uri)
|
||||
if not self._input:
|
||||
return None
|
||||
|
||||
|
@ -210,7 +212,7 @@ class ONVIFHassCamera(Camera):
|
|||
from haffmpeg.camera import CameraMjpeg
|
||||
|
||||
if not self._input:
|
||||
await self.hass.async_add_job(self.obtain_input_uri)
|
||||
await self.hass.async_add_executor_job(self.obtain_input_uri)
|
||||
if not self._input:
|
||||
return None
|
||||
|
||||
|
@ -228,6 +230,18 @@ class ONVIFHassCamera(Camera):
|
|||
finally:
|
||||
await stream.close()
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Return supported features."""
|
||||
if self._input:
|
||||
return SUPPORT_STREAM
|
||||
return 0
|
||||
|
||||
@property
|
||||
def stream_source(self):
|
||||
"""Return the stream source."""
|
||||
return self._input
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of this camera."""
|
||||
|
|
Loading…
Reference in New Issue