2019-04-03 15:40:03 +00:00
|
|
|
"""Support for Rain Bird Irrigation system LNK WiFi Module."""
|
2017-12-25 09:07:18 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
import voluptuous as vol
|
|
|
|
|
|
|
|
import homeassistant.helpers.config_validation as cv
|
2019-07-31 19:25:30 +00:00
|
|
|
from homeassistant.const import CONF_HOST, CONF_PASSWORD
|
2017-12-25 09:07:18 +00:00
|
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
DATA_RAINBIRD = "rainbird"
|
|
|
|
DOMAIN = "rainbird"
|
2017-12-25 09:07:18 +00:00
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
CONFIG_SCHEMA = vol.Schema(
|
|
|
|
{
|
|
|
|
DOMAIN: vol.Schema(
|
|
|
|
{vol.Required(CONF_HOST): cv.string, vol.Required(CONF_PASSWORD): cv.string}
|
|
|
|
)
|
|
|
|
},
|
|
|
|
extra=vol.ALLOW_EXTRA,
|
|
|
|
)
|
2017-12-25 09:07:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
def setup(hass, config):
|
2018-01-29 22:37:19 +00:00
|
|
|
"""Set up the Rain Bird component."""
|
2017-12-25 09:07:18 +00:00
|
|
|
conf = config[DOMAIN]
|
|
|
|
server = conf.get(CONF_HOST)
|
|
|
|
password = conf.get(CONF_PASSWORD)
|
|
|
|
|
|
|
|
from pyrainbird import RainbirdController
|
2019-07-31 19:25:30 +00:00
|
|
|
|
2019-08-20 16:26:15 +00:00
|
|
|
controller = RainbirdController(server, password)
|
2017-12-25 09:07:18 +00:00
|
|
|
|
|
|
|
_LOGGER.debug("Rain Bird Controller set to: %s", server)
|
|
|
|
|
2018-01-29 22:37:19 +00:00
|
|
|
initial_status = controller.currentIrrigation()
|
2019-08-20 16:26:15 +00:00
|
|
|
if initial_status and initial_status["type"] != "CurrentStationsActiveResponse":
|
2017-12-25 09:07:18 +00:00
|
|
|
_LOGGER.error("Error getting state. Possible configuration issues")
|
|
|
|
return False
|
|
|
|
|
|
|
|
hass.data[DATA_RAINBIRD] = controller
|
|
|
|
return True
|