Bump reolink-aio to 0.9.1 (#118655)
Co-authored-by: J. Nick Koston <nick@koston.org>pull/118772/head
parent
d43d12905d
commit
cba07540e9
|
@ -89,11 +89,17 @@ class ReolinkHostCoordinatorEntity(ReolinkBaseCoordinatorEntity[None]):
|
|||
async def async_added_to_hass(self) -> None:
|
||||
"""Entity created."""
|
||||
await super().async_added_to_hass()
|
||||
if (
|
||||
self.entity_description.cmd_key is not None
|
||||
and self.entity_description.cmd_key not in self._host.update_cmd_list
|
||||
):
|
||||
self._host.update_cmd_list.append(self.entity_description.cmd_key)
|
||||
cmd_key = self.entity_description.cmd_key
|
||||
if cmd_key is not None:
|
||||
self._host.async_register_update_cmd(cmd_key)
|
||||
|
||||
async def async_will_remove_from_hass(self) -> None:
|
||||
"""Entity removed."""
|
||||
cmd_key = self.entity_description.cmd_key
|
||||
if cmd_key is not None:
|
||||
self._host.async_unregister_update_cmd(cmd_key)
|
||||
|
||||
await super().async_will_remove_from_hass()
|
||||
|
||||
|
||||
class ReolinkChannelCoordinatorEntity(ReolinkHostCoordinatorEntity):
|
||||
|
@ -128,3 +134,18 @@ class ReolinkChannelCoordinatorEntity(ReolinkHostCoordinatorEntity):
|
|||
sw_version=self._host.api.camera_sw_version(dev_ch),
|
||||
configuration_url=self._conf_url,
|
||||
)
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Entity created."""
|
||||
await super().async_added_to_hass()
|
||||
cmd_key = self.entity_description.cmd_key
|
||||
if cmd_key is not None:
|
||||
self._host.async_register_update_cmd(cmd_key, self._channel)
|
||||
|
||||
async def async_will_remove_from_hass(self) -> None:
|
||||
"""Entity removed."""
|
||||
cmd_key = self.entity_description.cmd_key
|
||||
if cmd_key is not None:
|
||||
self._host.async_unregister_update_cmd(cmd_key, self._channel)
|
||||
|
||||
await super().async_will_remove_from_hass()
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from collections import defaultdict
|
||||
from collections.abc import Mapping
|
||||
import logging
|
||||
from typing import Any, Literal
|
||||
|
@ -21,7 +22,7 @@ from homeassistant.const import (
|
|||
CONF_PROTOCOL,
|
||||
CONF_USERNAME,
|
||||
)
|
||||
from homeassistant.core import CALLBACK_TYPE, HassJob, HomeAssistant
|
||||
from homeassistant.core import CALLBACK_TYPE, HassJob, HomeAssistant, callback
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
from homeassistant.helpers.device_registry import format_mac
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
|
@ -67,7 +68,9 @@ class ReolinkHost:
|
|||
timeout=DEFAULT_TIMEOUT,
|
||||
)
|
||||
|
||||
self.update_cmd_list: list[str] = []
|
||||
self._update_cmd: defaultdict[str, defaultdict[int | None, int]] = defaultdict(
|
||||
lambda: defaultdict(int)
|
||||
)
|
||||
|
||||
self.webhook_id: str | None = None
|
||||
self._onvif_push_supported: bool = True
|
||||
|
@ -84,6 +87,20 @@ class ReolinkHost:
|
|||
self._long_poll_task: asyncio.Task | None = None
|
||||
self._lost_subscription: bool = False
|
||||
|
||||
@callback
|
||||
def async_register_update_cmd(self, cmd: str, channel: int | None = None) -> None:
|
||||
"""Register the command to update the state."""
|
||||
self._update_cmd[cmd][channel] += 1
|
||||
|
||||
@callback
|
||||
def async_unregister_update_cmd(self, cmd: str, channel: int | None = None) -> None:
|
||||
"""Unregister the command to update the state."""
|
||||
self._update_cmd[cmd][channel] -= 1
|
||||
if not self._update_cmd[cmd][channel]:
|
||||
del self._update_cmd[cmd][channel]
|
||||
if not self._update_cmd[cmd]:
|
||||
del self._update_cmd[cmd]
|
||||
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
"""Create the unique ID, base for all entities."""
|
||||
|
@ -320,7 +337,7 @@ class ReolinkHost:
|
|||
|
||||
async def update_states(self) -> None:
|
||||
"""Call the API of the camera device to update the internal states."""
|
||||
await self._api.get_states(cmd_list=self.update_cmd_list)
|
||||
await self._api.get_states(cmd_list=self._update_cmd)
|
||||
|
||||
async def disconnect(self) -> None:
|
||||
"""Disconnect from the API, so the connection will be released."""
|
||||
|
|
|
@ -18,5 +18,5 @@
|
|||
"documentation": "https://www.home-assistant.io/integrations/reolink",
|
||||
"iot_class": "local_push",
|
||||
"loggers": ["reolink_aio"],
|
||||
"requirements": ["reolink-aio==0.8.11"]
|
||||
"requirements": ["reolink-aio==0.9.1"]
|
||||
}
|
||||
|
|
|
@ -109,12 +109,14 @@ SELECT_ENTITIES = (
|
|||
ReolinkSelectEntityDescription(
|
||||
key="status_led",
|
||||
cmd_key="GetPowerLed",
|
||||
translation_key="status_led",
|
||||
translation_key="doorbell_led",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
get_options=[state.name for state in StatusLedEnum],
|
||||
get_options=lambda api, ch: api.doorbell_led_list(ch),
|
||||
supported=lambda api, ch: api.supported(ch, "doorbell_led"),
|
||||
value=lambda api, ch: StatusLedEnum(api.doorbell_led(ch)).name,
|
||||
method=lambda api, ch, name: api.set_status_led(ch, StatusLedEnum[name].value),
|
||||
method=lambda api, ch, name: (
|
||||
api.set_status_led(ch, StatusLedEnum[name].value, doorbell=True)
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
@ -463,8 +463,8 @@
|
|||
"pantiltfirst": "Pan/tilt first"
|
||||
}
|
||||
},
|
||||
"status_led": {
|
||||
"name": "Status LED",
|
||||
"doorbell_led": {
|
||||
"name": "Doorbell LED",
|
||||
"state": {
|
||||
"stayoff": "Stay off",
|
||||
"auto": "Auto",
|
||||
|
|
|
@ -2454,7 +2454,7 @@ renault-api==0.2.3
|
|||
renson-endura-delta==1.7.1
|
||||
|
||||
# homeassistant.components.reolink
|
||||
reolink-aio==0.8.11
|
||||
reolink-aio==0.9.1
|
||||
|
||||
# homeassistant.components.idteck_prox
|
||||
rfk101py==0.0.1
|
||||
|
|
|
@ -1915,7 +1915,7 @@ renault-api==0.2.3
|
|||
renson-endura-delta==1.7.1
|
||||
|
||||
# homeassistant.components.reolink
|
||||
reolink-aio==0.8.11
|
||||
reolink-aio==0.9.1
|
||||
|
||||
# homeassistant.components.rflink
|
||||
rflink==0.0.66
|
||||
|
|
Loading…
Reference in New Issue