From 5890a7d38c3a7c5a74a455a47ad352b640928a2c Mon Sep 17 00:00:00 2001 From: Christopher Bailey Date: Thu, 29 Feb 2024 21:26:24 -0500 Subject: [PATCH] Add person tracking for UniFi Protect (#111289) --- homeassistant/components/unifiprotect/binary_sensor.py | 9 +++++++++ homeassistant/components/unifiprotect/switch.py | 10 ++++++++++ tests/components/unifiprotect/test_switch.py | 1 + 3 files changed, 20 insertions(+) diff --git a/homeassistant/components/unifiprotect/binary_sensor.py b/homeassistant/components/unifiprotect/binary_sensor.py index 4408075468f..e82a0ef5553 100644 --- a/homeassistant/components/unifiprotect/binary_sensor.py +++ b/homeassistant/components/unifiprotect/binary_sensor.py @@ -273,6 +273,15 @@ CAMERA_SENSORS: tuple[ProtectBinaryEntityDescription, ...] = ( ufp_value="is_glass_break_detection_on", ufp_perm=PermRequired.NO_WRITE, ), + ProtectBinaryEntityDescription( + key="track_person", + name="Tracking: Person", + icon="mdi:walk", + entity_category=EntityCategory.DIAGNOSTIC, + ufp_required_field="is_ptz", + ufp_value="is_person_tracking_enabled", + ufp_perm=PermRequired.NO_WRITE, + ), ) LIGHT_SENSORS: tuple[ProtectBinaryEntityDescription, ...] = ( diff --git a/homeassistant/components/unifiprotect/switch.py b/homeassistant/components/unifiprotect/switch.py index 64890e17d4d..2090e8baef8 100644 --- a/homeassistant/components/unifiprotect/switch.py +++ b/homeassistant/components/unifiprotect/switch.py @@ -298,6 +298,16 @@ CAMERA_SWITCHES: tuple[ProtectSwitchEntityDescription, ...] = ( ufp_set_method="set_glass_break_detection", ufp_perm=PermRequired.WRITE, ), + ProtectSwitchEntityDescription( + key="track_person", + name="Tracking: Person", + icon="mdi:walk", + entity_category=EntityCategory.CONFIG, + ufp_required_field="is_ptz", + ufp_value="is_person_tracking_enabled", + ufp_set_method="set_person_track", + ufp_perm=PermRequired.WRITE, + ), ) PRIVACY_MODE_SWITCH = ProtectSwitchEntityDescription[Camera]( diff --git a/tests/components/unifiprotect/test_switch.py b/tests/components/unifiprotect/test_switch.py index 70a21a324d0..1ad3baf5db1 100644 --- a/tests/components/unifiprotect/test_switch.py +++ b/tests/components/unifiprotect/test_switch.py @@ -37,6 +37,7 @@ CAMERA_SWITCHES_BASIC = [ not d.name.startswith("Detections:") and d.name != "SSH Enabled" and d.name != "Color Night Vision" + and d.name != "Tracking: Person" ) or d.name == "Detections: Motion" or d.name == "Detections: Person"