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

View File

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