Remove entity description mixin in Goodwe (#112773)

pull/112810/head
Joost Lekkerkerker 2024-03-09 11:00:36 +01:00 committed by GitHub
parent 3301117223
commit b26f00bf39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 20 deletions

View File

@ -19,20 +19,13 @@ from .const import DOMAIN, KEY_DEVICE_INFO, KEY_INVERTER
_LOGGER = logging.getLogger(__name__)
@dataclass(frozen=True)
class GoodweButtonEntityDescriptionRequired:
"""Required attributes of GoodweButtonEntityDescription."""
@dataclass(frozen=True, kw_only=True)
class GoodweButtonEntityDescription(ButtonEntityDescription):
"""Class describing Goodwe button entities."""
action: Callable[[Inverter], Awaitable[None]]
@dataclass(frozen=True)
class GoodweButtonEntityDescription(
ButtonEntityDescription, GoodweButtonEntityDescriptionRequired
):
"""Class describing Goodwe button entities."""
SYNCHRONIZE_CLOCK = GoodweButtonEntityDescription(
key="synchronize_clock",
translation_key="synchronize_clock",

View File

@ -24,22 +24,15 @@ from .const import DOMAIN, KEY_DEVICE_INFO, KEY_INVERTER
_LOGGER = logging.getLogger(__name__)
@dataclass(frozen=True)
class GoodweNumberEntityDescriptionBase:
"""Required values when describing Goodwe number entities."""
@dataclass(frozen=True, kw_only=True)
class GoodweNumberEntityDescription(NumberEntityDescription):
"""Class describing Goodwe number entities."""
getter: Callable[[Inverter], Awaitable[int]]
setter: Callable[[Inverter, int], Awaitable[None]]
filter: Callable[[Inverter], bool]
@dataclass(frozen=True)
class GoodweNumberEntityDescription(
NumberEntityDescription, GoodweNumberEntityDescriptionBase
):
"""Class describing Goodwe number entities."""
def _get_setting_unit(inverter: Inverter, setting: str) -> str:
"""Return the unit of an inverter setting."""
return next((s.unit for s in inverter.settings() if s.id_ == setting), "")