mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Updated UVC camera component to support SSL connections (#18829)
This commit is contained in:
parent
c23792d1fb
commit
29f15393b1
@ -10,12 +10,12 @@ import socket
|
|||||||
import requests
|
import requests
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import CONF_PORT
|
from homeassistant.const import CONF_PORT, CONF_SSL
|
||||||
from homeassistant.components.camera import Camera, PLATFORM_SCHEMA
|
from homeassistant.components.camera import Camera, PLATFORM_SCHEMA
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.exceptions import PlatformNotReady
|
from homeassistant.exceptions import PlatformNotReady
|
||||||
|
|
||||||
REQUIREMENTS = ['uvcclient==0.10.1']
|
REQUIREMENTS = ['uvcclient==0.11.0']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -25,12 +25,14 @@ CONF_PASSWORD = 'password'
|
|||||||
|
|
||||||
DEFAULT_PASSWORD = 'ubnt'
|
DEFAULT_PASSWORD = 'ubnt'
|
||||||
DEFAULT_PORT = 7080
|
DEFAULT_PORT = 7080
|
||||||
|
DEFAULT_SSL = False
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
vol.Required(CONF_NVR): cv.string,
|
vol.Required(CONF_NVR): cv.string,
|
||||||
vol.Required(CONF_KEY): cv.string,
|
vol.Required(CONF_KEY): cv.string,
|
||||||
vol.Optional(CONF_PASSWORD, default=DEFAULT_PASSWORD): cv.string,
|
vol.Optional(CONF_PASSWORD, default=DEFAULT_PASSWORD): cv.string,
|
||||||
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
|
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
|
||||||
|
vol.Optional(CONF_SSL, default=DEFAULT_SSL): cv.boolean,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@ -40,11 +42,12 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
key = config[CONF_KEY]
|
key = config[CONF_KEY]
|
||||||
password = config[CONF_PASSWORD]
|
password = config[CONF_PASSWORD]
|
||||||
port = config[CONF_PORT]
|
port = config[CONF_PORT]
|
||||||
|
ssl = config[CONF_SSL]
|
||||||
|
|
||||||
from uvcclient import nvr
|
from uvcclient import nvr
|
||||||
try:
|
try:
|
||||||
# Exceptions may be raised in all method calls to the nvr library.
|
# Exceptions may be raised in all method calls to the nvr library.
|
||||||
nvrconn = nvr.UVCRemote(addr, port, key)
|
nvrconn = nvr.UVCRemote(addr, port, key, ssl=ssl)
|
||||||
cameras = nvrconn.index()
|
cameras = nvrconn.index()
|
||||||
|
|
||||||
identifier = 'id' if nvrconn.server_version >= (3, 2, 0) else 'uuid'
|
identifier = 'id' if nvrconn.server_version >= (3, 2, 0) else 'uuid'
|
||||||
|
@ -1575,7 +1575,7 @@ upsmychoice==1.0.6
|
|||||||
uscisstatus==0.1.1
|
uscisstatus==0.1.1
|
||||||
|
|
||||||
# homeassistant.components.camera.uvc
|
# homeassistant.components.camera.uvc
|
||||||
uvcclient==0.10.1
|
uvcclient==0.11.0
|
||||||
|
|
||||||
# homeassistant.components.climate.venstar
|
# homeassistant.components.climate.venstar
|
||||||
venstarcolortouch==0.6
|
venstarcolortouch==0.6
|
||||||
|
@ -255,7 +255,7 @@ srpenergy==1.0.5
|
|||||||
statsd==3.2.1
|
statsd==3.2.1
|
||||||
|
|
||||||
# homeassistant.components.camera.uvc
|
# homeassistant.components.camera.uvc
|
||||||
uvcclient==0.10.1
|
uvcclient==0.11.0
|
||||||
|
|
||||||
# homeassistant.components.vultr
|
# homeassistant.components.vultr
|
||||||
vultr==0.1.2
|
vultr==0.1.2
|
||||||
|
@ -55,7 +55,12 @@ class TestUVCSetup(unittest.TestCase):
|
|||||||
assert setup_component(self.hass, 'camera', {'camera': config})
|
assert setup_component(self.hass, 'camera', {'camera': config})
|
||||||
|
|
||||||
assert mock_remote.call_count == 1
|
assert mock_remote.call_count == 1
|
||||||
assert mock_remote.call_args == mock.call('foo', 123, 'secret')
|
assert mock_remote.call_args == mock.call(
|
||||||
|
'foo',
|
||||||
|
123,
|
||||||
|
'secret',
|
||||||
|
ssl=False
|
||||||
|
)
|
||||||
mock_uvc.assert_has_calls([
|
mock_uvc.assert_has_calls([
|
||||||
mock.call(mock_remote.return_value, 'id1', 'Front', 'bar'),
|
mock.call(mock_remote.return_value, 'id1', 'Front', 'bar'),
|
||||||
mock.call(mock_remote.return_value, 'id2', 'Back', 'bar'),
|
mock.call(mock_remote.return_value, 'id2', 'Back', 'bar'),
|
||||||
@ -81,7 +86,12 @@ class TestUVCSetup(unittest.TestCase):
|
|||||||
assert setup_component(self.hass, 'camera', {'camera': config})
|
assert setup_component(self.hass, 'camera', {'camera': config})
|
||||||
|
|
||||||
assert mock_remote.call_count == 1
|
assert mock_remote.call_count == 1
|
||||||
assert mock_remote.call_args == mock.call('foo', 7080, 'secret')
|
assert mock_remote.call_args == mock.call(
|
||||||
|
'foo',
|
||||||
|
7080,
|
||||||
|
'secret',
|
||||||
|
ssl=False
|
||||||
|
)
|
||||||
mock_uvc.assert_has_calls([
|
mock_uvc.assert_has_calls([
|
||||||
mock.call(mock_remote.return_value, 'id1', 'Front', 'ubnt'),
|
mock.call(mock_remote.return_value, 'id1', 'Front', 'ubnt'),
|
||||||
mock.call(mock_remote.return_value, 'id2', 'Back', 'ubnt'),
|
mock.call(mock_remote.return_value, 'id2', 'Back', 'ubnt'),
|
||||||
@ -107,7 +117,12 @@ class TestUVCSetup(unittest.TestCase):
|
|||||||
assert setup_component(self.hass, 'camera', {'camera': config})
|
assert setup_component(self.hass, 'camera', {'camera': config})
|
||||||
|
|
||||||
assert mock_remote.call_count == 1
|
assert mock_remote.call_count == 1
|
||||||
assert mock_remote.call_args == mock.call('foo', 7080, 'secret')
|
assert mock_remote.call_args == mock.call(
|
||||||
|
'foo',
|
||||||
|
7080,
|
||||||
|
'secret',
|
||||||
|
ssl=False
|
||||||
|
)
|
||||||
mock_uvc.assert_has_calls([
|
mock_uvc.assert_has_calls([
|
||||||
mock.call(mock_remote.return_value, 'one', 'Front', 'ubnt'),
|
mock.call(mock_remote.return_value, 'one', 'Front', 'ubnt'),
|
||||||
mock.call(mock_remote.return_value, 'two', 'Back', 'ubnt'),
|
mock.call(mock_remote.return_value, 'two', 'Back', 'ubnt'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user