From cce4a569e47a7764781a36b89e837c8219900441 Mon Sep 17 00:00:00 2001 From: "J.J.Barrancos" Date: Fri, 25 Aug 2017 16:06:49 +0200 Subject: [PATCH] Changed doc and added default schema --- homeassistant/components/rainbird.py | 40 ++++++++++++---------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/homeassistant/components/rainbird.py b/homeassistant/components/rainbird.py index a5e55623eb7..981548ec3dd 100644 --- a/homeassistant/components/rainbird.py +++ b/homeassistant/components/rainbird.py @@ -1,41 +1,36 @@ """ -Module for interacting with WiFi LNK module of the Rainbird Irrigation system. +Support for Rainbird Irrigation system WiFi LNK Module. -This project has no affiliation with Rainbird. This module works with the -Rainbird LNK WiFi Module. For more information see: -http://www.rainbird.com/landscape/products/controllers/LNK-WiFi.htm - -This module communicates directly towards the IP Address of the WiFi module it -does not support the cloud. You can start/stop the irrigation and get the -currenltly active zone. - -I'm not a Python developer, so sorry for the bad code. I've developed it to -control it from my domtica systems. +For more details about this component, please refer to the documentation at +https://home-assistant.io/components/rainbird/ """ import logging +import voluptuous as vol import homeassistant.helpers as helpers +import homeassistant.helpers.config_validation as cv +from homeassistant.const import ( + CONF_HOST, CONF_PASSWORD) REQUIREMENTS = ['pyrainbird==0.0.7'] -# Home Assistant Setup DOMAIN = 'rainbird' -SERVER = '' -PASSWORD = '' STATE_VAR = 'rainbird.activestation' _LOGGER = logging.getLogger(__name__) +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): - """ - Call from Home Assistant. - - @param hass: default homeassistant hass class - @param config: default homeassistant config class - """ - server = config[DOMAIN].get('stickip') - password = config[DOMAIN].get('password') + """Set up the Rainbird component.""" + server = config[DOMAIN].get(CONF_HOST) + password = config[DOMAIN].get(CONF_PASSWORD) # RainbirdSetup from pyrainbird import RainbirdController @@ -70,7 +65,6 @@ def setup(hass, config): result = controller.stopIrrigation() if result == 1: _LOGGER.info("Stopped irrigation") - print("Success") elif result == 0: _LOGGER.error("Error sending request") else: