mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Fix unifiprotect for 2.0.0-beta2 of UniFi Protect (#69762)
This commit is contained in:
parent
836b051be9
commit
ad29d89484
@ -3,7 +3,7 @@
|
|||||||
"name": "UniFi Protect",
|
"name": "UniFi Protect",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/unifiprotect",
|
"documentation": "https://www.home-assistant.io/integrations/unifiprotect",
|
||||||
"requirements": ["pyunifiprotect==3.2.0", "unifi-discovery==1.1.2"],
|
"requirements": ["pyunifiprotect==3.3.0", "unifi-discovery==1.1.2"],
|
||||||
"dependencies": ["http"],
|
"dependencies": ["http"],
|
||||||
"codeowners": ["@briis", "@AngellusMortis", "@bdraco"],
|
"codeowners": ["@briis", "@AngellusMortis", "@bdraco"],
|
||||||
"quality_scale": "platinum",
|
"quality_scale": "platinum",
|
||||||
|
@ -137,7 +137,7 @@ CAMERA_SWITCHES: tuple[ProtectSwitchEntityDescription, ...] = (
|
|||||||
name="Detections: Person",
|
name="Detections: Person",
|
||||||
icon="mdi:walk",
|
icon="mdi:walk",
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
ufp_required_field="feature_flags.has_smart_detect",
|
ufp_required_field="can_detect_person",
|
||||||
ufp_value="is_person_detection_on",
|
ufp_value="is_person_detection_on",
|
||||||
ufp_set_method="set_person_detection",
|
ufp_set_method="set_person_detection",
|
||||||
),
|
),
|
||||||
@ -146,10 +146,19 @@ CAMERA_SWITCHES: tuple[ProtectSwitchEntityDescription, ...] = (
|
|||||||
name="Detections: Vehicle",
|
name="Detections: Vehicle",
|
||||||
icon="mdi:car",
|
icon="mdi:car",
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
ufp_required_field="feature_flags.has_smart_detect",
|
ufp_required_field="can_detect_vehicle",
|
||||||
ufp_value="is_vehicle_detection_on",
|
ufp_value="is_vehicle_detection_on",
|
||||||
ufp_set_method="set_vehicle_detection",
|
ufp_set_method="set_vehicle_detection",
|
||||||
),
|
),
|
||||||
|
ProtectSwitchEntityDescription(
|
||||||
|
key="smart_face",
|
||||||
|
name="Detections: Face",
|
||||||
|
icon="mdi:human-greeting",
|
||||||
|
entity_category=EntityCategory.CONFIG,
|
||||||
|
ufp_required_field="can_detect_face",
|
||||||
|
ufp_value="is_face_detection_on",
|
||||||
|
ufp_set_method="set_face_detection",
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
SENSE_SWITCHES: tuple[ProtectSwitchEntityDescription, ...] = (
|
SENSE_SWITCHES: tuple[ProtectSwitchEntityDescription, ...] = (
|
||||||
|
@ -1974,7 +1974,7 @@ pytrafikverket==0.1.6.2
|
|||||||
pyudev==0.22.0
|
pyudev==0.22.0
|
||||||
|
|
||||||
# homeassistant.components.unifiprotect
|
# homeassistant.components.unifiprotect
|
||||||
pyunifiprotect==3.2.0
|
pyunifiprotect==3.3.0
|
||||||
|
|
||||||
# homeassistant.components.uptimerobot
|
# homeassistant.components.uptimerobot
|
||||||
pyuptimerobot==22.2.0
|
pyuptimerobot==22.2.0
|
||||||
|
@ -1288,7 +1288,7 @@ pytrafikverket==0.1.6.2
|
|||||||
pyudev==0.22.0
|
pyudev==0.22.0
|
||||||
|
|
||||||
# homeassistant.components.unifiprotect
|
# homeassistant.components.unifiprotect
|
||||||
pyunifiprotect==3.2.0
|
pyunifiprotect==3.3.0
|
||||||
|
|
||||||
# homeassistant.components.uptimerobot
|
# homeassistant.components.uptimerobot
|
||||||
pyuptimerobot==22.2.0
|
pyuptimerobot==22.2.0
|
||||||
|
@ -6,7 +6,7 @@ from unittest.mock import AsyncMock, Mock
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pyunifiprotect.data import Camera, Light
|
from pyunifiprotect.data import Camera, Light
|
||||||
from pyunifiprotect.data.types import RecordingMode, VideoMode
|
from pyunifiprotect.data.types import RecordingMode, SmartDetectObjectType, VideoMode
|
||||||
|
|
||||||
from homeassistant.components.unifiprotect.const import DEFAULT_ATTRIBUTION
|
from homeassistant.components.unifiprotect.const import DEFAULT_ATTRIBUTION
|
||||||
from homeassistant.components.unifiprotect.switch import (
|
from homeassistant.components.unifiprotect.switch import (
|
||||||
@ -26,6 +26,11 @@ from .conftest import (
|
|||||||
ids_from_device_description,
|
ids_from_device_description,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
CAMERA_SWITCHES_NO_FACE = [d for d in CAMERA_SWITCHES if d.name != "Detections: Face"]
|
||||||
|
CAMERA_SWITCHES_NO_EXTRA = [
|
||||||
|
d for d in CAMERA_SWITCHES_NO_FACE if d.name not in ("High FPS", "Privacy Mode")
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="light")
|
@pytest.fixture(name="light")
|
||||||
async def light_fixture(
|
async def light_fixture(
|
||||||
@ -79,6 +84,10 @@ async def camera_fixture(
|
|||||||
camera_obj.feature_flags.has_privacy_mask = True
|
camera_obj.feature_flags.has_privacy_mask = True
|
||||||
camera_obj.feature_flags.has_speaker = True
|
camera_obj.feature_flags.has_speaker = True
|
||||||
camera_obj.feature_flags.has_smart_detect = True
|
camera_obj.feature_flags.has_smart_detect = True
|
||||||
|
camera_obj.feature_flags.smart_detect_types = [
|
||||||
|
SmartDetectObjectType.PERSON,
|
||||||
|
SmartDetectObjectType.VEHICLE,
|
||||||
|
]
|
||||||
camera_obj.is_ssh_enabled = False
|
camera_obj.is_ssh_enabled = False
|
||||||
camera_obj.led_settings.is_enabled = False
|
camera_obj.led_settings.is_enabled = False
|
||||||
camera_obj.hdr_mode = False
|
camera_obj.hdr_mode = False
|
||||||
@ -244,7 +253,7 @@ async def test_switch_setup_camera_all(
|
|||||||
|
|
||||||
entity_registry = er.async_get(hass)
|
entity_registry = er.async_get(hass)
|
||||||
|
|
||||||
for description in CAMERA_SWITCHES:
|
for description in CAMERA_SWITCHES_NO_FACE:
|
||||||
unique_id, entity_id = ids_from_device_description(
|
unique_id, entity_id = ids_from_device_description(
|
||||||
Platform.SWITCH, camera, description
|
Platform.SWITCH, camera, description
|
||||||
)
|
)
|
||||||
@ -375,15 +384,12 @@ async def test_switch_camera_ssh(
|
|||||||
camera.set_ssh.assert_called_with(False)
|
camera.set_ssh.assert_called_with(False)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("description", CAMERA_SWITCHES)
|
@pytest.mark.parametrize("description", CAMERA_SWITCHES_NO_EXTRA)
|
||||||
async def test_switch_camera_simple(
|
async def test_switch_camera_simple(
|
||||||
hass: HomeAssistant, camera: Camera, description: ProtectSwitchEntityDescription
|
hass: HomeAssistant, camera: Camera, description: ProtectSwitchEntityDescription
|
||||||
):
|
):
|
||||||
"""Tests all simple switches for cameras."""
|
"""Tests all simple switches for cameras."""
|
||||||
|
|
||||||
if description.name in ("High FPS", "Privacy Mode"):
|
|
||||||
return
|
|
||||||
|
|
||||||
assert description.ufp_set_method is not None
|
assert description.ufp_set_method is not None
|
||||||
|
|
||||||
camera.__fields__[description.ufp_set_method] = Mock()
|
camera.__fields__[description.ufp_set_method] = Mock()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user