1 """Number support for Melnor Bluetooth water timer."""
3 from __future__
import annotations
5 from collections.abc
import Callable, Coroutine
6 from dataclasses
import dataclass
7 from datetime
import time
10 from melnor_bluetooth.device
import Valve
18 from .const
import DOMAIN
19 from .coordinator
import MelnorDataUpdateCoordinator
20 from .entity
import MelnorZoneEntity, get_entities_for_valves
23 @dataclass(frozen=True, kw_only=True)
25 """Describes Melnor number entity."""
27 set_time_fn: Callable[[Valve, time], Coroutine[Any, Any,
None]]
28 state_fn: Callable[[Valve], Any]
31 ZONE_ENTITY_DESCRIPTIONS: list[MelnorZoneTimeEntityDescription] = [
33 entity_category=EntityCategory.CONFIG,
34 key=
"frequency_start_time",
35 translation_key=
"frequency_start_time",
36 set_time_fn=
lambda valve, value: valve.set_frequency_start_time(value),
37 state_fn=
lambda valve: valve.frequency.start_time,
44 config_entry: ConfigEntry,
45 async_add_entities: AddEntitiesCallback,
47 """Set up the number platform."""
49 coordinator: MelnorDataUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id]
52 get_entities_for_valves(
54 ZONE_ENTITY_DESCRIPTIONS,
55 lambda valve, description:
MelnorZoneTime(coordinator, description, valve),
61 """A time implementation for a melnor device."""
63 entity_description: MelnorZoneTimeEntityDescription
67 coordinator: MelnorDataUpdateCoordinator,
68 entity_description: MelnorZoneTimeEntityDescription,
71 """Initialize a number for a melnor device."""
72 super().
__init__(coordinator, entity_description, valve)
76 """Return the current value."""
80 """Update the current value."""
time|None native_value(self)
None __init__(self, MelnorDataUpdateCoordinator coordinator, MelnorZoneTimeEntityDescription entity_description, Valve valve)
None async_set_value(self, time value)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)