Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Reolink reboot button always available #136667

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions homeassistant/components/reolink/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class ReolinkHostButtonEntityDescription(
),
)

HOST_BUTTON_ENTITIES = (
AVAILABILITY_HOST_BUTTON_ENTITIES = (
ReolinkHostButtonEntityDescription(
key="reboot",
device_class=ButtonDeviceClass.RESTART,
Expand All @@ -155,15 +155,15 @@ async def async_setup_entry(
"""Set up a Reolink button entities."""
reolink_data: ReolinkData = config_entry.runtime_data

entities: list[ReolinkButtonEntity | ReolinkHostButtonEntity] = [
entities: list[ReolinkButtonEntity | ReolinkAvailabilityHostButtonEntity] = [
ReolinkButtonEntity(reolink_data, channel, entity_description)
for entity_description in BUTTON_ENTITIES
for channel in reolink_data.host.api.channels
if entity_description.supported(reolink_data.host.api, channel)
]
entities.extend(
ReolinkHostButtonEntity(reolink_data, entity_description)
for entity_description in HOST_BUTTON_ENTITIES
ReolinkAvailabilityHostButtonEntity(reolink_data, entity_description)
for entity_description in AVAILABILITY_HOST_BUTTON_ENTITIES
if entity_description.supported(reolink_data.host.api)
)
async_add_entities(entities)
Expand Down Expand Up @@ -218,7 +218,7 @@ async def async_ptz_move(self, **kwargs: Any) -> None:


class ReolinkHostButtonEntity(ReolinkHostCoordinatorEntity, ButtonEntity):
"""Base button entity class for Reolink IP cameras."""
"""Base button entity class for Reolink hosts."""

entity_description: ReolinkHostButtonEntityDescription

Expand All @@ -235,3 +235,12 @@ def __init__(
async def async_press(self) -> None:
"""Execute the button action."""
await self.entity_description.method(self._host.api)


class ReolinkAvailabilityHostButtonEntity(ReolinkHostButtonEntity):
starkillerOG marked this conversation as resolved.
Show resolved Hide resolved
"""Button entity class for Reolink hosts which will be available even if API is unavailable."""

@property
def available(self) -> bool:
"""Return True if entity is available."""
return True
Loading