1 """Support for Melnor RainCloud sprinkler water timer."""
3 from __future__
import annotations
8 import voluptuous
as vol
11 PLATFORM_SCHEMA
as SWITCH_PLATFORM_SCHEMA,
20 from .const
import DATA_RAINCLOUD
21 from .entity
import RainCloudEntity
23 _LOGGER = logging.getLogger(__name__)
25 ALLOWED_WATERING_TIME = [5, 10, 15, 30, 45, 60]
26 CONF_WATERING_TIME =
"watering_minutes"
27 DEFAULT_WATERING_TIME = 15
29 SWITCHES = [
"auto_watering",
"manual_watering"]
31 PLATFORM_SCHEMA = SWITCH_PLATFORM_SCHEMA.extend(
33 vol.Optional(CONF_MONITORED_CONDITIONS, default=
list(SWITCHES)): vol.All(
34 cv.ensure_list, [vol.In(SWITCHES)]
36 vol.Optional(CONF_WATERING_TIME, default=DEFAULT_WATERING_TIME): vol.All(
37 vol.In(ALLOWED_WATERING_TIME)
46 add_entities: AddEntitiesCallback,
47 discovery_info: DiscoveryInfoType |
None =
None,
49 """Set up a sensor for a raincloud device."""
50 raincloud = hass.data[DATA_RAINCLOUD].data
51 default_watering_timer = config[CONF_WATERING_TIME]
56 for zone
in raincloud.controller.faucet.zones
57 for sensor_type
in config[CONF_MONITORED_CONDITIONS]
64 """A switch implementation for raincloud device."""
66 def __init__(self, default_watering_timer, *args):
67 """Initialize a switch for raincloud device."""
73 """Return true if device is on."""
77 """Turn the device on."""
81 self.
datadata.auto_watering =
True
85 """Turn the device off."""
87 self.
datadata.watering_time =
"off"
89 self.
datadata.auto_watering =
False
93 """Update device state."""
94 _LOGGER.debug(
"Updating RainCloud switch: %s", self.
_name_name)
102 """Return the state attributes."""
105 "identifier": self.
datadata.serial,
def extra_state_attributes(self)
None turn_on(self, **Any kwargs)
None turn_off(self, **Any kwargs)
def __init__(self, default_watering_timer, *args)
None add_entities(AsusWrtRouter router, AddEntitiesCallback async_add_entities, set[str] tracked)
None setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback add_entities, DiscoveryInfoType|None discovery_info=None)