Process late feedback for Reolink (#84884)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
ec33f6fe78
commit
c0d5ceb18c
8 changed files with 120 additions and 101 deletions
|
@ -2,7 +2,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from collections.abc import Mapping
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
import aiohttp
|
||||
from reolink_ip.api import Host
|
||||
|
@ -16,7 +18,7 @@ from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNA
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.device_registry import format_mac
|
||||
|
||||
from .const import CONF_PROTOCOL, CONF_USE_HTTPS, DEFAULT_PROTOCOL, DEFAULT_TIMEOUT
|
||||
from .const import CONF_PROTOCOL, CONF_USE_HTTPS, DEFAULT_TIMEOUT
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -27,18 +29,14 @@ class ReolinkHost:
|
|||
def __init__(
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
config: dict,
|
||||
options: dict,
|
||||
config: Mapping[str, Any],
|
||||
options: Mapping[str, Any],
|
||||
) -> None:
|
||||
"""Initialize Reolink Host. Could be either NVR, or Camera."""
|
||||
self._hass: HomeAssistant = hass
|
||||
|
||||
self._clientsession: aiohttp.ClientSession | None = None
|
||||
self._unique_id: str | None = None
|
||||
|
||||
cur_protocol = (
|
||||
DEFAULT_PROTOCOL if CONF_PROTOCOL not in options else options[CONF_PROTOCOL]
|
||||
)
|
||||
self._unique_id: str = ""
|
||||
|
||||
self._api = Host(
|
||||
config[CONF_HOST],
|
||||
|
@ -46,12 +44,12 @@ class ReolinkHost:
|
|||
config[CONF_PASSWORD],
|
||||
port=config.get(CONF_PORT),
|
||||
use_https=config.get(CONF_USE_HTTPS),
|
||||
protocol=cur_protocol,
|
||||
protocol=options[CONF_PROTOCOL],
|
||||
timeout=DEFAULT_TIMEOUT,
|
||||
)
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
def unique_id(self) -> str:
|
||||
"""Create the unique ID, base for all entities."""
|
||||
return self._unique_id
|
||||
|
||||
|
@ -99,23 +97,22 @@ class ReolinkHost:
|
|||
):
|
||||
if enable_onvif:
|
||||
_LOGGER.error(
|
||||
"Unable to switch on ONVIF on %s. You need it to be ON to receive notifications",
|
||||
"Failed to enable ONVIF on %s. Set it to ON to receive notifications",
|
||||
self._api.nvr_name,
|
||||
)
|
||||
|
||||
if enable_rtmp:
|
||||
_LOGGER.error(
|
||||
"Unable to switch on RTMP on %s. You need it to be ON",
|
||||
"Failed to enable RTMP on %s. Set it to ON",
|
||||
self._api.nvr_name,
|
||||
)
|
||||
elif enable_rtsp:
|
||||
_LOGGER.error(
|
||||
"Unable to switch on RTSP on %s. You need it to be ON",
|
||||
"Failed to enable RTSP on %s. Set it to ON",
|
||||
self._api.nvr_name,
|
||||
)
|
||||
|
||||
if self._unique_id is None:
|
||||
self._unique_id = format_mac(self._api.mac_address)
|
||||
self._unique_id = format_mac(self._api.mac_address)
|
||||
|
||||
return True
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue