mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Add pause/unpause services to RainMachine (#21548)
* Add pause/unpause services to RainMachine * Update requirements
This commit is contained in:
parent
5e67054ee1
commit
326513af90
@ -19,7 +19,7 @@ from .config_flow import configured_instances
|
||||
from .const import (
|
||||
DATA_CLIENT, DEFAULT_PORT, DEFAULT_SCAN_INTERVAL, DEFAULT_SSL, DOMAIN)
|
||||
|
||||
REQUIREMENTS = ['regenmaschine==1.1.0']
|
||||
REQUIREMENTS = ['regenmaschine==1.2.0']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -31,6 +31,7 @@ ZONE_UPDATE_TOPIC = '{0}_zone_update'.format(DOMAIN)
|
||||
|
||||
CONF_CONTROLLERS = 'controllers'
|
||||
CONF_PROGRAM_ID = 'program_id'
|
||||
CONF_SECONDS = 'seconds'
|
||||
CONF_ZONE_ID = 'zone_id'
|
||||
CONF_ZONE_RUN_TIME = 'zone_run_time'
|
||||
|
||||
@ -73,6 +74,10 @@ SENSOR_SCHEMA = vol.Schema({
|
||||
vol.All(cv.ensure_list, [vol.In(SENSORS)])
|
||||
})
|
||||
|
||||
SERVICE_PAUSE_WATERING = vol.Schema({
|
||||
vol.Required(CONF_SECONDS): cv.positive_int,
|
||||
})
|
||||
|
||||
SERVICE_START_PROGRAM_SCHEMA = vol.Schema({
|
||||
vol.Required(CONF_PROGRAM_ID): cv.positive_int,
|
||||
})
|
||||
@ -184,6 +189,11 @@ async def async_setup_entry(hass, config_entry):
|
||||
refresh,
|
||||
timedelta(seconds=config_entry.data[CONF_SCAN_INTERVAL]))
|
||||
|
||||
async def pause_watering(service):
|
||||
"""Pause watering for a set number of seconds."""
|
||||
await rainmachine.client.watering.pause_all(service.data[CONF_SECONDS])
|
||||
async_dispatcher_send(hass, PROGRAM_UPDATE_TOPIC)
|
||||
|
||||
async def start_program(service):
|
||||
"""Start a particular program."""
|
||||
await rainmachine.client.programs.start(service.data[CONF_PROGRAM_ID])
|
||||
@ -210,12 +220,19 @@ async def async_setup_entry(hass, config_entry):
|
||||
await rainmachine.client.zones.stop(service.data[CONF_ZONE_ID])
|
||||
async_dispatcher_send(hass, ZONE_UPDATE_TOPIC)
|
||||
|
||||
async def unpause_watering(service):
|
||||
"""Unpause watering."""
|
||||
await rainmachine.client.watering.unpause_all()
|
||||
async_dispatcher_send(hass, PROGRAM_UPDATE_TOPIC)
|
||||
|
||||
for service, method, schema in [
|
||||
('pause_watering', pause_watering, SERVICE_PAUSE_WATERING),
|
||||
('start_program', start_program, SERVICE_START_PROGRAM_SCHEMA),
|
||||
('start_zone', start_zone, SERVICE_START_ZONE_SCHEMA),
|
||||
('stop_all', stop_all, {}),
|
||||
('stop_program', stop_program, SERVICE_STOP_PROGRAM_SCHEMA),
|
||||
('stop_zone', stop_zone, SERVICE_STOP_ZONE_SCHEMA)
|
||||
('stop_zone', stop_zone, SERVICE_STOP_ZONE_SCHEMA),
|
||||
('unpause_watering', unpause_watering, {}),
|
||||
]:
|
||||
hass.services.async_register(DOMAIN, service, method, schema=schema)
|
||||
|
||||
|
@ -1,6 +1,12 @@
|
||||
# Describes the format for available RainMachine services
|
||||
|
||||
---
|
||||
pause_watering:
|
||||
description: Pause all watering for a number of seconds.
|
||||
fields:
|
||||
seconds:
|
||||
description: The number of seconds to pause.
|
||||
example: 30
|
||||
start_program:
|
||||
description: Start a program.
|
||||
fields:
|
||||
@ -30,3 +36,5 @@ stop_zone:
|
||||
zone_id:
|
||||
description: The zone to stop.
|
||||
example: 3
|
||||
unpause_watering:
|
||||
description: Unpause all watering.
|
||||
|
@ -1486,7 +1486,7 @@ raspyrfm-client==1.2.8
|
||||
recollect-waste==1.0.1
|
||||
|
||||
# homeassistant.components.rainmachine
|
||||
regenmaschine==1.1.0
|
||||
regenmaschine==1.2.0
|
||||
|
||||
# homeassistant.components.python_script
|
||||
restrictedpython==4.0b8
|
||||
|
@ -254,7 +254,7 @@ pyunifi==2.16
|
||||
pywebpush==1.6.0
|
||||
|
||||
# homeassistant.components.rainmachine
|
||||
regenmaschine==1.1.0
|
||||
regenmaschine==1.2.0
|
||||
|
||||
# homeassistant.components.python_script
|
||||
restrictedpython==4.0b8
|
||||
|
Loading…
x
Reference in New Issue
Block a user