Add support for dual lens cameras in Reolink (#89554)
This commit is contained in:
parent
40ed3be4a8
commit
431a8d0047
5 changed files with 19 additions and 8 deletions
|
@ -3,6 +3,8 @@ from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from reolink_aio.api import DUAL_LENS_MODELS
|
||||||
|
|
||||||
from homeassistant.components.camera import Camera, CameraEntityFeature
|
from homeassistant.components.camera import Camera, CameraEntityFeature
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
@ -25,7 +27,7 @@ async def async_setup_entry(
|
||||||
host = reolink_data.host
|
host = reolink_data.host
|
||||||
|
|
||||||
cameras = []
|
cameras = []
|
||||||
for channel in host.api.channels:
|
for channel in host.api.stream_channels:
|
||||||
streams = ["sub", "main", "snapshots"]
|
streams = ["sub", "main", "snapshots"]
|
||||||
if host.api.protocol in ["rtmp", "flv"]:
|
if host.api.protocol in ["rtmp", "flv"]:
|
||||||
streams.append("ext")
|
streams.append("ext")
|
||||||
|
@ -56,6 +58,9 @@ class ReolinkCamera(ReolinkChannelCoordinatorEntity, Camera):
|
||||||
|
|
||||||
self._stream = stream
|
self._stream = 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_name = self._stream
|
||||||
self._attr_unique_id = f"{self._host.unique_id}_{self._channel}_{self._stream}"
|
self._attr_unique_id = f"{self._host.unique_id}_{self._channel}_{self._stream}"
|
||||||
self._attr_entity_registry_enabled_default = stream == "sub"
|
self._attr_entity_registry_enabled_default = stream == "sub"
|
||||||
|
|
|
@ -3,6 +3,8 @@ from __future__ import annotations
|
||||||
|
|
||||||
from typing import TypeVar
|
from typing import TypeVar
|
||||||
|
|
||||||
|
from reolink_aio.api import DUAL_LENS_MODELS
|
||||||
|
|
||||||
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
||||||
from homeassistant.helpers.entity import DeviceInfo
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.update_coordinator import (
|
from homeassistant.helpers.update_coordinator import (
|
||||||
|
@ -75,12 +77,16 @@ class ReolinkChannelCoordinatorEntity(ReolinkHostCoordinatorEntity):
|
||||||
|
|
||||||
self._channel = channel
|
self._channel = channel
|
||||||
|
|
||||||
|
dev_ch = channel
|
||||||
|
if self._host.api.model in DUAL_LENS_MODELS:
|
||||||
|
dev_ch = 0
|
||||||
|
|
||||||
if self._host.api.is_nvr:
|
if self._host.api.is_nvr:
|
||||||
self._attr_device_info = DeviceInfo(
|
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),
|
via_device=(DOMAIN, self._host.unique_id),
|
||||||
name=self._host.api.camera_name(self._channel),
|
name=self._host.api.camera_name(dev_ch),
|
||||||
model=self._host.api.camera_model(self._channel),
|
model=self._host.api.camera_model(dev_ch),
|
||||||
manufacturer=self._host.api.manufacturer,
|
manufacturer=self._host.api.manufacturer,
|
||||||
configuration_url=self._conf_url,
|
configuration_url=self._conf_url,
|
||||||
)
|
)
|
||||||
|
|
|
@ -18,5 +18,5 @@
|
||||||
"documentation": "https://www.home-assistant.io/integrations/reolink",
|
"documentation": "https://www.home-assistant.io/integrations/reolink",
|
||||||
"iot_class": "local_push",
|
"iot_class": "local_push",
|
||||||
"loggers": ["reolink_aio"],
|
"loggers": ["reolink_aio"],
|
||||||
"requirements": ["reolink-aio==0.5.3"]
|
"requirements": ["reolink-aio==0.5.4"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -2237,7 +2237,7 @@ regenmaschine==2022.11.0
|
||||||
renault-api==0.1.12
|
renault-api==0.1.12
|
||||||
|
|
||||||
# homeassistant.components.reolink
|
# homeassistant.components.reolink
|
||||||
reolink-aio==0.5.3
|
reolink-aio==0.5.4
|
||||||
|
|
||||||
# homeassistant.components.python_script
|
# homeassistant.components.python_script
|
||||||
restrictedpython==6.0
|
restrictedpython==6.0
|
||||||
|
|
|
@ -1594,7 +1594,7 @@ regenmaschine==2022.11.0
|
||||||
renault-api==0.1.12
|
renault-api==0.1.12
|
||||||
|
|
||||||
# homeassistant.components.reolink
|
# homeassistant.components.reolink
|
||||||
reolink-aio==0.5.3
|
reolink-aio==0.5.4
|
||||||
|
|
||||||
# homeassistant.components.python_script
|
# homeassistant.components.python_script
|
||||||
restrictedpython==6.0
|
restrictedpython==6.0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue