mirror of
https://github.com/home-assistant/core.git
synced 2025-07-11 15:27:08 +00:00
Pass in aiohttp session for onvif (#32045)
This commit is contained in:
parent
2c1c395c28
commit
2390a7f365
@ -11,6 +11,7 @@ from haffmpeg.tools import IMAGE_JPEG, ImageFrame
|
|||||||
import onvif
|
import onvif
|
||||||
from onvif import ONVIFCamera, exceptions
|
from onvif import ONVIFCamera, exceptions
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
from zeep.asyncio import AsyncTransport
|
||||||
from zeep.exceptions import Fault
|
from zeep.exceptions import Fault
|
||||||
|
|
||||||
from homeassistant.components.camera import PLATFORM_SCHEMA, SUPPORT_STREAM, Camera
|
from homeassistant.components.camera import PLATFORM_SCHEMA, SUPPORT_STREAM, Camera
|
||||||
@ -25,7 +26,10 @@ from homeassistant.const import (
|
|||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
)
|
)
|
||||||
from homeassistant.exceptions import PlatformNotReady
|
from homeassistant.exceptions import PlatformNotReady
|
||||||
from homeassistant.helpers.aiohttp_client import async_aiohttp_proxy_stream
|
from homeassistant.helpers.aiohttp_client import (
|
||||||
|
async_aiohttp_proxy_stream,
|
||||||
|
async_get_clientsession,
|
||||||
|
)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.service import async_extract_entity_ids
|
from homeassistant.helpers.service import async_extract_entity_ids
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
@ -143,12 +147,15 @@ class ONVIFHassCamera(Camera):
|
|||||||
"Setting up the ONVIF camera device @ '%s:%s'", self._host, self._port
|
"Setting up the ONVIF camera device @ '%s:%s'", self._host, self._port
|
||||||
)
|
)
|
||||||
|
|
||||||
|
session = async_get_clientsession(hass)
|
||||||
|
transport = AsyncTransport(None, session=session)
|
||||||
self._camera = ONVIFCamera(
|
self._camera = ONVIFCamera(
|
||||||
self._host,
|
self._host,
|
||||||
self._port,
|
self._port,
|
||||||
self._username,
|
self._username,
|
||||||
self._password,
|
self._password,
|
||||||
"{}/wsdl/".format(os.path.dirname(onvif.__file__)),
|
"{}/wsdl/".format(os.path.dirname(onvif.__file__)),
|
||||||
|
transport=transport,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_initialize(self):
|
async def async_initialize(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user