diff --git a/homeassistant/components/unifiprotect/binary_sensor.py b/homeassistant/components/unifiprotect/binary_sensor.py index b6aaed8f975..7e66f5efb28 100644 --- a/homeassistant/components/unifiprotect/binary_sensor.py +++ b/homeassistant/components/unifiprotect/binary_sensor.py @@ -175,6 +175,15 @@ CAMERA_SENSORS: tuple[ProtectBinaryEntityDescription, ...] = ( ufp_value="is_vehicle_detection_on", ufp_perm=PermRequired.NO_WRITE, ), + ProtectBinaryEntityDescription( + key="smart_animal", + name="Detections: Animal", + icon="mdi:paw", + entity_category=EntityCategory.DIAGNOSTIC, + ufp_required_field="can_detect_animal", + ufp_value="is_animal_detection_on", + ufp_perm=PermRequired.NO_WRITE, + ), ProtectBinaryEntityDescription( key="smart_package", name="Detections: Package", @@ -453,6 +462,15 @@ EVENT_SENSORS: tuple[ProtectBinaryEventEntityDescription, ...] = ( ufp_enabled="is_vehicle_detection_on", ufp_event_obj="last_vehicle_detect_event", ), + ProtectBinaryEventEntityDescription( + key="smart_obj_animal", + name="Animal Detected", + icon="mdi:paw", + ufp_value="is_animal_currently_detected", + ufp_required_field="can_detect_animal", + ufp_enabled="is_animal_detection_on", + ufp_event_obj="last_animal_detect_event", + ), ProtectBinaryEventEntityDescription( key="smart_obj_package", name="Package Detected", diff --git a/homeassistant/components/unifiprotect/switch.py b/homeassistant/components/unifiprotect/switch.py index d17b208de12..50953e2b8fe 100644 --- a/homeassistant/components/unifiprotect/switch.py +++ b/homeassistant/components/unifiprotect/switch.py @@ -179,6 +179,17 @@ CAMERA_SWITCHES: tuple[ProtectSwitchEntityDescription, ...] = ( ufp_set_method="set_vehicle_detection", ufp_perm=PermRequired.WRITE, ), + ProtectSwitchEntityDescription( + key="smart_animal", + name="Detections: Animal", + icon="mdi:paw", + entity_category=EntityCategory.CONFIG, + ufp_required_field="can_detect_animal", + ufp_value="is_animal_detection_on", + ufp_enabled="is_recording_enabled", + ufp_set_method="set_animal_detection", + ufp_perm=PermRequired.WRITE, + ), ProtectSwitchEntityDescription( key="smart_package", name="Detections: Package", diff --git a/tests/components/unifiprotect/conftest.py b/tests/components/unifiprotect/conftest.py index 9eb1ea312c6..02a1ce3f421 100644 --- a/tests/components/unifiprotect/conftest.py +++ b/tests/components/unifiprotect/conftest.py @@ -216,6 +216,7 @@ def doorbell_fixture(camera: Camera, fixed_now: datetime): doorbell.feature_flags.smart_detect_types = [ SmartDetectObjectType.PERSON, SmartDetectObjectType.VEHICLE, + SmartDetectObjectType.ANIMAL, ] doorbell.has_speaker = True doorbell.feature_flags.has_hdr = True diff --git a/tests/components/unifiprotect/test_binary_sensor.py b/tests/components/unifiprotect/test_binary_sensor.py index dbe8f72b244..b23fd529233 100644 --- a/tests/components/unifiprotect/test_binary_sensor.py +++ b/tests/components/unifiprotect/test_binary_sensor.py @@ -50,11 +50,11 @@ async def test_binary_sensor_camera_remove( ufp.api.bootstrap.nvr.system_info.ustorage = None await init_entry(hass, ufp, [doorbell, unadopted_camera]) - assert_entity_counts(hass, Platform.BINARY_SENSOR, 7, 7) + assert_entity_counts(hass, Platform.BINARY_SENSOR, 8, 8) await remove_entities(hass, ufp, [doorbell, unadopted_camera]) assert_entity_counts(hass, Platform.BINARY_SENSOR, 0, 0) await adopt_devices(hass, ufp, [doorbell, unadopted_camera]) - assert_entity_counts(hass, Platform.BINARY_SENSOR, 7, 7) + assert_entity_counts(hass, Platform.BINARY_SENSOR, 8, 8) async def test_binary_sensor_light_remove( @@ -122,7 +122,7 @@ async def test_binary_sensor_setup_camera_all( ufp.api.bootstrap.nvr.system_info.ustorage = None await init_entry(hass, ufp, [doorbell, unadopted_camera]) - assert_entity_counts(hass, Platform.BINARY_SENSOR, 7, 7) + assert_entity_counts(hass, Platform.BINARY_SENSOR, 8, 8) description = EVENT_SENSORS[0] unique_id, entity_id = ids_from_device_description( @@ -274,7 +274,7 @@ async def test_binary_sensor_update_motion( """Test binary_sensor motion entity.""" await init_entry(hass, ufp, [doorbell, unadopted_camera]) - assert_entity_counts(hass, Platform.BINARY_SENSOR, 13, 13) + assert_entity_counts(hass, Platform.BINARY_SENSOR, 14, 14) _, entity_id = ids_from_device_description( Platform.BINARY_SENSOR, doorbell, EVENT_SENSORS[1] diff --git a/tests/components/unifiprotect/test_switch.py b/tests/components/unifiprotect/test_switch.py index 16e471c2e7a..e03ab81833b 100644 --- a/tests/components/unifiprotect/test_switch.py +++ b/tests/components/unifiprotect/test_switch.py @@ -43,6 +43,7 @@ CAMERA_SWITCHES_BASIC = [ or d.name == "Detections: Motion" or d.name == "Detections: Person" or d.name == "Detections: Vehicle" + or d.name == "Detections: Animal" ] CAMERA_SWITCHES_NO_EXTRA = [ d @@ -58,11 +59,11 @@ async def test_switch_camera_remove( ufp.api.bootstrap.nvr.system_info.ustorage = None await init_entry(hass, ufp, [doorbell, unadopted_camera]) - assert_entity_counts(hass, Platform.SWITCH, 15, 13) + assert_entity_counts(hass, Platform.SWITCH, 16, 14) await remove_entities(hass, ufp, [doorbell, unadopted_camera]) assert_entity_counts(hass, Platform.SWITCH, 2, 2) await adopt_devices(hass, ufp, [doorbell, unadopted_camera]) - assert_entity_counts(hass, Platform.SWITCH, 15, 13) + assert_entity_counts(hass, Platform.SWITCH, 16, 14) async def test_switch_light_remove( @@ -174,7 +175,7 @@ async def test_switch_setup_camera_all( """Test switch entity setup for camera devices (all enabled feature flags).""" await init_entry(hass, ufp, [doorbell]) - assert_entity_counts(hass, Platform.SWITCH, 15, 13) + assert_entity_counts(hass, Platform.SWITCH, 16, 14) for description in CAMERA_SWITCHES_BASIC: unique_id, entity_id = ids_from_device_description( @@ -294,7 +295,7 @@ async def test_switch_camera_ssh( """Tests SSH switch for cameras.""" await init_entry(hass, ufp, [doorbell]) - assert_entity_counts(hass, Platform.SWITCH, 15, 13) + assert_entity_counts(hass, Platform.SWITCH, 16, 14) description = CAMERA_SWITCHES[0] @@ -327,7 +328,7 @@ async def test_switch_camera_simple( """Tests all simple switches for cameras.""" await init_entry(hass, ufp, [doorbell]) - assert_entity_counts(hass, Platform.SWITCH, 15, 13) + assert_entity_counts(hass, Platform.SWITCH, 16, 14) assert description.ufp_set_method is not None @@ -356,7 +357,7 @@ async def test_switch_camera_highfps( """Tests High FPS switch for cameras.""" await init_entry(hass, ufp, [doorbell]) - assert_entity_counts(hass, Platform.SWITCH, 15, 13) + assert_entity_counts(hass, Platform.SWITCH, 16, 14) description = CAMERA_SWITCHES[3] @@ -387,7 +388,7 @@ async def test_switch_camera_privacy( previous_record = doorbell.recording_settings.mode = RecordingMode.DETECTIONS await init_entry(hass, ufp, [doorbell]) - assert_entity_counts(hass, Platform.SWITCH, 15, 13) + assert_entity_counts(hass, Platform.SWITCH, 16, 14) description = PRIVACY_MODE_SWITCH @@ -439,7 +440,7 @@ async def test_switch_camera_privacy_already_on( doorbell.add_privacy_zone() await init_entry(hass, ufp, [doorbell]) - assert_entity_counts(hass, Platform.SWITCH, 15, 13) + assert_entity_counts(hass, Platform.SWITCH, 16, 14) description = PRIVACY_MODE_SWITCH