Remove entity description mixin in Minecraft Server (#112908)

This commit is contained in:
Joost Lekkerkerker 2024-03-11 11:29:30 +01:00 committed by GitHub
parent 9fd96e8a78
commit 53750acdab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 20 deletions

View file

@ -1,6 +1,5 @@
"""The Minecraft Server binary sensor platform."""
from dataclasses import dataclass
from homeassistant.components.binary_sensor import (
BinarySensorDeviceClass,
@ -18,13 +17,8 @@ from .entity import MinecraftServerEntity
KEY_STATUS = "status"
@dataclass(frozen=True)
class MinecraftServerBinarySensorEntityDescription(BinarySensorEntityDescription):
"""Class describing Minecraft Server binary sensor entities."""
BINARY_SENSOR_DESCRIPTIONS = [
MinecraftServerBinarySensorEntityDescription(
BinarySensorEntityDescription(
key=KEY_STATUS,
translation_key=KEY_STATUS,
device_class=BinarySensorDeviceClass.CONNECTIVITY,
@ -52,12 +46,10 @@ async def async_setup_entry(
class MinecraftServerBinarySensorEntity(MinecraftServerEntity, BinarySensorEntity):
"""Representation of a Minecraft Server binary sensor base entity."""
entity_description: MinecraftServerBinarySensorEntityDescription
def __init__(
self,
coordinator: MinecraftServerCoordinator,
description: MinecraftServerBinarySensorEntityDescription,
description: BinarySensorEntityDescription,
config_entry: ConfigEntry,
) -> None:
"""Initialize binary sensor base entity."""

View file

@ -32,22 +32,15 @@ UNIT_PLAYERS_MAX = "players"
UNIT_PLAYERS_ONLINE = "players"
@dataclass(frozen=True)
class MinecraftServerEntityDescriptionMixin:
"""Mixin values for Minecraft Server entities."""
@dataclass(frozen=True, kw_only=True)
class MinecraftServerSensorEntityDescription(SensorEntityDescription):
"""Class describing Minecraft Server sensor entities."""
value_fn: Callable[[MinecraftServerData], StateType]
attributes_fn: Callable[[MinecraftServerData], MutableMapping[str, Any]] | None
supported_server_types: set[MinecraftServerType]
@dataclass(frozen=True)
class MinecraftServerSensorEntityDescription(
SensorEntityDescription, MinecraftServerEntityDescriptionMixin
):
"""Class describing Minecraft Server sensor entities."""
def get_extra_state_attributes_players_list(
data: MinecraftServerData,
) -> dict[str, list[str]]: