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.pull/9334/head
parent
51c6029fe5
commit
689484216d
|
@ -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."""
|
||||
|
|
|
@ -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."""
|
||||
|
|
Loading…
Reference in New Issue