From 57356696932131ed5ef957054ddca94d890e40de Mon Sep 17 00:00:00 2001 From: Adam Ernst Date: Tue, 3 Aug 2021 16:51:52 -0500 Subject: [PATCH] Add "stop watering" service to rachio (#53764) Co-authored-by: Brian Rogers Co-authored-by: J. Nick Koston --- homeassistant/components/rachio/const.py | 1 + homeassistant/components/rachio/device.py | 17 +++++++++++++++++ homeassistant/components/rachio/services.yaml | 10 ++++++++++ 3 files changed, 28 insertions(+) diff --git a/homeassistant/components/rachio/const.py b/homeassistant/components/rachio/const.py index 721fb36fd36..9dbf14e3907 100644 --- a/homeassistant/components/rachio/const.py +++ b/homeassistant/components/rachio/const.py @@ -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" diff --git a/homeassistant/components/rachio/device.py b/homeassistant/components/rachio/device.py index ac2fea20bcf..6669a353094 100644 --- a/homeassistant/components/rachio/device.py +++ b/homeassistant/components/rachio/device.py @@ -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 diff --git a/homeassistant/components/rachio/services.yaml b/homeassistant/components/rachio/services.yaml index bcd853b3ded..67463a22172 100644 --- a/homeassistant/components/rachio/services.yaml +++ b/homeassistant/components/rachio/services.yaml @@ -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: