diff --git a/.coveragerc b/.coveragerc index d8041b9fe6c..8b7ffe2e966 100644 --- a/.coveragerc +++ b/.coveragerc @@ -416,6 +416,7 @@ omit = homeassistant/components/notify/xmpp.py homeassistant/components/nuimo_controller.py homeassistant/components/prometheus.py + homeassistant/components/rainbird.py homeassistant/components/remote/harmony.py homeassistant/components/remote/itach.py homeassistant/components/scene/hunterdouglas_powerview.py diff --git a/homeassistant/components/rainbird.py b/homeassistant/components/rainbird.py index 5eef9913470..4976b18afc2 100644 --- a/homeassistant/components/rainbird.py +++ b/homeassistant/components/rainbird.py @@ -1,6 +1,20 @@ -import homeassistant.helpers as helpers -import logging +""" +Module for interacting with WiFi LNK module of the Rainbird Irrigation system +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. +""" + +import logging +import homeassistant.helpers as helpers REQUIREMENTS = ['pyrainbird==0.0.7'] @@ -14,6 +28,11 @@ _LOGGER = logging.getLogger(__name__) def setup(hass, config): + """ + Standard setup function Home Assistant + @param hass: default homeassistant hass class + @param config: default homeassistant config class + """ server = config[DOMAIN].get('stickip') password = config[DOMAIN].get('password') @@ -26,34 +45,49 @@ def setup(hass, config): _LOGGER.info("Rainbird Controller set to " + str(server)) def startirrigation(call): + """ + Start Irrigation command towards Rainbird WiFi LNK stick + @param call: should be a home assistant call object with data + station for Zone to sprinkle and duration for the time + """ + station_id = call.data.get('station') duration = call.data.get('duration') _LOGGER.info("Requesting irrigation for " + str(station_id) + " duration " + str(duration)) result = controller.startIrrigation(station_id, duration) - if (result == 1): + if result == 1: _LOGGER.info("Irrigation started on " + str(station_id) + " for " + str(duration)) - elif (result == 0): + elif result == 0: _LOGGER.error("Error sending request") else: _LOGGER.error("Request was not acknowledged!") - def stopirrigation(call): + def stopirrigation(): + """ + Stops the irrigation (if one is running) + """ + _LOGGER.info("Stop request irrigation") result = controller.stopIrrigation() - if (result == 1): + if result == 1: _LOGGER.info("Stopped irrigation") print("Success") - elif (result == 0): + elif result == 0: _LOGGER.error("Error sending request") else: _LOGGER.error("Request was not acknowledged!") def getirrigation(): + """ + Get current active station + @return: integer which station is active + """ + _LOGGER.info("Request irrigation state") result = controller.currentIrrigation() - if (result < 0): + if result < 0: _LOGGER.error("Error sending request") return -1 @@ -65,9 +99,9 @@ def setup(hass, config): hass.services.register(DOMAIN, 'stop_irrigation', stopirrigation) helpers.event.track_time_change( - hass, lambda _: hass.states.set(STATE_VAR, getirrigation()), - year=None, month=None, day=None, - hour=None, minute=None, second=[00, 30] + hass, lambda _: hass.states.set(STATE_VAR, getirrigation()), + year=None, month=None, day=None, + hour=None, minute=None, second=[00, 30] ) _LOGGER.info("Initialized Rainbird Controller") diff --git a/requirements_all.txt b/requirements_all.txt index cf6325e6572..e94ca4ce025 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -686,6 +686,9 @@ pyowm==2.7.1 # homeassistant.components.qwikswitch pyqwikswitch==0.4 +# homeassistant.components.rainbird +pyrainbird==0.0.7 + # homeassistant.components.climate.sensibo pysensibo==1.0.1