Add "stop watering" service to rachio (#53764)

Co-authored-by: Brian Rogers <brg468@hotmail.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Adam Ernst 2021-08-03 16:51:52 -05:00 committed by GitHub
parent c959a0a484
commit 5735669693
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 0 deletions

View file

@ -54,6 +54,7 @@ SCHEDULE_TYPE_FIXED = "FIXED"
SCHEDULE_TYPE_FLEX = "FLEX"
SERVICE_PAUSE_WATERING = "pause_watering"
SERVICE_RESUME_WATERING = "resume_watering"
SERVICE_STOP_WATERING = "stop_watering"
SERVICE_SET_ZONE_MOISTURE = "set_zone_moisture_percent"
SERVICE_START_MULTIPLE_ZONES = "start_multiple_zone_schedule"

View file

@ -26,6 +26,7 @@ from .const import (
MODEL_GENERATION_1,
SERVICE_PAUSE_WATERING,
SERVICE_RESUME_WATERING,
SERVICE_STOP_WATERING,
)
from .webhooks import LISTEN_EVENT_TYPES, WEBHOOK_CONST_ID
@ -44,6 +45,8 @@ PAUSE_SERVICE_SCHEMA = vol.Schema(
RESUME_SERVICE_SCHEMA = vol.Schema({vol.Optional(ATTR_DEVICES): cv.string})
STOP_SERVICE_SCHEMA = vol.Schema({vol.Optional(ATTR_DEVICES): cv.string})
class RachioPerson:
"""Represent a Rachio user."""
@ -87,6 +90,13 @@ class RachioPerson:
if iro.name in devices:
iro.resume_watering()
def stop_water(service):
"""Service to stop watering on all or specific controllers."""
devices = service.data.get(ATTR_DEVICES, all_devices)
for iro in self._controllers:
if iro.name in devices:
iro.stop_watering()
hass.services.async_register(
DOMAIN,
SERVICE_PAUSE_WATERING,
@ -101,6 +111,13 @@ class RachioPerson:
schema=RESUME_SERVICE_SCHEMA,
)
hass.services.async_register(
DOMAIN,
SERVICE_STOP_WATERING,
stop_water,
schema=STOP_SERVICE_SCHEMA,
)
def _setup(self, hass):
"""Rachio device setup."""
rachio = self.rachio

View file

@ -59,3 +59,13 @@ resume_watering:
example: "Main House"
selector:
text:
stop_watering:
name: Stop watering
description: Stop any currently running zones or schedules.
fields:
devices:
name: Devices
description: Name of controllers to stop. Defaults to all controllers on the account if not provided.
example: "Main House"
selector:
text: