diff --git a/homeassistant/components/unifiprotect/manifest.json b/homeassistant/components/unifiprotect/manifest.json index a70d295fd74..e120e4ada4e 100644 --- a/homeassistant/components/unifiprotect/manifest.json +++ b/homeassistant/components/unifiprotect/manifest.json @@ -3,7 +3,7 @@ "name": "UniFi Protect", "config_flow": true, "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"], "codeowners": ["@briis", "@AngellusMortis", "@bdraco"], "quality_scale": "platinum", diff --git a/homeassistant/components/unifiprotect/switch.py b/homeassistant/components/unifiprotect/switch.py index 9271e87db50..a3626c3082e 100644 --- a/homeassistant/components/unifiprotect/switch.py +++ b/homeassistant/components/unifiprotect/switch.py @@ -137,7 +137,7 @@ CAMERA_SWITCHES: tuple[ProtectSwitchEntityDescription, ...] = ( name="Detections: Person", icon="mdi:walk", 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_set_method="set_person_detection", ), @@ -146,10 +146,19 @@ CAMERA_SWITCHES: tuple[ProtectSwitchEntityDescription, ...] = ( name="Detections: Vehicle", icon="mdi:car", 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_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, ...] = ( diff --git a/requirements_all.txt b/requirements_all.txt index 089a1b1e790..5acc5e46e23 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1974,7 +1974,7 @@ pytrafikverket==0.1.6.2 pyudev==0.22.0 # homeassistant.components.unifiprotect -pyunifiprotect==3.2.0 +pyunifiprotect==3.3.0 # homeassistant.components.uptimerobot pyuptimerobot==22.2.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 1a2da605dae..d506b62fc72 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1288,7 +1288,7 @@ pytrafikverket==0.1.6.2 pyudev==0.22.0 # homeassistant.components.unifiprotect -pyunifiprotect==3.2.0 +pyunifiprotect==3.3.0 # homeassistant.components.uptimerobot pyuptimerobot==22.2.0 diff --git a/tests/components/unifiprotect/test_switch.py b/tests/components/unifiprotect/test_switch.py index 87ffc5683c0..0a3ac92076e 100644 --- a/tests/components/unifiprotect/test_switch.py +++ b/tests/components/unifiprotect/test_switch.py @@ -6,7 +6,7 @@ from unittest.mock import AsyncMock, Mock import pytest 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.switch import ( @@ -26,6 +26,11 @@ from .conftest import ( 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") 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_speaker = 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.led_settings.is_enabled = False camera_obj.hdr_mode = False @@ -244,7 +253,7 @@ async def test_switch_setup_camera_all( 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( Platform.SWITCH, camera, description ) @@ -375,15 +384,12 @@ async def test_switch_camera_ssh( 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( hass: HomeAssistant, camera: Camera, description: ProtectSwitchEntityDescription ): """Tests all simple switches for cameras.""" - if description.name in ("High FPS", "Privacy Mode"): - return - assert description.ufp_set_method is not None camera.__fields__[description.ufp_set_method] = Mock()