Skip to content

Commit

Permalink
Fix edge cases for adding/enabling sensors for UniFi Protect (home-as…
Browse files Browse the repository at this point in the history
…sistant#86329)

Co-authored-by: J. Nick Koston <nick@koston.org>
fixes undefined
  • Loading branch information
AngellusMortis authored Jan 21, 2023
1 parent 5306883 commit 772a432
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions homeassistant/components/unifiprotect/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ class 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(
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/unifiprotect/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 7 additions & 0 deletions homeassistant/components/unifiprotect/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ async def _set_highfps(obj: Camera, value: bool) -> None:
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,
),
Expand All @@ -149,6 +150,7 @@ async def _set_highfps(obj: Camera, value: bool) -> None:
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,
),
Expand All @@ -159,6 +161,7 @@ async def _set_highfps(obj: Camera, value: bool) -> None:
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,
),
Expand All @@ -169,6 +172,7 @@ async def _set_highfps(obj: Camera, value: bool) -> None:
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,
),
Expand All @@ -179,6 +183,7 @@ async def _set_highfps(obj: Camera, value: bool) -> None:
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,
),
Expand All @@ -189,6 +194,7 @@ async def _set_highfps(obj: Camera, value: bool) -> None:
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,
),
Expand All @@ -199,6 +205,7 @@ async def _set_highfps(obj: Camera, value: bool) -> None:
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,
),
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 772a432

Please sign in to comment.