1 """Support for TechnoVE number entities."""
3 from __future__
import annotations
5 from collections.abc
import Callable, Coroutine
6 from dataclasses
import dataclass
9 from technove
import MIN_CURRENT, TechnoVE
14 NumberEntityDescription,
22 from .
import TechnoVEConfigEntry
23 from .const
import DOMAIN
24 from .coordinator
import TechnoVEDataUpdateCoordinator
25 from .entity
import TechnoVEEntity
26 from .helpers
import technove_exception_handler
29 @dataclass(frozen=True, kw_only=True)
31 """Describes TechnoVE number entity."""
33 native_max_value_fn: Callable[[TechnoVE], float]
34 native_value_fn: Callable[[TechnoVE], float]
35 set_value_fn: Callable[
36 [TechnoVEDataUpdateCoordinator, float], Coroutine[Any, Any,
None]
41 coordinator: TechnoVEDataUpdateCoordinator, value: float
43 if coordinator.data.info.in_sharing_mode:
45 translation_domain=DOMAIN, translation_key=
"max_current_in_sharing_mode"
47 await coordinator.technove.set_max_current(value)
53 translation_key=
"max_current",
54 entity_category=EntityCategory.CONFIG,
55 device_class=NumberDeviceClass.CURRENT,
58 native_min_value=MIN_CURRENT,
59 native_max_value_fn=
lambda station: station.info.max_station_current,
60 native_value_fn=
lambda station: station.info.max_current,
61 set_value_fn=_set_max_current,
68 entry: TechnoVEConfigEntry,
69 async_add_entities: AddEntitiesCallback,
71 """Set up TechnoVE number entity based on a config entry."""
78 """Defines a TechnoVE number entity."""
80 entity_description: TechnoVENumberDescription
84 coordinator: TechnoVEDataUpdateCoordinator,
85 description: TechnoVENumberDescription,
87 """Initialize a TechnoVE switch entity."""
89 super().
__init__(coordinator, description.key)
93 """Return the max value of the TechnoVE number entity."""
94 return self.
entity_descriptionentity_description.native_max_value_fn(self.coordinator.data)
98 """Return the native value of the TechnoVE number entity."""
99 return self.
entity_descriptionentity_description.native_value_fn(self.coordinator.data)
101 @technove_exception_handler
103 """Set the value for the TechnoVE number entity."""
None __init__(self, TechnoVEDataUpdateCoordinator coordinator, TechnoVENumberDescription description)
None async_set_native_value(self, float value)
float native_max_value(self)
None async_setup_entry(HomeAssistant hass, TechnoVEConfigEntry entry, AddEntitiesCallback async_add_entities)
None _set_max_current(TechnoVEDataUpdateCoordinator coordinator, float value)