Remove entity description mixin in Goodwe (#112773)
parent
3301117223
commit
b26f00bf39
|
@ -19,20 +19,13 @@ from .const import DOMAIN, KEY_DEVICE_INFO, KEY_INVERTER
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class GoodweButtonEntityDescriptionRequired:
|
class GoodweButtonEntityDescription(ButtonEntityDescription):
|
||||||
"""Required attributes of GoodweButtonEntityDescription."""
|
"""Class describing Goodwe button entities."""
|
||||||
|
|
||||||
action: Callable[[Inverter], Awaitable[None]]
|
action: Callable[[Inverter], Awaitable[None]]
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class GoodweButtonEntityDescription(
|
|
||||||
ButtonEntityDescription, GoodweButtonEntityDescriptionRequired
|
|
||||||
):
|
|
||||||
"""Class describing Goodwe button entities."""
|
|
||||||
|
|
||||||
|
|
||||||
SYNCHRONIZE_CLOCK = GoodweButtonEntityDescription(
|
SYNCHRONIZE_CLOCK = GoodweButtonEntityDescription(
|
||||||
key="synchronize_clock",
|
key="synchronize_clock",
|
||||||
translation_key="synchronize_clock",
|
translation_key="synchronize_clock",
|
||||||
|
|
|
@ -24,22 +24,15 @@ from .const import DOMAIN, KEY_DEVICE_INFO, KEY_INVERTER
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class GoodweNumberEntityDescriptionBase:
|
class GoodweNumberEntityDescription(NumberEntityDescription):
|
||||||
"""Required values when describing Goodwe number entities."""
|
"""Class describing Goodwe number entities."""
|
||||||
|
|
||||||
getter: Callable[[Inverter], Awaitable[int]]
|
getter: Callable[[Inverter], Awaitable[int]]
|
||||||
setter: Callable[[Inverter, int], Awaitable[None]]
|
setter: Callable[[Inverter, int], Awaitable[None]]
|
||||||
filter: Callable[[Inverter], bool]
|
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:
|
def _get_setting_unit(inverter: Inverter, setting: str) -> str:
|
||||||
"""Return the unit of an inverter setting."""
|
"""Return the unit of an inverter setting."""
|
||||||
return next((s.unit for s in inverter.settings() if s.id_ == setting), "")
|
return next((s.unit for s in inverter.settings() if s.id_ == setting), "")
|
||||||
|
|
Loading…
Reference in New Issue