Fix Rachio service missing with 1st generation controllers (#55679)

This commit is contained in:
Brian Rogers 2021-09-03 16:35:33 -04:00 committed by GitHub
parent 1e4233fe20
commit 9db13a3e74
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -70,9 +70,6 @@ class RachioPerson:
can_pause = True
break
if not can_pause:
return
all_devices = [rachio_iro.name for rachio_iro in self._controllers]
def pause_water(service):
@ -97,6 +94,16 @@ class RachioPerson:
if iro.name in devices:
iro.stop_watering()
hass.services.async_register(
DOMAIN,
SERVICE_STOP_WATERING,
stop_water,
schema=STOP_SERVICE_SCHEMA,
)
if not can_pause:
return
hass.services.async_register(
DOMAIN,
SERVICE_PAUSE_WATERING,
@ -111,13 +118,6 @@ 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
@ -134,7 +134,7 @@ class RachioPerson:
for controller in devices:
webhooks = rachio.notification.get_device_webhook(controller[KEY_ID])[1]
# The API does not provide a way to tell if a controller is shared
# or if they are the owner. To work around this problem we fetch the webooks
# or if they are the owner. To work around this problem we fetch the webhooks
# before we setup the device so we can skip it instead of failing.
# webhooks are normally a list, however if there is an error
# rachio hands us back a dict