mirror of
https://github.com/home-assistant/core.git
synced 2025-06-01 03:37:08 +00:00
Add rainbird set_rain_delay service (#52369)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
parent
b3a625593e
commit
2ed1efc3a3
@ -19,3 +19,16 @@ start_irrigation:
|
||||
min: 1
|
||||
max: 1440
|
||||
unit_of_measurement: "minutes"
|
||||
set_rain_delay:
|
||||
name: Set rain delay
|
||||
description: Set how long automatic irrigation is turned off.
|
||||
fields:
|
||||
duration:
|
||||
name: Duration
|
||||
description: Duration for this system to be turned off.
|
||||
required: true
|
||||
selector:
|
||||
number:
|
||||
min: 0
|
||||
max: 14
|
||||
unit_of_measurement: "days"
|
||||
|
@ -11,6 +11,7 @@ from . import CONF_ZONES, DATA_RAINBIRD, DOMAIN, RAINBIRD_CONTROLLER
|
||||
ATTR_DURATION = "duration"
|
||||
|
||||
SERVICE_START_IRRIGATION = "start_irrigation"
|
||||
SERVICE_SET_RAIN_DELAY = "set_rain_delay"
|
||||
|
||||
SERVICE_SCHEMA_IRRIGATION = vol.Schema(
|
||||
{
|
||||
@ -19,6 +20,12 @@ SERVICE_SCHEMA_IRRIGATION = vol.Schema(
|
||||
}
|
||||
)
|
||||
|
||||
SERVICE_SCHEMA_RAIN_DELAY = vol.Schema(
|
||||
{
|
||||
vol.Required(ATTR_DURATION): cv.positive_float,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up Rain Bird switches over a Rain Bird controller."""
|
||||
@ -64,6 +71,18 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
schema=SERVICE_SCHEMA_IRRIGATION,
|
||||
)
|
||||
|
||||
def set_rain_delay(service):
|
||||
duration = service.data[ATTR_DURATION]
|
||||
|
||||
controller.set_rain_delay(duration)
|
||||
|
||||
hass.services.register(
|
||||
DOMAIN,
|
||||
SERVICE_SET_RAIN_DELAY,
|
||||
set_rain_delay,
|
||||
schema=SERVICE_SCHEMA_RAIN_DELAY,
|
||||
)
|
||||
|
||||
|
||||
class RainBirdSwitch(SwitchEntity):
|
||||
"""Representation of a Rain Bird switch."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user