Read min/max number of showers from state for DomesticHotWaterProduction in Overkiz integration (#111535)
* Read min/max number of showers from state * Rewrite code for Read min/max number of showers from state * Set _attr_ instead of inherited valuepull/112516/head
parent
812afc1bd0
commit
e1be109947
|
@ -20,6 +20,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import HomeAssistantOverkizData
|
from . import HomeAssistantOverkizData
|
||||||
from .const import DOMAIN, IGNORED_OVERKIZ_DEVICES
|
from .const import DOMAIN, IGNORED_OVERKIZ_DEVICES
|
||||||
|
from .coordinator import OverkizDataUpdateCoordinator
|
||||||
from .entity import OverkizDescriptiveEntity
|
from .entity import OverkizDescriptiveEntity
|
||||||
|
|
||||||
BOOST_MODE_DURATION_DELAY = 1
|
BOOST_MODE_DURATION_DELAY = 1
|
||||||
|
@ -37,6 +38,8 @@ class OverkizNumberDescriptionMixin:
|
||||||
class OverkizNumberDescription(NumberEntityDescription, OverkizNumberDescriptionMixin):
|
class OverkizNumberDescription(NumberEntityDescription, OverkizNumberDescriptionMixin):
|
||||||
"""Class to describe an Overkiz number."""
|
"""Class to describe an Overkiz number."""
|
||||||
|
|
||||||
|
min_value_state_name: str | None = None
|
||||||
|
max_value_state_name: str | None = None
|
||||||
inverted: bool = False
|
inverted: bool = False
|
||||||
set_native_value: Callable[
|
set_native_value: Callable[
|
||||||
[float, Callable[..., Awaitable[None]]], Awaitable[None]
|
[float, Callable[..., Awaitable[None]]], Awaitable[None]
|
||||||
|
@ -94,6 +97,8 @@ NUMBER_DESCRIPTIONS: list[OverkizNumberDescription] = [
|
||||||
command=OverkizCommand.SET_EXPECTED_NUMBER_OF_SHOWER,
|
command=OverkizCommand.SET_EXPECTED_NUMBER_OF_SHOWER,
|
||||||
native_min_value=2,
|
native_min_value=2,
|
||||||
native_max_value=4,
|
native_max_value=4,
|
||||||
|
min_value_state_name=OverkizState.CORE_MINIMAL_SHOWER_MANUAL_MODE,
|
||||||
|
max_value_state_name=OverkizState.CORE_MAXIMAL_SHOWER_MANUAL_MODE,
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
),
|
),
|
||||||
# SomfyHeatingTemperatureInterface
|
# SomfyHeatingTemperatureInterface
|
||||||
|
@ -200,6 +205,29 @@ class OverkizNumber(OverkizDescriptiveEntity, NumberEntity):
|
||||||
|
|
||||||
entity_description: OverkizNumberDescription
|
entity_description: OverkizNumberDescription
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
device_url: str,
|
||||||
|
coordinator: OverkizDataUpdateCoordinator,
|
||||||
|
description: OverkizNumberDescription,
|
||||||
|
) -> None:
|
||||||
|
"""Initialize a device."""
|
||||||
|
super().__init__(device_url, coordinator, description)
|
||||||
|
|
||||||
|
if self.entity_description.min_value_state_name and (
|
||||||
|
state := self.device.states.get(
|
||||||
|
self.entity_description.min_value_state_name
|
||||||
|
)
|
||||||
|
):
|
||||||
|
self._attr_native_min_value = cast(float, state.value)
|
||||||
|
|
||||||
|
if self.entity_description.max_value_state_name and (
|
||||||
|
state := self.device.states.get(
|
||||||
|
self.entity_description.max_value_state_name
|
||||||
|
)
|
||||||
|
):
|
||||||
|
self._attr_native_max_value = cast(float, state.value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self) -> float | None:
|
def native_value(self) -> float | None:
|
||||||
"""Return the entity value to represent the entity state."""
|
"""Return the entity value to represent the entity state."""
|
||||||
|
|
Loading…
Reference in New Issue