From 689484216d73383ddedb8e89c29442db933f91b8 Mon Sep 17 00:00:00 2001 From: "J.J.Barrancos" Date: Tue, 29 Aug 2017 13:45:18 +0200 Subject: [PATCH] Using latest module and fixed state issue - pyrainbird 0.0.9 allows the override (if ever needed) connection retry/sleep - Forces state towards the Entity when switching the switches. Gives better UI experience. --- homeassistant/components/rainbird.py | 6 +++++- homeassistant/components/switch/rainbird.py | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/rainbird.py b/homeassistant/components/rainbird.py index f98e2ba1d61..48a40cc30fe 100644 --- a/homeassistant/components/rainbird.py +++ b/homeassistant/components/rainbird.py @@ -14,7 +14,7 @@ from homeassistant.helpers.entity import Entity from homeassistant.const import ( CONF_HOST, CONF_PASSWORD) -REQUIREMENTS = ['pyrainbird==0.0.7'] +REQUIREMENTS = ['pyrainbird==0.0.9'] DOMAIN = 'rainbird' @@ -102,6 +102,10 @@ class RainbirdDevice(Entity): """Return True if entity is available.""" return self._state != -1 + def setstate(self, state): + """Force set the current state value.""" + self._state = state + @property def state(self): """Return the state of the entity.""" diff --git a/homeassistant/components/switch/rainbird.py b/homeassistant/components/switch/rainbird.py index f951f257560..f341f1324f6 100644 --- a/homeassistant/components/switch/rainbird.py +++ b/homeassistant/components/switch/rainbird.py @@ -57,6 +57,7 @@ class RainBirdSwitch(SwitchDevice): self._duration = dev.get(CONF_TRIGGER_TIME) self._attributes = { "duration": self._duration, + "zone" : self._zone } @property @@ -78,11 +79,13 @@ class RainBirdSwitch(SwitchDevice): """Turn the switch on.""" self._state = True self._rainbird.start_irrigation(self._zone, self._duration) + self._rainbird.setstate(self._zone) def turn_off(self, **kwargs): """Turn the switch off.""" self._state = False self._rainbird.stop_irrigation() + self._rainbird.setstate(0) def get_device_status(self): """Get the status of the switch from Rain Bird Controller."""