mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 03:37:07 +00:00
Update pyrainbird to version 0.2.1 to fix zone number (#26064)
* Update pyrainbird to version 0.2.0 to fix zone number issue: - home-assistant/home-assistant/issues/24519 - jbarrancos/pyrainbird/issues/5 - https://community.home-assistant.io/t/rainbird-zone-switches-5-8-dont-correspond/104705 * requirements_all.txt regenerated * code formatting * code formatting * response checking * fixed switch state * pyrainbird version bump * formatting * version bump * if instead elif
This commit is contained in:
parent
a347a41d3c
commit
0e4504296e
@ -29,13 +29,12 @@ def setup(hass, config):
|
|||||||
|
|
||||||
from pyrainbird import RainbirdController
|
from pyrainbird import RainbirdController
|
||||||
|
|
||||||
controller = RainbirdController()
|
controller = RainbirdController(server, password)
|
||||||
controller.setConfig(server, password)
|
|
||||||
|
|
||||||
_LOGGER.debug("Rain Bird Controller set to: %s", server)
|
_LOGGER.debug("Rain Bird Controller set to: %s", server)
|
||||||
|
|
||||||
initial_status = controller.currentIrrigation()
|
initial_status = controller.currentIrrigation()
|
||||||
if initial_status == -1:
|
if initial_status and initial_status["type"] != "CurrentStationsActiveResponse":
|
||||||
_LOGGER.error("Error getting state. Possible configuration issues")
|
_LOGGER.error("Error getting state. Possible configuration issues")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"name": "Rainbird",
|
"name": "Rainbird",
|
||||||
"documentation": "https://www.home-assistant.io/components/rainbird",
|
"documentation": "https://www.home-assistant.io/components/rainbird",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"pyrainbird==0.1.6"
|
"pyrainbird==0.2.1"
|
||||||
],
|
],
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"codeowners": []
|
"codeowners": []
|
||||||
|
@ -56,7 +56,11 @@ class RainBirdSensor(Entity):
|
|||||||
"""Get the latest data and updates the states."""
|
"""Get the latest data and updates the states."""
|
||||||
_LOGGER.debug("Updating sensor: %s", self._name)
|
_LOGGER.debug("Updating sensor: %s", self._name)
|
||||||
if self._sensor_type == "rainsensor":
|
if self._sensor_type == "rainsensor":
|
||||||
self._state = self._controller.currentRainSensorState()
|
result = self._controller.currentRainSensorState()
|
||||||
|
if result and result["type"] == "CurrentRainSensorStateResponse":
|
||||||
|
self._state = result["sensorState"]
|
||||||
|
else:
|
||||||
|
self._state = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
@ -70,15 +70,23 @@ class RainBirdSwitch(SwitchDevice):
|
|||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the switch on."""
|
"""Turn the switch on."""
|
||||||
self._rainbird.startIrrigation(int(self._zone), int(self._duration))
|
response = self._rainbird.startIrrigation(int(self._zone), int(self._duration))
|
||||||
|
if response and response["type"] == "AcknowledgeResponse":
|
||||||
|
self._state = True
|
||||||
|
|
||||||
def turn_off(self, **kwargs):
|
def turn_off(self, **kwargs):
|
||||||
"""Turn the switch off."""
|
"""Turn the switch off."""
|
||||||
self._rainbird.stopIrrigation()
|
response = self._rainbird.stopIrrigation()
|
||||||
|
if response and response["type"] == "AcknowledgeResponse":
|
||||||
|
self._state = False
|
||||||
|
|
||||||
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."""
|
||||||
return self._rainbird.currentIrrigation() == self._zone
|
response = self._rainbird.currentIrrigation()
|
||||||
|
if response is None:
|
||||||
|
return None
|
||||||
|
if isinstance(response, dict) and "sprinklers" in response:
|
||||||
|
return response["sprinklers"][self._zone]
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Update switch status."""
|
"""Update switch status."""
|
||||||
|
@ -1359,7 +1359,7 @@ pyqwikswitch==0.93
|
|||||||
pyrail==0.0.3
|
pyrail==0.0.3
|
||||||
|
|
||||||
# homeassistant.components.rainbird
|
# homeassistant.components.rainbird
|
||||||
pyrainbird==0.1.6
|
pyrainbird==0.2.1
|
||||||
|
|
||||||
# homeassistant.components.recswitch
|
# homeassistant.components.recswitch
|
||||||
pyrecswitch==1.0.2
|
pyrecswitch==1.0.2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user