mirror of
https://github.com/home-assistant/core.git
synced 2025-11-13 13:00:11 +00:00
Add Reolink Ai person type, vehicle type and animal type (#153170)
This commit is contained in:
@@ -462,6 +462,15 @@
|
||||
},
|
||||
"sd_storage": {
|
||||
"default": "mdi:micro-sd"
|
||||
},
|
||||
"person_type": {
|
||||
"default": "mdi:account"
|
||||
},
|
||||
"vehicle_type": {
|
||||
"default": "mdi:car"
|
||||
},
|
||||
"animal_type": {
|
||||
"default": "mdi:paw"
|
||||
}
|
||||
},
|
||||
"siren": {
|
||||
|
||||
@@ -8,6 +8,7 @@ from datetime import date, datetime
|
||||
from decimal import Decimal
|
||||
|
||||
from reolink_aio.api import Host
|
||||
from reolink_aio.const import YOLO_DETECT_TYPES
|
||||
from reolink_aio.enums import BatteryEnum
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
@@ -135,6 +136,39 @@ SENSORS = (
|
||||
value=lambda api, ch: api.wifi_signal(ch),
|
||||
supported=lambda api, ch: api.supported(ch, "wifi"),
|
||||
),
|
||||
ReolinkSensorEntityDescription(
|
||||
key="person_type",
|
||||
cmd_id=696,
|
||||
translation_key="person_type",
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
options=YOLO_DETECT_TYPES["people"],
|
||||
value=lambda api, ch: api.baichuan.ai_detect_type(ch, "person"),
|
||||
supported=lambda api, ch: (
|
||||
api.supported(ch, "ai_yolo_type") and api.supported(ch, "ai_people")
|
||||
),
|
||||
),
|
||||
ReolinkSensorEntityDescription(
|
||||
key="vehicle_type",
|
||||
cmd_id=696,
|
||||
translation_key="vehicle_type",
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
options=YOLO_DETECT_TYPES["vehicle"],
|
||||
value=lambda api, ch: api.baichuan.ai_detect_type(ch, "vehicle"),
|
||||
supported=lambda api, ch: (
|
||||
api.supported(ch, "ai_yolo_type") and api.supported(ch, "ai_vehicle")
|
||||
),
|
||||
),
|
||||
ReolinkSensorEntityDescription(
|
||||
key="animal_type",
|
||||
cmd_id=696,
|
||||
translation_key="animal_type",
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
options=YOLO_DETECT_TYPES["dog_cat"],
|
||||
value=lambda api, ch: api.baichuan.ai_detect_type(ch, "dog_cat"),
|
||||
supported=lambda api, ch: (
|
||||
api.supported(ch, "ai_yolo_type") and api.supported(ch, "ai_dog_cat")
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
HOST_SENSORS = (
|
||||
|
||||
@@ -930,6 +930,29 @@
|
||||
},
|
||||
"sd_storage": {
|
||||
"name": "SD {hdd_index} storage"
|
||||
},
|
||||
"person_type": {
|
||||
"name": "Person type",
|
||||
"state": {
|
||||
"man": "Man",
|
||||
"woman": "Woman"
|
||||
}
|
||||
},
|
||||
"vehicle_type": {
|
||||
"name": "Vehicle type",
|
||||
"state": {
|
||||
"sedan": "Sedan",
|
||||
"suv": "SUV",
|
||||
"pickup_truck": "Pickup truck",
|
||||
"motorcycle": "Motorcycle"
|
||||
}
|
||||
},
|
||||
"animal_type": {
|
||||
"name": "Animal type",
|
||||
"state": {
|
||||
"dog": "Dog",
|
||||
"cat": "Cat"
|
||||
}
|
||||
}
|
||||
},
|
||||
"siren": {
|
||||
|
||||
@@ -185,6 +185,17 @@ def _init_host_mock(host_mock: MagicMock) -> None:
|
||||
host_mock.baichuan.smart_ai_index.return_value = 1
|
||||
host_mock.baichuan.smart_ai_name.return_value = "zone1"
|
||||
|
||||
def ai_detect_type(channel: int, object_type: str) -> str | None:
|
||||
if object_type == "people":
|
||||
return "man"
|
||||
if object_type == "dog_cat":
|
||||
return "dog"
|
||||
if object_type == "vehicle":
|
||||
return "motorcycle"
|
||||
return None
|
||||
|
||||
host_mock.baichuan.ai_detect_type = ai_detect_type
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def reolink_host_class() -> Generator[MagicMock]:
|
||||
|
||||
Reference in New Issue
Block a user