Enable package camera by default for UniFi Protect (#63985)
This commit is contained in:
parent
6473069be1
commit
f034ea5b4b
6 changed files with 46 additions and 8 deletions
|
@ -40,7 +40,9 @@ def get_camera_channels(
|
||||||
|
|
||||||
is_default = True
|
is_default = True
|
||||||
for channel in camera.channels:
|
for channel in camera.channels:
|
||||||
if channel.is_rtsp_enabled:
|
if channel.is_package:
|
||||||
|
yield camera, channel, True
|
||||||
|
elif channel.is_rtsp_enabled:
|
||||||
yield camera, channel, is_default
|
yield camera, channel, is_default
|
||||||
is_default = False
|
is_default = False
|
||||||
|
|
||||||
|
@ -60,6 +62,8 @@ async def async_setup_entry(
|
||||||
|
|
||||||
entities = []
|
entities = []
|
||||||
for camera, channel, is_default in get_camera_channels(data.api):
|
for camera, channel, is_default in get_camera_channels(data.api):
|
||||||
|
# do not enable streaming for package camera
|
||||||
|
# 2 FPS causes a lot of buferring
|
||||||
entities.append(
|
entities.append(
|
||||||
ProtectCamera(
|
ProtectCamera(
|
||||||
data,
|
data,
|
||||||
|
@ -67,11 +71,11 @@ async def async_setup_entry(
|
||||||
channel,
|
channel,
|
||||||
is_default,
|
is_default,
|
||||||
True,
|
True,
|
||||||
disable_stream,
|
disable_stream or channel.is_package,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if channel.is_rtsp_enabled:
|
if channel.is_rtsp_enabled and not channel.is_package:
|
||||||
entities.append(
|
entities.append(
|
||||||
ProtectCamera(
|
ProtectCamera(
|
||||||
data,
|
data,
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/unifiprotect",
|
"documentation": "https://www.home-assistant.io/integrations/unifiprotect",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"pyunifiprotect==1.6.1"
|
"pyunifiprotect==1.6.2"
|
||||||
],
|
],
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"http"
|
"http"
|
||||||
|
|
|
@ -48,7 +48,7 @@ INFRARED_MODES = [
|
||||||
|
|
||||||
CHIME_TYPES = [
|
CHIME_TYPES = [
|
||||||
{"id": ChimeType.NONE.value, "name": "None"},
|
{"id": ChimeType.NONE.value, "name": "None"},
|
||||||
{"id": ChimeType.MECHINCAL.value, "name": "Mechanical"},
|
{"id": ChimeType.MECHANICAL.value, "name": "Mechanical"},
|
||||||
{"id": ChimeType.DIGITAL.value, "name": "Digital"},
|
{"id": ChimeType.DIGITAL.value, "name": "Digital"},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -2015,7 +2015,7 @@ pytrafikverket==0.1.6.2
|
||||||
pyudev==0.22.0
|
pyudev==0.22.0
|
||||||
|
|
||||||
# homeassistant.components.unifiprotect
|
# homeassistant.components.unifiprotect
|
||||||
pyunifiprotect==1.6.1
|
pyunifiprotect==1.6.2
|
||||||
|
|
||||||
# homeassistant.components.uptimerobot
|
# homeassistant.components.uptimerobot
|
||||||
pyuptimerobot==21.11.0
|
pyuptimerobot==21.11.0
|
||||||
|
|
|
@ -1240,7 +1240,7 @@ pytrafikverket==0.1.6.2
|
||||||
pyudev==0.22.0
|
pyudev==0.22.0
|
||||||
|
|
||||||
# homeassistant.components.unifiprotect
|
# homeassistant.components.unifiprotect
|
||||||
pyunifiprotect==1.6.1
|
pyunifiprotect==1.6.2
|
||||||
|
|
||||||
# homeassistant.components.uptimerobot
|
# homeassistant.components.uptimerobot
|
||||||
pyuptimerobot==21.11.0
|
pyuptimerobot==21.11.0
|
||||||
|
|
|
@ -259,16 +259,37 @@ async def test_basic_setup(
|
||||||
camera_no_channels.channels[1].is_rtsp_enabled = False
|
camera_no_channels.channels[1].is_rtsp_enabled = False
|
||||||
camera_no_channels.channels[2].is_rtsp_enabled = False
|
camera_no_channels.channels[2].is_rtsp_enabled = False
|
||||||
|
|
||||||
|
camera_package = mock_camera.copy(deep=True)
|
||||||
|
camera_package._api = mock_entry.api
|
||||||
|
camera_package.channels[0]._api = mock_entry.api
|
||||||
|
camera_package.channels[1]._api = mock_entry.api
|
||||||
|
camera_package.channels[2]._api = mock_entry.api
|
||||||
|
camera_package.name = "Test Camera 5"
|
||||||
|
camera_package.id = "test_package"
|
||||||
|
camera_package.channels[0].is_rtsp_enabled = True
|
||||||
|
camera_package.channels[0].name = "High"
|
||||||
|
camera_package.channels[0].rtsp_alias = "test_high_alias"
|
||||||
|
camera_package.channels[1].is_rtsp_enabled = False
|
||||||
|
camera_package.channels[2].is_rtsp_enabled = False
|
||||||
|
package_channel = camera_package.channels[0].copy(deep=True)
|
||||||
|
package_channel.is_rtsp_enabled = False
|
||||||
|
package_channel.name = "Package Camera"
|
||||||
|
package_channel.id = 3
|
||||||
|
package_channel.fps = 2
|
||||||
|
package_channel.rtsp_alias = "test_package_alias"
|
||||||
|
camera_package.channels.append(package_channel)
|
||||||
|
|
||||||
mock_entry.api.bootstrap.cameras = {
|
mock_entry.api.bootstrap.cameras = {
|
||||||
camera_high_only.id: camera_high_only,
|
camera_high_only.id: camera_high_only,
|
||||||
camera_medium_only.id: camera_medium_only,
|
camera_medium_only.id: camera_medium_only,
|
||||||
camera_all_channels.id: camera_all_channels,
|
camera_all_channels.id: camera_all_channels,
|
||||||
camera_no_channels.id: camera_no_channels,
|
camera_no_channels.id: camera_no_channels,
|
||||||
|
camera_package.id: camera_package,
|
||||||
}
|
}
|
||||||
await hass.config_entries.async_setup(mock_entry.entry.entry_id)
|
await hass.config_entries.async_setup(mock_entry.entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert_entity_counts(hass, Platform.CAMERA, 11, 4)
|
assert_entity_counts(hass, Platform.CAMERA, 14, 6)
|
||||||
|
|
||||||
# test camera 1
|
# test camera 1
|
||||||
entity_id = validate_default_camera_entity(hass, camera_high_only, 0)
|
entity_id = validate_default_camera_entity(hass, camera_high_only, 0)
|
||||||
|
@ -316,6 +337,19 @@ async def test_basic_setup(
|
||||||
hass, camera_no_channels, 0, entity_id, features=0
|
hass, camera_no_channels, 0, entity_id, features=0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# test camera 5
|
||||||
|
entity_id = validate_default_camera_entity(hass, camera_package, 0)
|
||||||
|
await validate_rtsps_camera_state(hass, camera_package, 0, entity_id)
|
||||||
|
|
||||||
|
entity_id = validate_rtsp_camera_entity(hass, camera_package, 0)
|
||||||
|
await enable_entity(hass, mock_entry.entry.entry_id, entity_id)
|
||||||
|
await validate_rtsp_camera_state(hass, camera_package, 0, entity_id)
|
||||||
|
|
||||||
|
entity_id = validate_default_camera_entity(hass, camera_package, 3)
|
||||||
|
await validate_no_stream_camera_state(
|
||||||
|
hass, camera_package, 3, entity_id, features=0
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_missing_channels(
|
async def test_missing_channels(
|
||||||
hass: HomeAssistant, mock_entry: MockEntityFixture, mock_camera: ProtectCamera
|
hass: HomeAssistant, mock_entry: MockEntityFixture, mock_camera: ProtectCamera
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue