core/homeassistant/components/rainbird/__init__.py

43 lines
1.1 KiB
Python
Raw Normal View History

"""Support for Rain Bird Irrigation system LNK WiFi Module."""
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
_LOGGER = logging.getLogger(__name__)
2019-07-31 19:25:30 +00:00
DATA_RAINBIRD = "rainbird"
DOMAIN = "rainbird"
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,
)
def setup(hass, config):
"""Set up the Rain Bird component."""
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
controller = RainbirdController(server, password)
_LOGGER.debug("Rain Bird Controller set to: %s", server)
initial_status = controller.currentIrrigation()
if initial_status and initial_status["type"] != "CurrentStationsActiveResponse":
_LOGGER.error("Error getting state. Possible configuration issues")
return False
hass.data[DATA_RAINBIRD] = controller
return True