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 return result
@dataclass(frozen=True) @dataclass(frozen=True, kw_only=True)
class BMWRequiredKeysMixin: class BMWBinarySensorEntityDescription(BinarySensorEntityDescription):
"""Mixin for required keys."""
value_fn: Callable[[MyBMWVehicle], bool]
@dataclass(frozen=True)
class BMWBinarySensorEntityDescription(
BinarySensorEntityDescription, BMWRequiredKeysMixin
):
"""Describes BMW binary_sensor entity.""" """Describes BMW binary_sensor entity."""
value_fn: Callable[[MyBMWVehicle], bool]
attr_fn: Callable[[MyBMWVehicle, UnitSystem], dict[str, Any]] | None = None attr_fn: Callable[[MyBMWVehicle, UnitSystem], dict[str, Any]] | None = None

View File

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

View File

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

View File

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

View File

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