diff --git a/custom_components/deebot/binary_sensor.py b/custom_components/deebot/binary_sensor.py index 9f11b4c..9c103ab 100644 --- a/custom_components/deebot/binary_sensor.py +++ b/custom_components/deebot/binary_sensor.py @@ -19,22 +19,17 @@ from .entity import DeebotEntity, DeebotEntityDescription, EventT -@dataclass -class DeebotBinarySensorEntityMixin(Generic[EventT]): - """Deebot binary sensor entity mixin.""" - - value_fn: Callable[[EventT], bool | None] - icon_fn: Callable[[bool | None], str | None] - - -@dataclass +@dataclass(kw_only=True) class DeebotBinarySensorEntityDescription( BinarySensorEntityDescription, # type: ignore DeebotEntityDescription, - DeebotBinarySensorEntityMixin[EventT], + Generic[EventT], ): """Class describing Deebot binary sensor entity.""" + value_fn: Callable[[EventT], bool | None] + icon_fn: Callable[[bool | None], str | None] + ENTITY_DESCRIPTIONS: tuple[DeebotBinarySensorEntityDescription, ...] = ( DeebotBinarySensorEntityDescription[WaterInfoEvent]( diff --git a/custom_components/deebot/button.py b/custom_components/deebot/button.py index 141e080..77d1ccb 100644 --- a/custom_components/deebot/button.py +++ b/custom_components/deebot/button.py @@ -16,7 +16,7 @@ from .entity import DeebotEntity, DeebotEntityDescription -@dataclass +@dataclass(kw_only=True) class DeebotButtonEntityDescription( ButtonEntityDescription, # type: ignore DeebotEntityDescription, diff --git a/custom_components/deebot/entity.py b/custom_components/deebot/entity.py index 259b012..0d46e6f 100644 --- a/custom_components/deebot/entity.py +++ b/custom_components/deebot/entity.py @@ -17,21 +17,15 @@ EventT = TypeVar("EventT", bound=Event) -@dataclass -class DeebotDescription(Generic[CapabilityT]): - """Deebot description.""" - - capability_fn: Callable[[Capabilities], CapabilityT | None] - - -@dataclass +@dataclass(kw_only=True) class DeebotEntityDescription( EntityDescription, # type: ignore - DeebotDescription[CapabilityT], + Generic[CapabilityT], ): """Deebot Entity Description.""" always_available: bool = False + capability_fn: Callable[[Capabilities], CapabilityT | None] class DeebotEntity(Entity, Generic[CapabilityT, _EntityDescriptionT]): # type: ignore diff --git a/custom_components/deebot/number.py b/custom_components/deebot/number.py index 33e3eb2..83ce1e4 100644 --- a/custom_components/deebot/number.py +++ b/custom_components/deebot/number.py @@ -16,23 +16,17 @@ from .entity import DeebotEntity, DeebotEntityDescription, EventT -@dataclass -class DeebotNumberEntityMixin(Generic[EventT]): - """Deebot number entity mixin.""" - - value_fn: Callable[[EventT], float | None] - - -@dataclass +@dataclass(kw_only=True) class DeebotNumberEntityDescription( NumberEntityDescription, # type: ignore DeebotEntityDescription, - DeebotNumberEntityMixin[EventT], + Generic[EventT], ): """Deebot number entity description.""" - native_max_value_fn: Callable[[EventT], float | None] = lambda _: None icon_fn: Callable[["DeebotNumberEntity"], str | None] = lambda _: None + native_max_value_fn: Callable[[EventT], float | None] = lambda _: None + value_fn: Callable[[EventT], float | None] def _volume_icon(instance: "DeebotNumberEntity") -> str | None: diff --git a/custom_components/deebot/select.py b/custom_components/deebot/select.py index a404612..e0a2655 100644 --- a/custom_components/deebot/select.py +++ b/custom_components/deebot/select.py @@ -16,22 +16,17 @@ from .entity import DeebotEntity, DeebotEntityDescription, EventT -@dataclass -class DeebotSelectEntityMixin(Generic[EventT]): - """Deebot select entity mixin.""" - - current_option_fn: Callable[[EventT], str | None] - options_fn: Callable[[CapabilitySetTypes], list[str]] - - -@dataclass +@dataclass(kw_only=True) class DeebotSelectEntityDescription( SelectEntityDescription, # type: ignore DeebotEntityDescription, - DeebotSelectEntityMixin[EventT], + Generic[EventT], ): """Deebot select entity description.""" + current_option_fn: Callable[[EventT], str | None] + options_fn: Callable[[CapabilitySetTypes], list[str]] + ENTITY_DESCRIPTIONS: tuple[DeebotSelectEntityDescription, ...] = ( DeebotSelectEntityDescription( diff --git a/custom_components/deebot/sensor.py b/custom_components/deebot/sensor.py index cbcbef9..272b26c 100644 --- a/custom_components/deebot/sensor.py +++ b/custom_components/deebot/sensor.py @@ -42,24 +42,18 @@ from .entity import DeebotEntity, DeebotEntityDescription, EventT -@dataclass -class DeebotSensorMixin(Generic[EventT]): - """Deebot sensor mixin.""" - - value_fn: Callable[[EventT], StateType] - - -@dataclass +@dataclass(kw_only=True) class DeebotSensorEntityDescription( SensorEntityDescription, # type: ignore DeebotEntityDescription, - DeebotSensorMixin[EventT], + Generic[EventT], ): """Deebot sensor entity description.""" extra_state_attributes_fn: Callable[ [EventT], MutableMapping[str, Any] ] | None = None + value_fn: Callable[[EventT], StateType] def _clean_log_event_value(event: CleanLogEvent) -> str | None: diff --git a/custom_components/deebot/switch.py b/custom_components/deebot/switch.py index cffa1af..ab5db61 100644 --- a/custom_components/deebot/switch.py +++ b/custom_components/deebot/switch.py @@ -15,7 +15,7 @@ from .entity import DeebotEntity, DeebotEntityDescription -@dataclass +@dataclass(kw_only=True) class DeebotSwitchEntityDescription( SwitchEntityDescription, # type: ignore DeebotEntityDescription,