diff --git a/homeassistant/components/reolink/button.py b/homeassistant/components/reolink/button.py index 6b1fcc65a2f..c1a2aed4119 100644 --- a/homeassistant/components/reolink/button.py +++ b/homeassistant/components/reolink/button.py @@ -138,6 +138,7 @@ BUTTON_ENTITIES = ( HOST_BUTTON_ENTITIES = ( ReolinkHostButtonEntityDescription( key="reboot", + always_available=True, device_class=ButtonDeviceClass.RESTART, entity_category=EntityCategory.CONFIG, entity_registry_enabled_default=False, @@ -218,7 +219,7 @@ class ReolinkButtonEntity(ReolinkChannelCoordinatorEntity, ButtonEntity): class ReolinkHostButtonEntity(ReolinkHostCoordinatorEntity, ButtonEntity): - """Base button entity class for Reolink IP cameras.""" + """Base button entity class for Reolink hosts.""" entity_description: ReolinkHostButtonEntityDescription diff --git a/homeassistant/components/reolink/entity.py b/homeassistant/components/reolink/entity.py index 63c95c25025..e3a84579865 100644 --- a/homeassistant/components/reolink/entity.py +++ b/homeassistant/components/reolink/entity.py @@ -25,6 +25,7 @@ class ReolinkEntityDescription(EntityDescription): cmd_key: str | None = None cmd_id: int | None = None + always_available: bool = False @dataclass(frozen=True, kw_only=True) @@ -92,6 +93,9 @@ class ReolinkHostCoordinatorEntity(CoordinatorEntity[DataUpdateCoordinator[None] @property def available(self) -> bool: """Return True if entity is available.""" + if self.entity_description.always_available: + return True + return ( self._host.api.session_active and not self._host.api.baichuan.privacy_mode() diff --git a/homeassistant/components/reolink/switch.py b/homeassistant/components/reolink/switch.py index cecb0b0000f..a0b8824782a 100644 --- a/homeassistant/components/reolink/switch.py +++ b/homeassistant/components/reolink/switch.py @@ -206,11 +206,9 @@ SWITCH_ENTITIES = ( value=lambda api, ch: api.pir_reduce_alarm(ch) is True, method=lambda api, ch, value: api.set_pir(ch, reduce_alarm=value), ), -) - -AVAILABILITY_SWITCH_ENTITIES = ( ReolinkSwitchEntityDescription( key="privacy_mode", + always_available=True, translation_key="privacy_mode", entity_category=EntityCategory.CONFIG, supported=lambda api, ch: api.supported(ch, "privacy_mode"), @@ -355,12 +353,6 @@ async def async_setup_entry( for entity_description in CHIME_SWITCH_ENTITIES for chime in reolink_data.host.api.chime_list ) - entities.extend( - ReolinkAvailabilitySwitchEntity(reolink_data, channel, entity_description) - for entity_description in AVAILABILITY_SWITCH_ENTITIES - for channel in reolink_data.host.api.channels - if entity_description.supported(reolink_data.host.api, channel) - ) # Can be removed in HA 2025.4.0 depricated_dict = {} @@ -426,15 +418,6 @@ class ReolinkSwitchEntity(ReolinkChannelCoordinatorEntity, SwitchEntity): self.async_write_ha_state() -class ReolinkAvailabilitySwitchEntity(ReolinkSwitchEntity): - """Switch entity class for Reolink IP cameras which will be available even if API is unavailable.""" - - @property - def available(self) -> bool: - """Return True if entity is available.""" - return self._host.api.camera_online(self._channel) - - class ReolinkNVRSwitchEntity(ReolinkHostCoordinatorEntity, SwitchEntity): """Switch entity class for Reolink NVR features."""