mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
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.
This commit is contained in:
parent
51c6029fe5
commit
689484216d
@ -14,7 +14,7 @@ from homeassistant.helpers.entity import Entity
|
|||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST, CONF_PASSWORD)
|
CONF_HOST, CONF_PASSWORD)
|
||||||
|
|
||||||
REQUIREMENTS = ['pyrainbird==0.0.7']
|
REQUIREMENTS = ['pyrainbird==0.0.9']
|
||||||
|
|
||||||
DOMAIN = 'rainbird'
|
DOMAIN = 'rainbird'
|
||||||
|
|
||||||
@ -102,6 +102,10 @@ class RainbirdDevice(Entity):
|
|||||||
"""Return True if entity is available."""
|
"""Return True if entity is available."""
|
||||||
return self._state != -1
|
return self._state != -1
|
||||||
|
|
||||||
|
def setstate(self, state):
|
||||||
|
"""Force set the current state value."""
|
||||||
|
self._state = state
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
"""Return the state of the entity."""
|
"""Return the state of the entity."""
|
||||||
|
@ -57,6 +57,7 @@ class RainBirdSwitch(SwitchDevice):
|
|||||||
self._duration = dev.get(CONF_TRIGGER_TIME)
|
self._duration = dev.get(CONF_TRIGGER_TIME)
|
||||||
self._attributes = {
|
self._attributes = {
|
||||||
"duration": self._duration,
|
"duration": self._duration,
|
||||||
|
"zone" : self._zone
|
||||||
}
|
}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -78,11 +79,13 @@ class RainBirdSwitch(SwitchDevice):
|
|||||||
"""Turn the switch on."""
|
"""Turn the switch on."""
|
||||||
self._state = True
|
self._state = True
|
||||||
self._rainbird.start_irrigation(self._zone, self._duration)
|
self._rainbird.start_irrigation(self._zone, self._duration)
|
||||||
|
self._rainbird.setstate(self._zone)
|
||||||
|
|
||||||
def turn_off(self, **kwargs):
|
def turn_off(self, **kwargs):
|
||||||
"""Turn the switch off."""
|
"""Turn the switch off."""
|
||||||
self._state = False
|
self._state = False
|
||||||
self._rainbird.stop_irrigation()
|
self._rainbird.stop_irrigation()
|
||||||
|
self._rainbird.setstate(0)
|
||||||
|
|
||||||
def get_device_status(self):
|
def get_device_status(self):
|
||||||
"""Get the status of the switch from Rain Bird Controller."""
|
"""Get the status of the switch from Rain Bird Controller."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user