Skip to content

Commit 5ff3233

Browse files
authored
Remove license plate event sensor (home-assistant#157196)
1 parent 22daed0 commit 5ff3233

File tree

3 files changed

+4
-621
lines changed

3 files changed

+4
-621
lines changed

homeassistant/components/unifiprotect/sensor.py

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
ProtectAdoptableDeviceModel,
1818
ProtectDeviceModel,
1919
Sensor,
20-
SmartDetectObjectType,
2120
)
2221

2322
from homeassistant.components.sensor import (
@@ -533,18 +532,6 @@ def _get_alarm_sound(obj: Sensor) -> str:
533532
),
534533
)
535534

536-
LICENSE_PLATE_EVENT_SENSORS: tuple[ProtectSensorEventEntityDescription, ...] = (
537-
ProtectSensorEventEntityDescription(
538-
key="smart_obj_licenseplate",
539-
icon="mdi:car",
540-
translation_key="license_plate_detected",
541-
ufp_obj_type=SmartDetectObjectType.LICENSE_PLATE,
542-
ufp_required_field="can_detect_license_plate",
543-
ufp_event_obj="last_license_plate_detect_event",
544-
),
545-
)
546-
547-
548535
LIGHT_SENSORS: tuple[ProtectSensorEntityDescription, ...] = (
549536
ProtectSensorEntityDescription(
550537
key="motion_last_trip_time",
@@ -680,20 +667,6 @@ def _async_event_entities(
680667
camera.display_name,
681668
)
682669

683-
if not camera.feature_flags.has_smart_detect:
684-
continue
685-
686-
for event_desc in LICENSE_PLATE_EVENT_SENSORS:
687-
if not event_desc.has_required(camera):
688-
continue
689-
690-
entities.append(ProtectLicensePlateEventSensor(data, camera, event_desc))
691-
_LOGGER.debug(
692-
"Adding sensor entity %s for %s",
693-
description.name,
694-
camera.display_name,
695-
)
696-
697670
return entities
698671

699672

@@ -738,40 +711,3 @@ class ProtectEventSensor(EventEntityMixin, SensorEntity):
738711
"_attr_native_value",
739712
"_attr_extra_state_attributes",
740713
)
741-
742-
743-
class ProtectLicensePlateEventSensor(ProtectEventSensor):
744-
"""A UniFi Protect license plate sensor."""
745-
746-
device: Camera
747-
748-
@callback
749-
def _set_event_done(self) -> None:
750-
self._attr_native_value = OBJECT_TYPE_NONE
751-
self._attr_extra_state_attributes = {}
752-
753-
@callback
754-
def _async_update_device_from_protect(self, device: ProtectDeviceType) -> None:
755-
description = self.entity_description
756-
757-
prev_event = self._event
758-
prev_event_end = self._event_end
759-
super()._async_update_device_from_protect(device)
760-
if event := description.get_event_obj(device):
761-
self._event = event
762-
self._event_end = event.end
763-
764-
if not (
765-
event
766-
and (metadata := event.metadata)
767-
and (license_plate := metadata.license_plate)
768-
and description.has_matching_smart(event)
769-
and not self._event_already_ended(prev_event, prev_event_end)
770-
):
771-
self._set_event_done()
772-
return
773-
774-
self._attr_native_value = license_plate.name
775-
self._set_event_attrs(event)
776-
if event.end:
777-
self._async_event_with_immediate_end()

tests/components/unifiprotect/test_media_source.py

Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -730,109 +730,6 @@ async def test_browse_media_recent_truncated(
730730
),
731731
"Object Detection - Person, Vehicle",
732732
),
733-
(
734-
Event(
735-
model=ModelType.EVENT,
736-
id="test_event_id",
737-
type=EventType.SMART_DETECT,
738-
start=datetime(2000, 1, 1, 0, 0, 0),
739-
end=None,
740-
score=100,
741-
smart_detect_types=["vehicle", "licensePlate"],
742-
smart_detect_event_ids=[],
743-
camera_id="test",
744-
),
745-
"Object Detection - License Plate, Vehicle",
746-
),
747-
(
748-
Event(
749-
model=ModelType.EVENT,
750-
id="test_event_id",
751-
type=EventType.SMART_DETECT,
752-
start=datetime(2000, 1, 1, 0, 0, 0),
753-
end=None,
754-
score=100,
755-
smart_detect_types=["vehicle", "licensePlate"],
756-
smart_detect_event_ids=[],
757-
camera_id="test",
758-
metadata={
759-
"license_plate": {"name": "ABC1234", "confidence_level": 95},
760-
"detected_thumbnails": [
761-
{
762-
"clock_best_wall": datetime(2000, 1, 1, 0, 0, 0),
763-
"type": "vehicle",
764-
"cropped_id": "event_id",
765-
}
766-
],
767-
},
768-
),
769-
"Object Detection - Vehicle: ABC1234",
770-
),
771-
(
772-
Event(
773-
model=ModelType.EVENT,
774-
id="test_event_id",
775-
type=EventType.SMART_DETECT,
776-
start=datetime(2000, 1, 1, 0, 0, 0),
777-
end=None,
778-
score=100,
779-
smart_detect_types=["vehicle", "licensePlate"],
780-
smart_detect_event_ids=[],
781-
camera_id="test",
782-
metadata={
783-
"license_plate": {"name": "ABC1234", "confidence_level": 95},
784-
"detected_thumbnails": [
785-
{
786-
"clock_best_wall": datetime(2000, 1, 1, 0, 0, 0),
787-
"type": "vehicle",
788-
"cropped_id": "event_id",
789-
"attributes": {
790-
"vehicle_type": {
791-
"val": "car",
792-
"confidence": 95,
793-
}
794-
},
795-
}
796-
],
797-
},
798-
),
799-
"Object Detection - Car: ABC1234",
800-
),
801-
(
802-
Event(
803-
model=ModelType.EVENT,
804-
id="test_event_id",
805-
type=EventType.SMART_DETECT,
806-
start=datetime(2000, 1, 1, 0, 0, 0),
807-
end=None,
808-
score=100,
809-
smart_detect_types=["vehicle", "licensePlate"],
810-
smart_detect_event_ids=[],
811-
camera_id="test",
812-
metadata={
813-
"license_plate": {"name": "ABC1234", "confidence_level": 95},
814-
"detected_thumbnails": [
815-
{
816-
"clock_best_wall": datetime(2000, 1, 1, 0, 0, 0),
817-
"type": "vehicle",
818-
"cropped_id": "event_id",
819-
"attributes": {
820-
"color": {
821-
"val": "black",
822-
"confidence": 95,
823-
}
824-
},
825-
},
826-
{
827-
"clock_best_wall": datetime(2000, 1, 1, 0, 0, 0),
828-
"type": "person",
829-
"cropped_id": "event_id",
830-
},
831-
],
832-
},
833-
),
834-
"Object Detection - Black Vehicle: ABC1234",
835-
),
836733
(
837734
Event(
838735
model=ModelType.EVENT,

0 commit comments

Comments
 (0)