From 02f8779de845d67e2840d90107828c1e6fc73cc4 Mon Sep 17 00:00:00 2001 From: "J.J.Barrancos" Date: Wed, 18 Oct 2017 09:58:32 +0200 Subject: [PATCH 1/4] Fixed comments from @fabaff Fxied issues raides --- homeassistant/components/switch/rainbird.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/homeassistant/components/switch/rainbird.py b/homeassistant/components/switch/rainbird.py index 9678babaea5..d69dc14daf3 100644 --- a/homeassistant/components/switch/rainbird.py +++ b/homeassistant/components/switch/rainbird.py @@ -9,19 +9,19 @@ import logging import voluptuous as vol -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import (SwitchDevice, PLATFORM_SCHEMA) from homeassistant.const import (CONF_PLATFORM, CONF_SWITCHES, CONF_ZONE, CONF_FRIENDLY_NAME, CONF_TRIGGER_TIME, CONF_SCAN_INTERVAL, CONF_HOST, CONF_PASSWORD) from homeassistant.helpers import config_validation as cv from homeassistant.exceptions import PlatformNotReady -REQUIREMENTS = ['pyrainbird==0.1.0'] +REQUIREMENTS = ['pyrainbird==0.1.0','pycrypto==2.6.1'] DOMAIN = 'rainbird' _LOGGER = logging.getLogger(__name__) -PLATFORM_SCHEMA = vol.Schema({ +PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_PLATFORM): DOMAIN, vol.Required(CONF_HOST): cv.string, vol.Required(CONF_PASSWORD): cv.string, @@ -57,8 +57,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): devices = [] for dev_id, switch in config.get(CONF_SWITCHES).items(): devices.append(RainBirdSwitch(controller, switch, dev_id)) - add_devices(devices) - return True + add_devices(devices, True) class RainBirdSwitch(SwitchDevice): @@ -69,8 +68,8 @@ class RainBirdSwitch(SwitchDevice): self._rainbird = rb self._devid = dev_id self._zone = int(dev.get(CONF_ZONE)) - self._name = dev.get(CONF_FRIENDLY_NAME, "Sprinker %s" % self._zone) - self._state = self.get_device_status() + self._name = dev.get(CONF_FRIENDLY_NAME, "Sprinker {}".format(self._zone)) + self._state = None self._duration = dev.get(CONF_TRIGGER_TIME) self._attributes = { "duration": self._duration, @@ -82,11 +81,6 @@ class RainBirdSwitch(SwitchDevice): """Return state attributes.""" return self._attributes - @property - def should_poll(self): - """Return the polling state.""" - return True - @property def name(self): """Get the name of the switch.""" From 76a3a4892d1baae1d4848a79c5bde6d1f33147b3 Mon Sep 17 00:00:00 2001 From: "J.J.Barrancos" Date: Wed, 18 Oct 2017 10:18:37 +0200 Subject: [PATCH 2/4] Fix req --- homeassistant/components/switch/rainbird.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/switch/rainbird.py b/homeassistant/components/switch/rainbird.py index d69dc14daf3..3f3a8cf6d5c 100644 --- a/homeassistant/components/switch/rainbird.py +++ b/homeassistant/components/switch/rainbird.py @@ -16,7 +16,7 @@ from homeassistant.const import (CONF_PLATFORM, CONF_SWITCHES, CONF_ZONE, from homeassistant.helpers import config_validation as cv from homeassistant.exceptions import PlatformNotReady -REQUIREMENTS = ['pyrainbird==0.1.0','pycrypto==2.6.1'] +REQUIREMENTS = ['pyrainbird==0.1.0'] DOMAIN = 'rainbird' _LOGGER = logging.getLogger(__name__) From 778761ebce72de47aac17803af79ebb7860bed9d Mon Sep 17 00:00:00 2001 From: "J.J.Barrancos" Date: Wed, 18 Oct 2017 10:40:38 +0200 Subject: [PATCH 3/4] lint error --- homeassistant/components/switch/rainbird.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/switch/rainbird.py b/homeassistant/components/switch/rainbird.py index 3f3a8cf6d5c..ac0b07a78f8 100644 --- a/homeassistant/components/switch/rainbird.py +++ b/homeassistant/components/switch/rainbird.py @@ -68,7 +68,8 @@ class RainBirdSwitch(SwitchDevice): self._rainbird = rb self._devid = dev_id self._zone = int(dev.get(CONF_ZONE)) - self._name = dev.get(CONF_FRIENDLY_NAME, "Sprinker {}".format(self._zone)) + self._name = dev.get(CONF_FRIENDLY_NAME, + "Sprinker {}".format(self._zone)) self._state = None self._duration = dev.get(CONF_TRIGGER_TIME) self._attributes = { From a628112e4c701ca1b4425d69ede48cb216835769 Mon Sep 17 00:00:00 2001 From: "J.J.Barrancos" Date: Wed, 18 Oct 2017 11:17:29 +0200 Subject: [PATCH 4/4] lint ws --- homeassistant/components/switch/rainbird.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/switch/rainbird.py b/homeassistant/components/switch/rainbird.py index ac0b07a78f8..70397e53d09 100644 --- a/homeassistant/components/switch/rainbird.py +++ b/homeassistant/components/switch/rainbird.py @@ -68,7 +68,7 @@ class RainBirdSwitch(SwitchDevice): self._rainbird = rb self._devid = dev_id self._zone = int(dev.get(CONF_ZONE)) - self._name = dev.get(CONF_FRIENDLY_NAME, + self._name = dev.get(CONF_FRIENDLY_NAME, "Sprinker {}".format(self._zone)) self._state = None self._duration = dev.get(CONF_TRIGGER_TIME)