Add sensors for read-only devices for UniFi Protect (#73768)
This commit is contained in:
parent
db9c242723
commit
9940a85e28
8 changed files with 391 additions and 31 deletions
|
@ -34,7 +34,8 @@ from .entity import (
|
|||
ProtectNVREntity,
|
||||
async_all_device_entities,
|
||||
)
|
||||
from .models import ProtectRequiredKeysMixin
|
||||
from .models import PermRequired, ProtectRequiredKeysMixin
|
||||
from .utils import async_get_is_highfps
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
_KEY_DOOR = "door"
|
||||
|
@ -69,6 +70,126 @@ CAMERA_SENSORS: tuple[ProtectBinaryEntityDescription, ...] = (
|
|||
icon="mdi:brightness-6",
|
||||
ufp_value="is_dark",
|
||||
),
|
||||
ProtectBinaryEntityDescription(
|
||||
key="ssh",
|
||||
name="SSH Enabled",
|
||||
icon="mdi:lock",
|
||||
entity_registry_enabled_default=False,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
ufp_value="is_ssh_enabled",
|
||||
ufp_perm=PermRequired.NO_WRITE,
|
||||
),
|
||||
ProtectBinaryEntityDescription(
|
||||
key="status_light",
|
||||
name="Status Light On",
|
||||
icon="mdi:led-on",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
ufp_required_field="feature_flags.has_led_status",
|
||||
ufp_value="led_settings.is_enabled",
|
||||
ufp_perm=PermRequired.NO_WRITE,
|
||||
),
|
||||
ProtectBinaryEntityDescription(
|
||||
key="hdr_mode",
|
||||
name="HDR Mode",
|
||||
icon="mdi:brightness-7",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
ufp_required_field="feature_flags.has_hdr",
|
||||
ufp_value="hdr_mode",
|
||||
ufp_perm=PermRequired.NO_WRITE,
|
||||
),
|
||||
ProtectBinaryEntityDescription(
|
||||
key="high_fps",
|
||||
name="High FPS",
|
||||
icon="mdi:video-high-definition",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
ufp_required_field="feature_flags.has_highfps",
|
||||
ufp_value_fn=async_get_is_highfps,
|
||||
ufp_perm=PermRequired.NO_WRITE,
|
||||
),
|
||||
ProtectBinaryEntityDescription(
|
||||
key="system_sounds",
|
||||
name="System Sounds",
|
||||
icon="mdi:speaker",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
ufp_required_field="feature_flags.has_speaker",
|
||||
ufp_value="speaker_settings.are_system_sounds_enabled",
|
||||
ufp_perm=PermRequired.NO_WRITE,
|
||||
),
|
||||
ProtectBinaryEntityDescription(
|
||||
key="osd_name",
|
||||
name="Overlay: Show Name",
|
||||
icon="mdi:fullscreen",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
ufp_value="osd_settings.is_name_enabled",
|
||||
ufp_perm=PermRequired.NO_WRITE,
|
||||
),
|
||||
ProtectBinaryEntityDescription(
|
||||
key="osd_date",
|
||||
name="Overlay: Show Date",
|
||||
icon="mdi:fullscreen",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
ufp_value="osd_settings.is_date_enabled",
|
||||
ufp_perm=PermRequired.NO_WRITE,
|
||||
),
|
||||
ProtectBinaryEntityDescription(
|
||||
key="osd_logo",
|
||||
name="Overlay: Show Logo",
|
||||
icon="mdi:fullscreen",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
ufp_value="osd_settings.is_logo_enabled",
|
||||
ufp_perm=PermRequired.NO_WRITE,
|
||||
),
|
||||
ProtectBinaryEntityDescription(
|
||||
key="osd_bitrate",
|
||||
name="Overlay: Show Bitrate",
|
||||
icon="mdi:fullscreen",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
ufp_value="osd_settings.is_debug_enabled",
|
||||
ufp_perm=PermRequired.NO_WRITE,
|
||||
),
|
||||
ProtectBinaryEntityDescription(
|
||||
key="motion",
|
||||
name="Detections: Motion",
|
||||
icon="mdi:run-fast",
|
||||
ufp_value="recording_settings.enable_motion_detection",
|
||||
ufp_perm=PermRequired.NO_WRITE,
|
||||
),
|
||||
ProtectBinaryEntityDescription(
|
||||
key="smart_person",
|
||||
name="Detections: Person",
|
||||
icon="mdi:walk",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
ufp_required_field="can_detect_person",
|
||||
ufp_value="is_person_detection_on",
|
||||
ufp_perm=PermRequired.NO_WRITE,
|
||||
),
|
||||
ProtectBinaryEntityDescription(
|
||||
key="smart_vehicle",
|
||||
name="Detections: Vehicle",
|
||||
icon="mdi:car",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
ufp_required_field="can_detect_vehicle",
|
||||
ufp_value="is_vehicle_detection_on",
|
||||
ufp_perm=PermRequired.NO_WRITE,
|
||||
),
|
||||
ProtectBinaryEntityDescription(
|
||||
key="smart_face",
|
||||
name="Detections: Face",
|
||||
icon="mdi:human-greeting",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
ufp_required_field="can_detect_face",
|
||||
ufp_value="is_face_detection_on",
|
||||
ufp_perm=PermRequired.NO_WRITE,
|
||||
),
|
||||
ProtectBinaryEntityDescription(
|
||||
key="smart_package",
|
||||
name="Detections: Package",
|
||||
icon="mdi:package-variant-closed",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
ufp_required_field="can_detect_package",
|
||||
ufp_value="is_package_detection_on",
|
||||
ufp_perm=PermRequired.NO_WRITE,
|
||||
),
|
||||
)
|
||||
|
||||
LIGHT_SENSORS: tuple[ProtectBinaryEntityDescription, ...] = (
|
||||
|
@ -84,6 +205,31 @@ LIGHT_SENSORS: tuple[ProtectBinaryEntityDescription, ...] = (
|
|||
device_class=BinarySensorDeviceClass.MOTION,
|
||||
ufp_value="is_pir_motion_detected",
|
||||
),
|
||||
ProtectBinaryEntityDescription(
|
||||
key="light",
|
||||
name="Flood Light",
|
||||
icon="mdi:spotlight-beam",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
ufp_value="is_light_on",
|
||||
ufp_perm=PermRequired.NO_WRITE,
|
||||
),
|
||||
ProtectBinaryEntityDescription(
|
||||
key="ssh",
|
||||
name="SSH Enabled",
|
||||
icon="mdi:lock",
|
||||
entity_registry_enabled_default=False,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
ufp_value="is_ssh_enabled",
|
||||
ufp_perm=PermRequired.NO_WRITE,
|
||||
),
|
||||
ProtectBinaryEntityDescription(
|
||||
key="status_light",
|
||||
name="Status Light On",
|
||||
icon="mdi:led-on",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
ufp_value="light_device_settings.is_indicator_enabled",
|
||||
ufp_perm=PermRequired.NO_WRITE,
|
||||
),
|
||||
)
|
||||
|
||||
SENSE_SENSORS: tuple[ProtectBinaryEntityDescription, ...] = (
|
||||
|
@ -114,6 +260,53 @@ SENSE_SENSORS: tuple[ProtectBinaryEntityDescription, ...] = (
|
|||
device_class=BinarySensorDeviceClass.TAMPER,
|
||||
ufp_value="is_tampering_detected",
|
||||
),
|
||||
ProtectBinaryEntityDescription(
|
||||
key="status_light",
|
||||
name="Status Light On",
|
||||
icon="mdi:led-on",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
ufp_value="led_settings.is_enabled",
|
||||
ufp_perm=PermRequired.NO_WRITE,
|
||||
),
|
||||
ProtectBinaryEntityDescription(
|
||||
key="motion",
|
||||
name="Motion Detection",
|
||||
icon="mdi:walk",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
ufp_value="motion_settings.is_enabled",
|
||||
ufp_perm=PermRequired.NO_WRITE,
|
||||
),
|
||||
ProtectBinaryEntityDescription(
|
||||
key="temperature",
|
||||
name="Temperature Sensor",
|
||||
icon="mdi:thermometer",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
ufp_value="temperature_settings.is_enabled",
|
||||
ufp_perm=PermRequired.NO_WRITE,
|
||||
),
|
||||
ProtectBinaryEntityDescription(
|
||||
key="humidity",
|
||||
name="Humidity Sensor",
|
||||
icon="mdi:water-percent",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
ufp_value="humidity_settings.is_enabled",
|
||||
ufp_perm=PermRequired.NO_WRITE,
|
||||
),
|
||||
ProtectBinaryEntityDescription(
|
||||
key="light",
|
||||
name="Light Sensor",
|
||||
icon="mdi:brightness-5",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
ufp_value="light_settings.is_enabled",
|
||||
ufp_perm=PermRequired.NO_WRITE,
|
||||
),
|
||||
ProtectBinaryEntityDescription(
|
||||
key="alarm",
|
||||
name="Alarm Sound Detection",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
ufp_value="alarm_settings.is_enabled",
|
||||
ufp_perm=PermRequired.NO_WRITE,
|
||||
),
|
||||
)
|
||||
|
||||
MOTION_SENSORS: tuple[ProtectBinaryEntityDescription, ...] = (
|
||||
|
@ -133,6 +326,26 @@ DOORLOCK_SENSORS: tuple[ProtectBinaryEntityDescription, ...] = (
|
|||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
ufp_value="battery_status.is_low",
|
||||
),
|
||||
ProtectBinaryEntityDescription(
|
||||
key="status_light",
|
||||
name="Status Light On",
|
||||
icon="mdi:led-on",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
ufp_value="led_settings.is_enabled",
|
||||
ufp_perm=PermRequired.NO_WRITE,
|
||||
),
|
||||
)
|
||||
|
||||
VIEWER_SENSORS: tuple[ProtectBinaryEntityDescription, ...] = (
|
||||
ProtectBinaryEntityDescription(
|
||||
key="ssh",
|
||||
name="SSH Enabled",
|
||||
icon="mdi:lock",
|
||||
entity_registry_enabled_default=False,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
ufp_value="is_ssh_enabled",
|
||||
ufp_perm=PermRequired.NO_WRITE,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
@ -159,6 +372,7 @@ async def async_setup_entry(
|
|||
light_descs=LIGHT_SENSORS,
|
||||
sense_descs=SENSE_SENSORS,
|
||||
lock_descs=DOORLOCK_SENSORS,
|
||||
viewer_descs=VIEWER_SENSORS,
|
||||
)
|
||||
entities += _async_motion_entities(data)
|
||||
entities += _async_nvr_entities(data)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue