def setup(hass, config): """Set up the Rain Bird componenent.""" conf = config[DOMAIN] server = conf.get(CONF_HOST) password = conf.get(CONF_PASSWORD) from pyrainbird import RainbirdController controller = RainbirdController() controller.setConfig(server, password) _LOGGER.debug("Rain Bird Controller set to: %s", server) initialstatus = controller.currentIrrigation() if initialstatus == -1: _LOGGER.error("Error getting state. Possible configuration issues") return False hass.data[DATA_RAINBIRD] = controller return True
def setup(hass, config): """Set up the Rain Bird componenent.""" conf = config[DOMAIN] server = conf.get(CONF_HOST) password = conf.get(CONF_PASSWORD) from pyrainbird import RainbirdController controller = RainbirdController() controller.setConfig(server, password) _LOGGER.debug("Rain Bird Controller set to: %s", server) initialstatus = controller.currentIrrigation() if initialstatus == -1: _LOGGER.error("Error getting state. Possible configuration issues") return False hass.data[DATA_RAINBIRD] = controller return True
def setup_platform(hass, config, add_devices, discovery_info=None): """Set up Rain Bird switches over a Rain Bird controller.""" server = config.get(CONF_HOST) password = config.get(CONF_PASSWORD) from pyrainbird import RainbirdController controller = RainbirdController(_LOGGER) controller.setConfig(server, password) _LOGGER.debug("Rain Bird Controller set to " + str(server)) if controller.currentIrrigation() == -1: _LOGGER.error("Error getting state. Possible configuration issues") raise PlatformNotReady else: _LOGGER.debug("Initialized Rain Bird Controller") devices = [] for dev_id, switch in config.get(CONF_SWITCHES).items(): devices.append(RainBirdSwitch(controller, switch, dev_id)) add_devices(devices, True)