Remove entity description mixin in BMW (#112391)

This commit is contained in:
Joost Lekkerkerker 2024-03-05 18:11:30 +01:00 committed by GitHub
parent 7cef704220
commit cb397cecb1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 15 additions and 47 deletions

View File

@ -109,19 +109,11 @@ def _format_cbs_report(
return result
@dataclass(frozen=True)
class BMWRequiredKeysMixin:
"""Mixin for required keys."""
value_fn: Callable[[MyBMWVehicle], bool]
@dataclass(frozen=True)
class BMWBinarySensorEntityDescription(
BinarySensorEntityDescription, BMWRequiredKeysMixin
):
@dataclass(frozen=True, kw_only=True)
class BMWBinarySensorEntityDescription(BinarySensorEntityDescription):
"""Describes BMW binary_sensor entity."""
value_fn: Callable[[MyBMWVehicle], bool]
attr_fn: Callable[[MyBMWVehicle, UnitSystem], dict[str, Any]] | None = None

View File

@ -25,17 +25,11 @@ if TYPE_CHECKING:
_LOGGER = logging.getLogger(__name__)
@dataclass(frozen=True)
class BMWRequiredKeysMixin:
"""Mixin for required keys."""
remote_function: Callable[[MyBMWVehicle], Coroutine[Any, Any, RemoteServiceStatus]]
@dataclass(frozen=True)
class BMWButtonEntityDescription(ButtonEntityDescription, BMWRequiredKeysMixin):
@dataclass(frozen=True, kw_only=True)
class BMWButtonEntityDescription(ButtonEntityDescription):
"""Class describing BMW button entities."""
remote_function: Callable[[MyBMWVehicle], Coroutine[Any, Any, RemoteServiceStatus]]
enabled_when_read_only: bool = False
is_available: Callable[[MyBMWVehicle], bool] = lambda _: True

View File

@ -26,18 +26,12 @@ from .coordinator import BMWDataUpdateCoordinator
_LOGGER = logging.getLogger(__name__)
@dataclass(frozen=True)
class BMWRequiredKeysMixin:
"""Mixin for required keys."""
@dataclass(frozen=True, kw_only=True)
class BMWNumberEntityDescription(NumberEntityDescription):
"""Describes BMW number entity."""
value_fn: Callable[[MyBMWVehicle], float | int | None]
remote_service: Callable[[MyBMWVehicle, float | int], Coroutine[Any, Any, Any]]
@dataclass(frozen=True)
class BMWNumberEntityDescription(NumberEntityDescription, BMWRequiredKeysMixin):
"""Describes BMW number entity."""
is_available: Callable[[MyBMWVehicle], bool] = lambda _: False
dynamic_options: Callable[[MyBMWVehicle], list[str]] | None = None

View File

@ -22,18 +22,12 @@ from .coordinator import BMWDataUpdateCoordinator
_LOGGER = logging.getLogger(__name__)
@dataclass(frozen=True)
class BMWRequiredKeysMixin:
"""Mixin for required keys."""
@dataclass(frozen=True, kw_only=True)
class BMWSelectEntityDescription(SelectEntityDescription):
"""Describes BMW sensor entity."""
current_option: Callable[[MyBMWVehicle], str]
remote_service: Callable[[MyBMWVehicle, str], Coroutine[Any, Any, Any]]
@dataclass(frozen=True)
class BMWSelectEntityDescription(SelectEntityDescription, BMWRequiredKeysMixin):
"""Describes BMW sensor entity."""
is_available: Callable[[MyBMWVehicle], bool] = lambda _: False
dynamic_options: Callable[[MyBMWVehicle], list[str]] | None = None

View File

@ -22,19 +22,13 @@ from .coordinator import BMWDataUpdateCoordinator
_LOGGER = logging.getLogger(__name__)
@dataclass(frozen=True)
class BMWRequiredKeysMixin:
"""Mixin for required keys."""
@dataclass(frozen=True, kw_only=True)
class BMWSwitchEntityDescription(SwitchEntityDescription):
"""Describes BMW switch entity."""
value_fn: Callable[[MyBMWVehicle], bool]
remote_service_on: Callable[[MyBMWVehicle], Coroutine[Any, Any, Any]]
remote_service_off: Callable[[MyBMWVehicle], Coroutine[Any, Any, Any]]
@dataclass(frozen=True)
class BMWSwitchEntityDescription(SwitchEntityDescription, BMWRequiredKeysMixin):
"""Describes BMW switch entity."""
is_available: Callable[[MyBMWVehicle], bool] = lambda _: False
dynamic_options: Callable[[MyBMWVehicle], list[str]] | None = None