1 """Support for Ecoforest number platform."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from dataclasses
import dataclass
8 from pyecoforest.models.device
import Device
15 from .const
import DOMAIN
16 from .coordinator
import EcoforestCoordinator
17 from .entity
import EcoforestEntity
20 @dataclass(frozen=True, kw_only=True)
22 """Describes an ecoforest number entity."""
24 value_fn: Callable[[Device], float |
None]
30 translation_key=
"power_level",
34 value_fn=
lambda data: data.power,
41 config_entry: ConfigEntry,
42 async_add_entities: AddEntitiesCallback,
44 """Set up Ecoforest number platform."""
45 coordinator: EcoforestCoordinator = hass.data[DOMAIN][config_entry.entry_id]
49 for description
in NUMBER_ENTITIES
56 """Representation of an Ecoforest number entity."""
58 entity_description: EcoforestNumberEntityDescription
62 """Return the state of the entity."""
66 """Update the native value."""
67 await self.coordinator.api.set_power(
int(value))
None async_set_native_value(self, float value)
float|None native_value(self)
None async_request_refresh(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)