From 772a432c4d06bf399485df45afb45cf5c09f9e4a Mon Sep 17 00:00:00 2001 From: Christopher Bailey Date: Sat, 21 Jan 2023 14:38:59 -0500 Subject: [PATCH] Fix edge cases for adding/enabling sensors for UniFi Protect (#86329) Co-authored-by: J. Nick Koston fixes undefined --- homeassistant/components/unifiprotect/binary_sensor.py | 1 + homeassistant/components/unifiprotect/manifest.json | 2 +- homeassistant/components/unifiprotect/switch.py | 7 +++++++ requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/unifiprotect/binary_sensor.py b/homeassistant/components/unifiprotect/binary_sensor.py index 4a3b76581ba..c7893eb45d1 100644 --- a/homeassistant/components/unifiprotect/binary_sensor.py +++ b/homeassistant/components/unifiprotect/binary_sensor.py @@ -346,6 +346,7 @@ EVENT_SENSORS: tuple[ProtectBinaryEventEntityDescription, ...] = ( name="Motion", device_class=BinarySensorDeviceClass.MOTION, ufp_value="is_motion_detected", + ufp_enabled="is_motion_detection_on", ufp_event_obj="last_motion_event", ), ProtectBinaryEventEntityDescription( diff --git a/homeassistant/components/unifiprotect/manifest.json b/homeassistant/components/unifiprotect/manifest.json index de622497a3d..5398016ba63 100644 --- a/homeassistant/components/unifiprotect/manifest.json +++ b/homeassistant/components/unifiprotect/manifest.json @@ -4,7 +4,7 @@ "integration_type": "hub", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/unifiprotect", - "requirements": ["pyunifiprotect==4.6.1", "unifi-discovery==1.1.7"], + "requirements": ["pyunifiprotect==4.6.2", "unifi-discovery==1.1.7"], "dependencies": ["http", "repairs"], "codeowners": ["@briis", "@AngellusMortis", "@bdraco"], "quality_scale": "platinum", diff --git a/homeassistant/components/unifiprotect/switch.py b/homeassistant/components/unifiprotect/switch.py index fa501f6a364..63ae4419235 100644 --- a/homeassistant/components/unifiprotect/switch.py +++ b/homeassistant/components/unifiprotect/switch.py @@ -139,6 +139,7 @@ CAMERA_SWITCHES: tuple[ProtectSwitchEntityDescription, ...] = ( icon="mdi:run-fast", entity_category=EntityCategory.CONFIG, ufp_value="recording_settings.enable_motion_detection", + ufp_enabled="is_recording_enabled", ufp_set_method="set_motion_detection", ufp_perm=PermRequired.WRITE, ), @@ -149,6 +150,7 @@ CAMERA_SWITCHES: tuple[ProtectSwitchEntityDescription, ...] = ( entity_category=EntityCategory.CONFIG, ufp_required_field="can_detect_person", ufp_value="is_person_detection_on", + ufp_enabled="is_recording_enabled", ufp_set_method="set_person_detection", ufp_perm=PermRequired.WRITE, ), @@ -159,6 +161,7 @@ CAMERA_SWITCHES: tuple[ProtectSwitchEntityDescription, ...] = ( entity_category=EntityCategory.CONFIG, ufp_required_field="can_detect_vehicle", ufp_value="is_vehicle_detection_on", + ufp_enabled="is_recording_enabled", ufp_set_method="set_vehicle_detection", ufp_perm=PermRequired.WRITE, ), @@ -169,6 +172,7 @@ CAMERA_SWITCHES: tuple[ProtectSwitchEntityDescription, ...] = ( entity_category=EntityCategory.CONFIG, ufp_required_field="can_detect_face", ufp_value="is_face_detection_on", + ufp_enabled="is_recording_enabled", ufp_set_method="set_face_detection", ufp_perm=PermRequired.WRITE, ), @@ -179,6 +183,7 @@ CAMERA_SWITCHES: tuple[ProtectSwitchEntityDescription, ...] = ( entity_category=EntityCategory.CONFIG, ufp_required_field="can_detect_package", ufp_value="is_package_detection_on", + ufp_enabled="is_recording_enabled", ufp_set_method="set_package_detection", ufp_perm=PermRequired.WRITE, ), @@ -189,6 +194,7 @@ CAMERA_SWITCHES: tuple[ProtectSwitchEntityDescription, ...] = ( entity_category=EntityCategory.CONFIG, ufp_required_field="can_detect_license_plate", ufp_value="is_license_plate_detection_on", + ufp_enabled="is_recording_enabled", ufp_set_method="set_license_plate_detection", ufp_perm=PermRequired.WRITE, ), @@ -199,6 +205,7 @@ CAMERA_SWITCHES: tuple[ProtectSwitchEntityDescription, ...] = ( entity_category=EntityCategory.CONFIG, ufp_required_field="can_detect_smoke", ufp_value="is_smoke_detection_on", + ufp_enabled="is_recording_enabled", ufp_set_method="set_smoke_detection", ufp_perm=PermRequired.WRITE, ), diff --git a/requirements_all.txt b/requirements_all.txt index ea08a97860a..eaa610c09b4 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2140,7 +2140,7 @@ pytrafikverket==0.2.2 pyudev==0.23.2 # homeassistant.components.unifiprotect -pyunifiprotect==4.6.1 +pyunifiprotect==4.6.2 # homeassistant.components.uptimerobot pyuptimerobot==22.2.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 56d8aeee64c..d09ca7ae5d1 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1512,7 +1512,7 @@ pytrafikverket==0.2.2 pyudev==0.23.2 # homeassistant.components.unifiprotect -pyunifiprotect==4.6.1 +pyunifiprotect==4.6.2 # homeassistant.components.uptimerobot pyuptimerobot==22.2.0