Assorted fixes for UniFi Protect (#83032)
This commit is contained in:
parent
e23007322d
commit
6fb9bdec93
7 changed files with 34 additions and 21 deletions
|
@ -30,7 +30,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
|||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DEVICE_CLASS_DETECTION, DISPATCH_ADOPT, DOMAIN
|
||||
from .const import DISPATCH_ADOPT, DOMAIN
|
||||
from .data import ProtectData
|
||||
from .entity import (
|
||||
EventEntityMixin,
|
||||
|
@ -351,7 +351,6 @@ MOTION_SENSORS: tuple[ProtectBinaryEventEntityDescription, ...] = (
|
|||
key="smart_obj_any",
|
||||
name="Object Detected",
|
||||
icon="mdi:eye",
|
||||
device_class=DEVICE_CLASS_DETECTION,
|
||||
ufp_value="is_smart_detected",
|
||||
ufp_required_field="feature_flags.has_smart_detect",
|
||||
ufp_event_obj="last_smart_detect_event",
|
||||
|
@ -360,7 +359,6 @@ MOTION_SENSORS: tuple[ProtectBinaryEventEntityDescription, ...] = (
|
|||
key="smart_obj_person",
|
||||
name="Person Detected",
|
||||
icon="mdi:walk",
|
||||
device_class=DEVICE_CLASS_DETECTION,
|
||||
ufp_value="is_smart_detected",
|
||||
ufp_required_field="can_detect_person",
|
||||
ufp_enabled="is_person_detection_on",
|
||||
|
@ -371,7 +369,6 @@ MOTION_SENSORS: tuple[ProtectBinaryEventEntityDescription, ...] = (
|
|||
key="smart_obj_vehicle",
|
||||
name="Vehicle Detected",
|
||||
icon="mdi:car",
|
||||
device_class=DEVICE_CLASS_DETECTION,
|
||||
ufp_value="is_smart_detected",
|
||||
ufp_required_field="can_detect_vehicle",
|
||||
ufp_enabled="is_vehicle_detection_on",
|
||||
|
@ -381,7 +378,6 @@ MOTION_SENSORS: tuple[ProtectBinaryEventEntityDescription, ...] = (
|
|||
ProtectBinaryEventEntityDescription(
|
||||
key="smart_obj_face",
|
||||
name="Face Detected",
|
||||
device_class=DEVICE_CLASS_DETECTION,
|
||||
icon="mdi:mdi-face",
|
||||
ufp_value="is_smart_detected",
|
||||
ufp_required_field="can_detect_face",
|
||||
|
@ -392,7 +388,6 @@ MOTION_SENSORS: tuple[ProtectBinaryEventEntityDescription, ...] = (
|
|||
ProtectBinaryEventEntityDescription(
|
||||
key="smart_obj_package",
|
||||
name="Package Detected",
|
||||
device_class=DEVICE_CLASS_DETECTION,
|
||||
icon="mdi:package-variant-closed",
|
||||
ufp_value="is_smart_detected",
|
||||
ufp_required_field="can_detect_package",
|
||||
|
@ -402,9 +397,8 @@ MOTION_SENSORS: tuple[ProtectBinaryEventEntityDescription, ...] = (
|
|||
),
|
||||
ProtectBinaryEventEntityDescription(
|
||||
key="smart_audio_any",
|
||||
name="Audio Detected",
|
||||
name="Audio Object Detected",
|
||||
icon="mdi:eye",
|
||||
device_class=DEVICE_CLASS_DETECTION,
|
||||
ufp_value="is_smart_detected",
|
||||
ufp_required_field="feature_flags.has_smart_detect",
|
||||
ufp_event_obj="last_smart_audio_detect_event",
|
||||
|
@ -412,7 +406,6 @@ MOTION_SENSORS: tuple[ProtectBinaryEventEntityDescription, ...] = (
|
|||
ProtectBinaryEventEntityDescription(
|
||||
key="smart_audio_smoke",
|
||||
name="Smoke Alarm Detected",
|
||||
device_class=DEVICE_CLASS_DETECTION,
|
||||
icon="mdi:fire",
|
||||
ufp_value="is_smart_detected",
|
||||
ufp_required_field="can_detect_smoke",
|
||||
|
@ -423,7 +416,6 @@ MOTION_SENSORS: tuple[ProtectBinaryEventEntityDescription, ...] = (
|
|||
ProtectBinaryEventEntityDescription(
|
||||
key="smart_audio_cmonx",
|
||||
name="CO Alarm Detected",
|
||||
device_class=DEVICE_CLASS_DETECTION,
|
||||
icon="mdi:fire",
|
||||
ufp_value="is_smart_detected",
|
||||
ufp_required_field="can_detect_smoke",
|
||||
|
@ -629,4 +621,8 @@ class ProtectEventBinarySensor(EventEntityMixin, BinarySensorEntity):
|
|||
@callback
|
||||
def _async_update_device_from_protect(self, device: ProtectModelWithId) -> None:
|
||||
super()._async_update_device_from_protect(device)
|
||||
self._attr_is_on = self.entity_description.get_ufp_value(self.device)
|
||||
is_on = self.entity_description.get_is_on(device)
|
||||
self._attr_is_on: bool | None = is_on
|
||||
if not is_on:
|
||||
self._event = None
|
||||
self._attr_extra_state_attributes = {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue