Add support for dual lens cameras in Reolink (#89554)

This commit is contained in:
starkillerOG 2023-03-13 12:16:52 +01:00 committed by GitHub
parent 40ed3be4a8
commit 431a8d0047
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 8 deletions

View File

@ -3,6 +3,8 @@ from __future__ import annotations
import logging
from reolink_aio.api import DUAL_LENS_MODELS
from homeassistant.components.camera import Camera, CameraEntityFeature
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
@ -25,7 +27,7 @@ async def async_setup_entry(
host = reolink_data.host
cameras = []
for channel in host.api.channels:
for channel in host.api.stream_channels:
streams = ["sub", "main", "snapshots"]
if host.api.protocol in ["rtmp", "flv"]:
streams.append("ext")
@ -56,7 +58,10 @@ class ReolinkCamera(ReolinkChannelCoordinatorEntity, Camera):
self._stream = stream
self._attr_name = self._stream
if self._host.api.model in DUAL_LENS_MODELS:
self._attr_name = f"{self._stream} lens {self._channel}"
else:
self._attr_name = self._stream
self._attr_unique_id = f"{self._host.unique_id}_{self._channel}_{self._stream}"
self._attr_entity_registry_enabled_default = stream == "sub"

View File

@ -3,6 +3,8 @@ from __future__ import annotations
from typing import TypeVar
from reolink_aio.api import DUAL_LENS_MODELS
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.update_coordinator import (
@ -75,12 +77,16 @@ class ReolinkChannelCoordinatorEntity(ReolinkHostCoordinatorEntity):
self._channel = channel
dev_ch = channel
if self._host.api.model in DUAL_LENS_MODELS:
dev_ch = 0
if self._host.api.is_nvr:
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, f"{self._host.unique_id}_ch{self._channel}")},
identifiers={(DOMAIN, f"{self._host.unique_id}_ch{dev_ch}")},
via_device=(DOMAIN, self._host.unique_id),
name=self._host.api.camera_name(self._channel),
model=self._host.api.camera_model(self._channel),
name=self._host.api.camera_name(dev_ch),
model=self._host.api.camera_model(dev_ch),
manufacturer=self._host.api.manufacturer,
configuration_url=self._conf_url,
)

View File

@ -18,5 +18,5 @@
"documentation": "https://www.home-assistant.io/integrations/reolink",
"iot_class": "local_push",
"loggers": ["reolink_aio"],
"requirements": ["reolink-aio==0.5.3"]
"requirements": ["reolink-aio==0.5.4"]
}

View File

@ -2237,7 +2237,7 @@ regenmaschine==2022.11.0
renault-api==0.1.12
# homeassistant.components.reolink
reolink-aio==0.5.3
reolink-aio==0.5.4
# homeassistant.components.python_script
restrictedpython==6.0

View File

@ -1594,7 +1594,7 @@ regenmaschine==2022.11.0
renault-api==0.1.12
# homeassistant.components.reolink
reolink-aio==0.5.3
reolink-aio==0.5.4
# homeassistant.components.python_script
restrictedpython==6.0