Remove entity description mixin in Roku (#112931)
This commit is contained in:
parent
85bc72f9f1
commit
b59bba8951
3 changed files with 12 additions and 33 deletions
|
@ -20,20 +20,13 @@ from .const import DOMAIN
|
|||
from .entity import RokuEntity
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class RokuBinarySensorEntityDescriptionMixin:
|
||||
"""Mixin for required keys."""
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class RokuBinarySensorEntityDescription(BinarySensorEntityDescription):
|
||||
"""Describes a Roku binary sensor entity."""
|
||||
|
||||
value_fn: Callable[[RokuDevice], bool | None]
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class RokuBinarySensorEntityDescription(
|
||||
BinarySensorEntityDescription, RokuBinarySensorEntityDescriptionMixin
|
||||
):
|
||||
"""Describes a Roku binary sensor entity."""
|
||||
|
||||
|
||||
BINARY_SENSORS: tuple[RokuBinarySensorEntityDescription, ...] = (
|
||||
RokuBinarySensorEntityDescription(
|
||||
key="headphones_connected",
|
||||
|
|
|
@ -19,15 +19,6 @@ from .entity import RokuEntity
|
|||
from .helpers import format_channel_name, roku_exception_handler
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class RokuSelectEntityDescriptionMixin:
|
||||
"""Mixin for required keys."""
|
||||
|
||||
options_fn: Callable[[RokuDevice], list[str]]
|
||||
value_fn: Callable[[RokuDevice], str | None]
|
||||
set_fn: Callable[[RokuDevice, Roku, str], Awaitable[None]]
|
||||
|
||||
|
||||
def _get_application_name(device: RokuDevice) -> str | None:
|
||||
if device.app is None or device.app.name is None:
|
||||
return None
|
||||
|
@ -86,12 +77,14 @@ async def _tune_channel(device: RokuDevice, roku: Roku, value: str) -> None:
|
|||
await roku.tune(_channel.number)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class RokuSelectEntityDescription(
|
||||
SelectEntityDescription, RokuSelectEntityDescriptionMixin
|
||||
):
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class RokuSelectEntityDescription(SelectEntityDescription):
|
||||
"""Describes Roku select entity."""
|
||||
|
||||
options_fn: Callable[[RokuDevice], list[str]]
|
||||
value_fn: Callable[[RokuDevice], str | None]
|
||||
set_fn: Callable[[RokuDevice, Roku, str], Awaitable[None]]
|
||||
|
||||
|
||||
ENTITIES: tuple[RokuSelectEntityDescription, ...] = (
|
||||
RokuSelectEntityDescription(
|
||||
|
|
|
@ -18,20 +18,13 @@ from .coordinator import RokuDataUpdateCoordinator
|
|||
from .entity import RokuEntity
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class RokuSensorEntityDescriptionMixin:
|
||||
"""Mixin for required keys."""
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class RokuSensorEntityDescription(SensorEntityDescription):
|
||||
"""Describes Roku sensor entity."""
|
||||
|
||||
value_fn: Callable[[RokuDevice], str | None]
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class RokuSensorEntityDescription(
|
||||
SensorEntityDescription, RokuSensorEntityDescriptionMixin
|
||||
):
|
||||
"""Describes Roku sensor entity."""
|
||||
|
||||
|
||||
SENSORS: tuple[RokuSensorEntityDescription, ...] = (
|
||||
RokuSensorEntityDescription(
|
||||
key="active_app",
|
||||
|
|
Loading…
Add table
Reference in a new issue