Skip to content
Snippets Groups Projects
Commit 05a1e11d authored by Dan Smith's avatar Dan Smith
Browse files

Filter out AirCam models in UVC camera platform

The older (unsupported AirCam) models behave differently and also apparently
suffer some under the last release of the NVR that supported them. Since they
are EOL and not supported by current software, filter them out so we don't
break while trying to extract an image from them.
parent d6a14a17
No related branches found
No related tags found
No related merge requests found
...@@ -47,6 +47,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None): ...@@ -47,6 +47,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
_LOGGER.error('Unable to connect to NVR: %s', str(ex)) _LOGGER.error('Unable to connect to NVR: %s', str(ex))
return False return False
# Filter out airCam models, which are not supported in the latest
# version of UnifiVideo and which are EOL by Ubiquiti
cameras = [camera for camera in cameras
if 'airCam' not in nvrconn.get_camera(camera['uuid'])['model']]
add_devices([UnifiVideoCamera(nvrconn, add_devices([UnifiVideoCamera(nvrconn,
camera['uuid'], camera['uuid'],
camera['name']) camera['name'])
......
...@@ -27,10 +27,19 @@ class TestUVCSetup(unittest.TestCase): ...@@ -27,10 +27,19 @@ class TestUVCSetup(unittest.TestCase):
fake_cameras = [ fake_cameras = [
{'uuid': 'one', 'name': 'Front'}, {'uuid': 'one', 'name': 'Front'},
{'uuid': 'two', 'name': 'Back'}, {'uuid': 'two', 'name': 'Back'},
{'uuid': 'three', 'name': 'Old AirCam'},
] ]
def fake_get_camera(uuid):
if uuid == 'three':
return {'model': 'airCam'}
else:
return {'model': 'UVC'}
hass = mock.MagicMock() hass = mock.MagicMock()
add_devices = mock.MagicMock() add_devices = mock.MagicMock()
mock_remote.return_value.index.return_value = fake_cameras mock_remote.return_value.index.return_value = fake_cameras
mock_remote.return_value.get_camera.side_effect = fake_get_camera
self.assertTrue(uvc.setup_platform(hass, config, add_devices)) self.assertTrue(uvc.setup_platform(hass, config, add_devices))
mock_remote.assert_called_once_with('foo', 123, 'secret') mock_remote.assert_called_once_with('foo', 123, 'secret')
add_devices.assert_called_once_with([ add_devices.assert_called_once_with([
...@@ -54,6 +63,7 @@ class TestUVCSetup(unittest.TestCase): ...@@ -54,6 +63,7 @@ class TestUVCSetup(unittest.TestCase):
hass = mock.MagicMock() hass = mock.MagicMock()
add_devices = mock.MagicMock() add_devices = mock.MagicMock()
mock_remote.return_value.index.return_value = fake_cameras mock_remote.return_value.index.return_value = fake_cameras
mock_remote.return_value.get_camera.return_value = {'model': 'UVC'}
self.assertTrue(uvc.setup_platform(hass, config, add_devices)) self.assertTrue(uvc.setup_platform(hass, config, add_devices))
mock_remote.assert_called_once_with('foo', 7080, 'secret') mock_remote.assert_called_once_with('foo', 7080, 'secret')
add_devices.assert_called_once_with([ add_devices.assert_called_once_with([
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment