From fbd0dbf8ee02bb2712661b3675228125fd0d84fe Mon Sep 17 00:00:00 2001 From: Eric Rolf Date: Sun, 31 Jan 2016 21:39:04 -0500 Subject: [PATCH 01/22] Wink Garage Door Support --- .../components/garage_door/__init__.py | 112 ++++++ homeassistant/components/garage_door/demo.py | 49 +++ .../components/garage_door/services.yaml | 0 homeassistant/components/garage_door/wink.py | 67 ++++ homeassistant/components/wink.py | 4 +- homeassistant/const.py | 3 + requirements_all.txt | 364 +++++++++--------- 7 files changed, 415 insertions(+), 184 deletions(-) create mode 100644 homeassistant/components/garage_door/__init__.py create mode 100644 homeassistant/components/garage_door/demo.py create mode 100644 homeassistant/components/garage_door/services.yaml create mode 100644 homeassistant/components/garage_door/wink.py diff --git a/homeassistant/components/garage_door/__init__.py b/homeassistant/components/garage_door/__init__.py new file mode 100644 index 00000000000..572dd27cd90 --- /dev/null +++ b/homeassistant/components/garage_door/__init__.py @@ -0,0 +1,112 @@ +""" +homeassistant.components.garage_door +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Component to interface with garage doors that can be controlled remotely. + +For more details about this component, please refer to the documentation +at https://home-assistant.io/components/garage_door/ +""" +from datetime import timedelta +import logging +import os + +from homeassistant.config import load_yaml_config_file +from homeassistant.helpers.entity_component import EntityComponent +from homeassistant.helpers.entity import Entity + +from homeassistant.const import ( + STATE_CLOSED, STATE_OPEN, STATE_UNKNOWN, SERVICE_CLOSE, SERVICE_OPEN, + ATTR_ENTITY_ID) +from homeassistant.components import (group, wink) + +DOMAIN = 'garage_door' +SCAN_INTERVAL = 30 + +GROUP_NAME_ALL_GARAGE_DOORS = 'all garage doors' +ENTITY_ID_ALL_GARAGE_DOORS = group.ENTITY_ID_FORMAT.format('all_garage_doors') + +ENTITY_ID_FORMAT = DOMAIN + '.{}' + +ATTR_CLOSED = "closed" + +MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10) + +# Maps discovered services to their platforms +DISCOVERY_PLATFORMS = { + wink.DISCOVER_GARAGE_DOORS: 'wink' +} + +_LOGGER = logging.getLogger(__name__) + + +def is_closed(hass, entity_id=None): + """ Returns if the garage door is closed based on the statemachine. """ + entity_id = entity_id or ENTITY_ID_ALL_GARAGE_DOORS + return hass.states.is_state(entity_id, STATE_CLOSED) + + +def close(hass, entity_id=None): + """ Closes all or specified garage door. """ + data = {ATTR_ENTITY_ID: entity_id} if entity_id else None + hass.services.call(DOMAIN, SERVICE_CLOSE, data) + + +def open(hass, entity_id=None): + """ Open all or specified garage door. """ + data = {ATTR_ENTITY_ID: entity_id} if entity_id else None + hass.services.call(DOMAIN, SERVICE_OPEN, data) + + +def setup(hass, config): + """ Track states and offer events for garage door. """ + component = EntityComponent( + _LOGGER, DOMAIN, hass, SCAN_INTERVAL, DISCOVERY_PLATFORMS, + GROUP_NAME_ALL_GARAGE_DOORS) + component.setup(config) + + def handle_garage_door_service(service): + """ Handles calls to the garage door services. """ + target_locks = component.extract_from_service(service) + + for item in target_locks: + if service.service == SERVICE_CLOSE: + item.close() + else: + item.open() + + if item.should_poll: + item.update_ha_state(True) + + descriptions = load_yaml_config_file( + os.path.join(os.path.dirname(__file__), 'services.yaml')) + hass.services.register(DOMAIN, SERVICE_OPEN, handle_garage_door_service, + descriptions.get(SERVICE_OPEN)) + hass.services.register(DOMAIN, SERVICE_CLOSE, handle_garage_door_service, + descriptions.get(SERVICE_CLOSE)) + + return True + + +class GarageDoorDevice(Entity): + """ Represents a garage door within Home Assistant. """ + # pylint: disable=no-self-use + + @property + def is_closed(self): + """ Is the garage door closed or opened. """ + return None + + def close(self): + """ Closes the garage door. """ + raise NotImplementedError() + + def open(self): + """ Opens the garage door. """ + raise NotImplementedError() + + @property + def state(self): + closed = self.is_closed + if closed is None: + return STATE_UNKNOWN + return STATE_CLOSED if closed else STATE_OPEN diff --git a/homeassistant/components/garage_door/demo.py b/homeassistant/components/garage_door/demo.py new file mode 100644 index 00000000000..30935a0d3ef --- /dev/null +++ b/homeassistant/components/garage_door/demo.py @@ -0,0 +1,49 @@ +""" +homeassistant.components.garage_door.demo +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Demo platform that has two fake garage doors. +""" +from homeassistant.components.garage_door import GarageDoorDevice +from homeassistant.const import STATE_CLOSED, STATE_OPEN + + +# pylint: disable=unused-argument +def setup_platform(hass, config, add_devices_callback, discovery_info=None): + """ Find and return demo garage doors. """ + add_devices_callback([ + DemoGarageDoor('Left Garage Door', STATE_CLOSED), + DemoGarageDoor('Right Garage Door', STATE_OPEN) + ]) + + +class DemoGarageDoor(GarageDoorDevice): + """ Provides a demo garage door. """ + def __init__(self, name, state): + self._name = name + self._state = state + + @property + def should_poll(self): + """ No polling needed for a demo garage door. """ + return False + + @property + def name(self): + """ Returns the name of the device if any. """ + return self._name + + @property + def is_closed(self): + """ True if device is closed. """ + return self._state == STATE_CLOSED + + def close(self, **kwargs): + """ Close the device. """ + self._state = STATE_CLOSED + self.update_ha_state() + + def open(self, **kwargs): + """ Open the device. """ + self._state = STATE_OPEN + self.update_ha_state() diff --git a/homeassistant/components/garage_door/services.yaml b/homeassistant/components/garage_door/services.yaml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/homeassistant/components/garage_door/wink.py b/homeassistant/components/garage_door/wink.py new file mode 100644 index 00000000000..8283575f19d --- /dev/null +++ b/homeassistant/components/garage_door/wink.py @@ -0,0 +1,67 @@ +""" +homeassistant.components.garage_door.wink +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Support for Wink garage doors. + +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/garage_door.wink/ +""" +import logging + +from homeassistant.components.garage_door import GarageDoorDevice +from homeassistant.const import CONF_ACCESS_TOKEN + +REQUIREMENTS = ['python-wink==0.4.2'] + + +def setup_platform(hass, config, add_devices, discovery_info=None): + """ Sets up the Wink platform. """ + import pywink + + if discovery_info is None: + token = config.get(CONF_ACCESS_TOKEN) + + if token is None: + logging.getLogger(__name__).error( + "Missing wink access_token. " + "Get one at https://winkbearertoken.appspot.com/") + return + + pywink.set_bearer_token(token) + + add_devices(WinkGarageDoorDevice(door) for door in + pywink.get_garage_doors()) + + +class WinkGarageDoorDevice(GarageDoorDevice): + """ Represents a Wink garage door. """ + + def __init__(self, wink): + self.wink = wink + + @property + def unique_id(self): + """ Returns the id of this wink garage door """ + return "{}.{}".format(self.__class__, self.wink.device_id()) + + @property + def name(self): + """ Returns the name of the garage door if any. """ + return self.wink.name() + + def update(self): + """ Update the state of the garage door. """ + self.wink.update_state() + + @property + def is_closed(self): + """ True if device is closed. """ + return self.wink.state() == 0 + + def close(self): + """ Close the device. """ + self.wink.set_state(0) + + def open(self): + """ Open the device. """ + self.wink.set_state(1) diff --git a/homeassistant/components/wink.py b/homeassistant/components/wink.py index 29a7a5537d1..4b8bac4d1af 100644 --- a/homeassistant/components/wink.py +++ b/homeassistant/components/wink.py @@ -22,6 +22,7 @@ DISCOVER_LIGHTS = "wink.lights" DISCOVER_SWITCHES = "wink.switches" DISCOVER_SENSORS = "wink.sensors" DISCOVER_LOCKS = "wink.locks" +DISCOVER_GARAGE_DOORS = "wink.garage_doors" def setup(hass, config): @@ -42,7 +43,8 @@ def setup(hass, config): pywink.get_powerstrip_outlets, DISCOVER_SWITCHES), ('sensor', lambda: pywink.get_sensors or pywink.get_eggtrays, DISCOVER_SENSORS), - ('lock', pywink.get_locks, DISCOVER_LOCKS)): + ('lock', pywink.get_locks, DISCOVER_LOCKS), + ('garage_door', pywink.get_garage_doors, DISCOVER_GARAGE_DOORS)): if func_exists(): component = get_component(component_name) diff --git a/homeassistant/const.py b/homeassistant/const.py index cd711df44cd..b5ebdb16e2b 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -151,6 +151,9 @@ SERVICE_ALARM_TRIGGER = "alarm_trigger" SERVICE_LOCK = "lock" SERVICE_UNLOCK = "unlock" +SERVICE_OPEN = "open" +SERVICE_CLOSE = "close" + SERVICE_MOVE_UP = 'move_up' SERVICE_MOVE_DOWN = 'move_down' SERVICE_STOP = 'stop' diff --git a/requirements_all.txt b/requirements_all.txt index 9e0e159a1d2..b0c07fa9ee1 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -6,146 +6,17 @@ pip>=7.0.0 vincenty==0.1.3 jinja2>=2.8 -# homeassistant.components.isy994 -PyISY==1.0.5 +# homeassistant.components.alarm_control_panel.alarmdotcom +https://github.com/Xorso/pyalarmdotcom/archive/0.0.7.zip#pyalarmdotcom==0.0.7 # homeassistant.components.arduino PyMata==2.07a -# homeassistant.components.rpi_gpio -# RPi.GPIO==0.6.1 - -# homeassistant.components.media_player.sonos -SoCo==0.11.1 - -# homeassistant.components.notify.twitter -TwitterAPI==2.3.6 - -# homeassistant.components.sun -astral==0.9 - -# homeassistant.components.light.blinksticklight -blinkstick==1.1.7 - -# homeassistant.components.sensor.bitcoin -blockchain==1.2.1 - -# homeassistant.components.notify.xmpp -dnspython3==1.12.0 - -# homeassistant.components.sensor.dweet -dweepy==0.2.0 - -# homeassistant.components.sensor.eliqonline -eliqonline==1.0.11 - -# homeassistant.components.thermostat.honeywell -evohomeclient==0.2.4 - -# homeassistant.components.notify.free_mobile -freesms==0.1.0 - -# homeassistant.components.device_tracker.fritz -# fritzconnection==0.4.6 - # homeassistant.components.conversation fuzzywuzzy==0.8.0 -# homeassistant.components.thermostat.heatmiser -heatmiserV3==0.9.1 - -# homeassistant.components.switch.hikvisioncam -hikvision==0.4 - -# homeassistant.components.sensor.dht -# http://github.com/mala-zaba/Adafruit_Python_DHT/archive/4101340de8d2457dd194bca1e8d11cbfc237e919.zip#Adafruit_DHT==1.1.0 - -# homeassistant.components.rfxtrx -https://github.com/Danielhiversen/pyRFXtrx/archive/0.2.zip#RFXtrx==0.2 - -# homeassistant.components.sensor.netatmo -https://github.com/HydrelioxGitHub/netatmo-api-python/archive/43ff238a0122b0939a0dc4e8836b6782913fb6e2.zip#lnetatmo==0.4.0 - -# homeassistant.components.alarm_control_panel.alarmdotcom -https://github.com/Xorso/pyalarmdotcom/archive/0.0.7.zip#pyalarmdotcom==0.0.7 - -# homeassistant.components.modbus -https://github.com/bashwork/pymodbus/archive/d7fc4f1cc975631e0a9011390e8017f64b612661.zip#pymodbus==1.2.0 - -# homeassistant.components.sensor.sabnzbd -https://github.com/jamespcole/home-assistant-nzb-clients/archive/616cad59154092599278661af17e2a9f2cf5e2a9.zip#python-sabnzbd==0.1 - -# homeassistant.components.ecobee -https://github.com/nkgilley/python-ecobee-api/archive/92a2f330cbaf601d0618456fdd97e5a8c42c1c47.zip#python-ecobee==0.0.4 - -# homeassistant.components.switch.edimax -https://github.com/rkabadi/pyedimax/archive/365301ce3ff26129a7910c501ead09ea625f3700.zip#pyedimax==0.1 - -# homeassistant.components.sensor.temper -https://github.com/rkabadi/temper-python/archive/3dbdaf2d87b8db9a3cd6e5585fc704537dd2d09b.zip#temperusb==1.2.3 - -# homeassistant.components.mysensors -https://github.com/theolind/pymysensors/archive/005bff4c5ca7a56acd30e816bc3bcdb5cb2d46fd.zip#pymysensors==0.4 - -# homeassistant.components.notify.googlevoice -https://github.com/w1ll1am23/pygooglevoice-sms/archive/7c5ee9969b97a7992fc86a753fe9f20e3ffa3f7c.zip#pygooglevoice-sms==0.0.1 - -# homeassistant.components.influxdb -influxdb==2.11.0 - -# homeassistant.components.insteon_hub -insteon_hub==0.4.5 - -# homeassistant.components.media_player.kodi -jsonrpc-requests==0.1 - -# homeassistant.components.light.lifx -liffylights==0.9.4 - -# homeassistant.components.light.limitlessled -limitlessled==1.0.0 - -# homeassistant.components.discovery -netdisco==0.5.2 - -# homeassistant.components.switch.orvibo -orvibo==1.1.1 - -# homeassistant.components.mqtt -paho-mqtt==1.1 - -# homeassistant.components.device_tracker.aruba -pexpect==4.0.1 - -# homeassistant.components.light.hue -phue==0.8 - -# homeassistant.components.media_player.plex -plexapi==1.1.0 - -# homeassistant.components.thermostat.proliphix -proliphix==0.1.0 - -# homeassistant.components.sensor.systemmonitor -psutil==3.4.2 - -# homeassistant.components.notify.pushbullet -pushbullet.py==0.9.0 - -# homeassistant.components.notify.pushetta -pushetta==1.0.15 - -# homeassistant.components.sensor.cpuspeed -py-cpuinfo==0.1.8 - -# homeassistant.components.media_player.cast -pychromecast==0.7.1 - -# homeassistant.components.zwave -pydispatcher==2.0.5 - -# homeassistant.components.ifttt -pyfttt==0.3 +# homeassistant.components.device_tracker.fritz +# fritzconnection==0.4.6 # homeassistant.components.device_tracker.icloud pyicloud==0.7.2 @@ -153,86 +24,213 @@ pyicloud==0.7.2 # homeassistant.components.device_tracker.netgear pynetgear==0.3.2 -# homeassistant.components.sensor.openweathermap -pyowm==2.3.0 +# homeassistant.components.device_tracker.nmap_tracker +python-nmap==0.4.3 # homeassistant.components.device_tracker.snmp pysnmp==4.2.5 -# homeassistant.components.sensor.forecast -python-forecastio==1.3.3 +# homeassistant.components.discovery +netdisco==0.5.2 -# homeassistant.components.media_player.mpd -python-mpd2==0.5.4 +# homeassistant.components.ecobee +https://github.com/nkgilley/python-ecobee-api/archive/92a2f330cbaf601d0618456fdd97e5a8c42c1c47.zip#python-ecobee==0.0.4 -# homeassistant.components.nest -python-nest==2.6.0 +# homeassistant.components.ifttt +pyfttt==0.3 -# homeassistant.components.device_tracker.nmap_tracker -python-nmap==0.4.3 +# homeassistant.components.influxdb +influxdb==2.11.0 -# homeassistant.components.notify.pushover -python-pushover==0.2 +# homeassistant.components.insteon_hub +insteon_hub==0.4.5 -# homeassistant.components.statsd -python-statsd==1.7.2 - -# homeassistant.components.notify.telegram -python-telegram-bot==3.2.0 - -# homeassistant.components.sensor.twitch -python-twitch==1.2.0 - -# homeassistant.components.wink -# homeassistant.components.light.wink -# homeassistant.components.lock.wink -# homeassistant.components.sensor.wink -# homeassistant.components.switch.wink -python-wink==0.4.2 +# homeassistant.components.isy994 +PyISY==1.0.5 # homeassistant.components.keyboard pyuserinput==0.1.9 -# homeassistant.components.light.vera -# homeassistant.components.sensor.vera -# homeassistant.components.switch.vera -pyvera==0.2.7 +# homeassistant.components.light.blinksticklight +blinkstick==1.1.7 -# homeassistant.components.switch.wemo -pywemo==0.3.8 +# homeassistant.components.light.hue +phue==0.8 -# homeassistant.components.thermostat.radiotherm -radiotherm==1.2 +# homeassistant.components.light.lifx +liffylights==0.9.3 -# homeassistant.components.media_player.samsungtv -samsungctl==0.5.1 - -# homeassistant.components.scsgate -scsgate==0.1.0 - -# homeassistant.components.notify.slack -slacker==0.6.8 - -# homeassistant.components.notify.xmpp -sleekxmpp==1.3.1 +# homeassistant.components.light.limitlessled +limitlessled==1.0.0 # homeassistant.components.light.tellstick # homeassistant.components.sensor.tellstick # homeassistant.components.switch.tellstick tellcore-py==1.1.2 -# homeassistant.components.tellduslive -tellive-py==0.5.2 +# homeassistant.components.light.vera +# homeassistant.components.sensor.vera +# homeassistant.components.switch.vera +pyvera==0.2.7 + +# homeassistant.components.wink +# homeassistant.components.light.wink +# homeassistant.components.lock.wink +# homeassistant.components.sensor.wink +# homeassistant.components.switch.wink +# homeassistant.components.garage_door.wink +python-wink==0.4.2 + +# homeassistant.components.media_player.cast +pychromecast==0.7.1 + +# homeassistant.components.media_player.kodi +jsonrpc-requests==0.1 + +# homeassistant.components.media_player.mpd +python-mpd2==0.5.4 + +# homeassistant.components.media_player.plex +plexapi==1.1.0 + +# homeassistant.components.media_player.samsungtv +samsungctl==0.5.1 + +# homeassistant.components.media_player.sonos +SoCo==0.11.1 + +# homeassistant.components.modbus +https://github.com/bashwork/pymodbus/archive/d7fc4f1cc975631e0a9011390e8017f64b612661.zip#pymodbus==1.2.0 + +# homeassistant.components.mqtt +paho-mqtt==1.1 + +# homeassistant.components.mysensors +https://github.com/theolind/pymysensors/archive/005bff4c5ca7a56acd30e816bc3bcdb5cb2d46fd.zip#pymysensors==0.4 + +# homeassistant.components.nest +python-nest==2.6.0 + +# homeassistant.components.notify.free_mobile +freesms==0.1.0 + +# homeassistant.components.notify.googlevoice +https://github.com/w1ll1am23/pygooglevoice-sms/archive/7c5ee9969b97a7992fc86a753fe9f20e3ffa3f7c.zip#pygooglevoice-sms==0.0.1 + +# homeassistant.components.notify.pushbullet +pushbullet.py==0.9.0 + +# homeassistant.components.notify.pushetta +pushetta==1.0.15 + +# homeassistant.components.notify.pushover +python-pushover==0.2 + +# homeassistant.components.notify.slack +slacker==0.6.8 + +# homeassistant.components.notify.telegram +python-telegram-bot==3.2.0 + +# homeassistant.components.notify.twitter +TwitterAPI==2.3.6 + +# homeassistant.components.notify.xmpp +sleekxmpp==1.3.1 + +# homeassistant.components.notify.xmpp +dnspython3==1.12.0 + +# homeassistant.components.rfxtrx +https://github.com/Danielhiversen/pyRFXtrx/archive/0.2.zip#RFXtrx==0.2 + +# homeassistant.components.rpi_gpio +# RPi.GPIO==0.6.1 + +# homeassistant.components.scsgate +scsgate==0.1.0 + +# homeassistant.components.sensor.bitcoin +blockchain==1.2.1 + +# homeassistant.components.sensor.cpuspeed +py-cpuinfo==0.1.8 + +# homeassistant.components.sensor.dht +# http://github.com/mala-zaba/Adafruit_Python_DHT/archive/4101340de8d2457dd194bca1e8d11cbfc237e919.zip#Adafruit_DHT==1.1.0 + +# homeassistant.components.sensor.dweet +dweepy==0.2.0 + +# homeassistant.components.sensor.eliqonline +eliqonline==1.0.11 + +# homeassistant.components.sensor.forecast +python-forecastio==1.3.3 + +# homeassistant.components.sensor.netatmo +https://github.com/HydrelioxGitHub/netatmo-api-python/archive/43ff238a0122b0939a0dc4e8836b6782913fb6e2.zip#lnetatmo==0.4.0 + +# homeassistant.components.sensor.openweathermap +pyowm==2.3.0 + +# homeassistant.components.sensor.sabnzbd +https://github.com/jamespcole/home-assistant-nzb-clients/archive/616cad59154092599278661af17e2a9f2cf5e2a9.zip#python-sabnzbd==0.1 + +# homeassistant.components.sensor.systemmonitor +psutil==3.4.2 + +# homeassistant.components.sensor.temper +https://github.com/rkabadi/temper-python/archive/3dbdaf2d87b8db9a3cd6e5585fc704537dd2d09b.zip#temperusb==1.2.3 # homeassistant.components.sensor.transmission # homeassistant.components.switch.transmission transmissionrpc==0.11 +# homeassistant.components.sensor.twitch +python-twitch==1.2.0 + +# homeassistant.components.sensor.yr +xmltodict + +# homeassistant.components.statsd +python-statsd==1.7.2 + +# homeassistant.components.sun +astral==0.9 + +# homeassistant.components.switch.edimax +https://github.com/rkabadi/pyedimax/archive/365301ce3ff26129a7910c501ead09ea625f3700.zip#pyedimax==0.1 + +# homeassistant.components.switch.hikvisioncam +hikvision==0.4 + +# homeassistant.components.switch.orvibo +orvibo==1.1.1 + +# homeassistant.components.switch.wemo +pywemo==0.3.8 + +# homeassistant.components.tellduslive +tellive-py==0.5.2 + +# homeassistant.components.thermostat.heatmiser +heatmiserV3==0.9.1 + +# homeassistant.components.thermostat.honeywell +evohomeclient==0.2.4 + +# homeassistant.components.thermostat.proliphix +proliphix==0.1.0 + +# homeassistant.components.thermostat.radiotherm +radiotherm==1.2 + # homeassistant.components.verisure vsure==0.5.0 # homeassistant.components.zigbee xbee-helper==0.0.6 -# homeassistant.components.sensor.yr -xmltodict +# homeassistant.components.zwave +pydispatcher==2.0.5 From 7ef207552096dd812e097475b49f1241a7357662 Mon Sep 17 00:00:00 2001 From: Eric Rolf Date: Fri, 5 Feb 2016 14:20:06 -0500 Subject: [PATCH 02/22] Updated requirements_all.txt --- requirements_all.txt | 373 ++++++++++++++++++++++--------------------- 1 file changed, 188 insertions(+), 185 deletions(-) diff --git a/requirements_all.txt b/requirements_all.txt index b0c07fa9ee1..4ead1a361b3 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -6,158 +6,32 @@ pip>=7.0.0 vincenty==0.1.3 jinja2>=2.8 -# homeassistant.components.alarm_control_panel.alarmdotcom -https://github.com/Xorso/pyalarmdotcom/archive/0.0.7.zip#pyalarmdotcom==0.0.7 +# homeassistant.components.isy994 +PyISY==1.0.5 # homeassistant.components.arduino PyMata==2.07a -# homeassistant.components.conversation -fuzzywuzzy==0.8.0 - -# homeassistant.components.device_tracker.fritz -# fritzconnection==0.4.6 - -# homeassistant.components.device_tracker.icloud -pyicloud==0.7.2 - -# homeassistant.components.device_tracker.netgear -pynetgear==0.3.2 - -# homeassistant.components.device_tracker.nmap_tracker -python-nmap==0.4.3 - -# homeassistant.components.device_tracker.snmp -pysnmp==4.2.5 - -# homeassistant.components.discovery -netdisco==0.5.2 - -# homeassistant.components.ecobee -https://github.com/nkgilley/python-ecobee-api/archive/92a2f330cbaf601d0618456fdd97e5a8c42c1c47.zip#python-ecobee==0.0.4 - -# homeassistant.components.ifttt -pyfttt==0.3 - -# homeassistant.components.influxdb -influxdb==2.11.0 - -# homeassistant.components.insteon_hub -insteon_hub==0.4.5 - -# homeassistant.components.isy994 -PyISY==1.0.5 - -# homeassistant.components.keyboard -pyuserinput==0.1.9 - -# homeassistant.components.light.blinksticklight -blinkstick==1.1.7 - -# homeassistant.components.light.hue -phue==0.8 - -# homeassistant.components.light.lifx -liffylights==0.9.3 - -# homeassistant.components.light.limitlessled -limitlessled==1.0.0 - -# homeassistant.components.light.tellstick -# homeassistant.components.sensor.tellstick -# homeassistant.components.switch.tellstick -tellcore-py==1.1.2 - -# homeassistant.components.light.vera -# homeassistant.components.sensor.vera -# homeassistant.components.switch.vera -pyvera==0.2.7 - -# homeassistant.components.wink -# homeassistant.components.light.wink -# homeassistant.components.lock.wink -# homeassistant.components.sensor.wink -# homeassistant.components.switch.wink -# homeassistant.components.garage_door.wink -python-wink==0.4.2 - -# homeassistant.components.media_player.cast -pychromecast==0.7.1 - -# homeassistant.components.media_player.kodi -jsonrpc-requests==0.1 - -# homeassistant.components.media_player.mpd -python-mpd2==0.5.4 - -# homeassistant.components.media_player.plex -plexapi==1.1.0 - -# homeassistant.components.media_player.samsungtv -samsungctl==0.5.1 +# homeassistant.components.rpi_gpio +# RPi.GPIO==0.6.1 # homeassistant.components.media_player.sonos SoCo==0.11.1 -# homeassistant.components.modbus -https://github.com/bashwork/pymodbus/archive/d7fc4f1cc975631e0a9011390e8017f64b612661.zip#pymodbus==1.2.0 - -# homeassistant.components.mqtt -paho-mqtt==1.1 - -# homeassistant.components.mysensors -https://github.com/theolind/pymysensors/archive/005bff4c5ca7a56acd30e816bc3bcdb5cb2d46fd.zip#pymysensors==0.4 - -# homeassistant.components.nest -python-nest==2.6.0 - -# homeassistant.components.notify.free_mobile -freesms==0.1.0 - -# homeassistant.components.notify.googlevoice -https://github.com/w1ll1am23/pygooglevoice-sms/archive/7c5ee9969b97a7992fc86a753fe9f20e3ffa3f7c.zip#pygooglevoice-sms==0.0.1 - -# homeassistant.components.notify.pushbullet -pushbullet.py==0.9.0 - -# homeassistant.components.notify.pushetta -pushetta==1.0.15 - -# homeassistant.components.notify.pushover -python-pushover==0.2 - -# homeassistant.components.notify.slack -slacker==0.6.8 - -# homeassistant.components.notify.telegram -python-telegram-bot==3.2.0 - # homeassistant.components.notify.twitter TwitterAPI==2.3.6 -# homeassistant.components.notify.xmpp -sleekxmpp==1.3.1 +# homeassistant.components.sun +astral==0.9 -# homeassistant.components.notify.xmpp -dnspython3==1.12.0 - -# homeassistant.components.rfxtrx -https://github.com/Danielhiversen/pyRFXtrx/archive/0.2.zip#RFXtrx==0.2 - -# homeassistant.components.rpi_gpio -# RPi.GPIO==0.6.1 - -# homeassistant.components.scsgate -scsgate==0.1.0 +# homeassistant.components.light.blinksticklight +blinkstick==1.1.7 # homeassistant.components.sensor.bitcoin blockchain==1.2.1 -# homeassistant.components.sensor.cpuspeed -py-cpuinfo==0.1.8 - -# homeassistant.components.sensor.dht -# http://github.com/mala-zaba/Adafruit_Python_DHT/archive/4101340de8d2457dd194bca1e8d11cbfc237e919.zip#Adafruit_DHT==1.1.0 +# homeassistant.components.notify.xmpp +dnspython3==1.12.0 # homeassistant.components.sensor.dweet dweepy==0.2.0 @@ -165,72 +39,201 @@ dweepy==0.2.0 # homeassistant.components.sensor.eliqonline eliqonline==1.0.11 -# homeassistant.components.sensor.forecast -python-forecastio==1.3.3 +# homeassistant.components.thermostat.honeywell +evohomeclient==0.2.4 -# homeassistant.components.sensor.netatmo -https://github.com/HydrelioxGitHub/netatmo-api-python/archive/43ff238a0122b0939a0dc4e8836b6782913fb6e2.zip#lnetatmo==0.4.0 +# homeassistant.components.notify.free_mobile +freesms==0.1.0 -# homeassistant.components.sensor.openweathermap -pyowm==2.3.0 +# homeassistant.components.device_tracker.fritz +# fritzconnection==0.4.6 -# homeassistant.components.sensor.sabnzbd -https://github.com/jamespcole/home-assistant-nzb-clients/archive/616cad59154092599278661af17e2a9f2cf5e2a9.zip#python-sabnzbd==0.1 - -# homeassistant.components.sensor.systemmonitor -psutil==3.4.2 - -# homeassistant.components.sensor.temper -https://github.com/rkabadi/temper-python/archive/3dbdaf2d87b8db9a3cd6e5585fc704537dd2d09b.zip#temperusb==1.2.3 - -# homeassistant.components.sensor.transmission -# homeassistant.components.switch.transmission -transmissionrpc==0.11 - -# homeassistant.components.sensor.twitch -python-twitch==1.2.0 - -# homeassistant.components.sensor.yr -xmltodict - -# homeassistant.components.statsd -python-statsd==1.7.2 - -# homeassistant.components.sun -astral==0.9 - -# homeassistant.components.switch.edimax -https://github.com/rkabadi/pyedimax/archive/365301ce3ff26129a7910c501ead09ea625f3700.zip#pyedimax==0.1 - -# homeassistant.components.switch.hikvisioncam -hikvision==0.4 - -# homeassistant.components.switch.orvibo -orvibo==1.1.1 - -# homeassistant.components.switch.wemo -pywemo==0.3.8 - -# homeassistant.components.tellduslive -tellive-py==0.5.2 +# homeassistant.components.conversation +fuzzywuzzy==0.8.0 # homeassistant.components.thermostat.heatmiser heatmiserV3==0.9.1 -# homeassistant.components.thermostat.honeywell -evohomeclient==0.2.4 +# homeassistant.components.switch.hikvisioncam +hikvision==0.4 + +# homeassistant.components.sensor.dht +# http://github.com/mala-zaba/Adafruit_Python_DHT/archive/4101340de8d2457dd194bca1e8d11cbfc237e919.zip#Adafruit_DHT==1.1.0 + +# homeassistant.components.rfxtrx +https://github.com/Danielhiversen/pyRFXtrx/archive/0.2.zip#RFXtrx==0.2 + +# homeassistant.components.sensor.netatmo +https://github.com/HydrelioxGitHub/netatmo-api-python/archive/43ff238a0122b0939a0dc4e8836b6782913fb6e2.zip#lnetatmo==0.4.0 + +# homeassistant.components.alarm_control_panel.alarmdotcom +https://github.com/Xorso/pyalarmdotcom/archive/0.0.7.zip#pyalarmdotcom==0.0.7 + +# homeassistant.components.modbus +https://github.com/bashwork/pymodbus/archive/d7fc4f1cc975631e0a9011390e8017f64b612661.zip#pymodbus==1.2.0 + +# homeassistant.components.sensor.sabnzbd +https://github.com/jamespcole/home-assistant-nzb-clients/archive/616cad59154092599278661af17e2a9f2cf5e2a9.zip#python-sabnzbd==0.1 + +# homeassistant.components.ecobee +https://github.com/nkgilley/python-ecobee-api/archive/92a2f330cbaf601d0618456fdd97e5a8c42c1c47.zip#python-ecobee==0.0.4 + +# homeassistant.components.switch.edimax +https://github.com/rkabadi/pyedimax/archive/365301ce3ff26129a7910c501ead09ea625f3700.zip#pyedimax==0.1 + +# homeassistant.components.sensor.temper +https://github.com/rkabadi/temper-python/archive/3dbdaf2d87b8db9a3cd6e5585fc704537dd2d09b.zip#temperusb==1.2.3 + +# homeassistant.components.mysensors +https://github.com/theolind/pymysensors/archive/005bff4c5ca7a56acd30e816bc3bcdb5cb2d46fd.zip#pymysensors==0.4 + +# homeassistant.components.notify.googlevoice +https://github.com/w1ll1am23/pygooglevoice-sms/archive/7c5ee9969b97a7992fc86a753fe9f20e3ffa3f7c.zip#pygooglevoice-sms==0.0.1 + +# homeassistant.components.influxdb +influxdb==2.11.0 + +# homeassistant.components.insteon_hub +insteon_hub==0.4.5 + +# homeassistant.components.media_player.kodi +jsonrpc-requests==0.1 + +# homeassistant.components.light.lifx +liffylights==0.9.4 + +# homeassistant.components.light.limitlessled +limitlessled==1.0.0 + +# homeassistant.components.discovery +netdisco==0.5.2 + +# homeassistant.components.switch.orvibo +orvibo==1.1.1 + +# homeassistant.components.mqtt +paho-mqtt==1.1 + +# homeassistant.components.device_tracker.aruba +pexpect==4.0.1 + +# homeassistant.components.light.hue +phue==0.8 + +# homeassistant.components.media_player.plex +plexapi==1.1.0 # homeassistant.components.thermostat.proliphix proliphix==0.1.0 +# homeassistant.components.sensor.systemmonitor +psutil==3.4.2 + +# homeassistant.components.notify.pushbullet +pushbullet.py==0.9.0 + +# homeassistant.components.notify.pushetta +pushetta==1.0.15 + +# homeassistant.components.sensor.cpuspeed +py-cpuinfo==0.1.8 + +# homeassistant.components.media_player.cast +pychromecast==0.7.1 + +# homeassistant.components.zwave +pydispatcher==2.0.5 + +# homeassistant.components.ifttt +pyfttt==0.3 + +# homeassistant.components.device_tracker.icloud +pyicloud==0.7.2 + +# homeassistant.components.device_tracker.netgear +pynetgear==0.3.2 + +# homeassistant.components.sensor.openweathermap +pyowm==2.3.0 + +# homeassistant.components.device_tracker.snmp +pysnmp==4.2.5 + +# homeassistant.components.sensor.forecast +python-forecastio==1.3.3 + +# homeassistant.components.media_player.mpd +python-mpd2==0.5.4 + +# homeassistant.components.nest +python-nest==2.6.0 + +# homeassistant.components.device_tracker.nmap_tracker +python-nmap==0.4.3 + +# homeassistant.components.notify.pushover +python-pushover==0.2 + +# homeassistant.components.statsd +python-statsd==1.7.2 + +# homeassistant.components.notify.telegram +python-telegram-bot==3.2.0 + +# homeassistant.components.sensor.twitch +python-twitch==1.2.0 + +# homeassistant.components.wink +# homeassistant.components.garage_door.wink +# homeassistant.components.light.wink +# homeassistant.components.lock.wink +# homeassistant.components.sensor.wink +# homeassistant.components.switch.wink +python-wink==0.4.2 + +# homeassistant.components.keyboard +pyuserinput==0.1.9 + +# homeassistant.components.light.vera +# homeassistant.components.sensor.vera +# homeassistant.components.switch.vera +pyvera==0.2.7 + +# homeassistant.components.switch.wemo +pywemo==0.3.8 + # homeassistant.components.thermostat.radiotherm radiotherm==1.2 +# homeassistant.components.media_player.samsungtv +samsungctl==0.5.1 + +# homeassistant.components.scsgate +scsgate==0.1.0 + +# homeassistant.components.notify.slack +slacker==0.6.8 + +# homeassistant.components.notify.xmpp +sleekxmpp==1.3.1 + +# homeassistant.components.light.tellstick +# homeassistant.components.sensor.tellstick +# homeassistant.components.switch.tellstick +tellcore-py==1.1.2 + +# homeassistant.components.tellduslive +tellive-py==0.5.2 + +# homeassistant.components.sensor.transmission +# homeassistant.components.switch.transmission +transmissionrpc==0.11 + # homeassistant.components.verisure vsure==0.5.0 # homeassistant.components.zigbee xbee-helper==0.0.6 -# homeassistant.components.zwave -pydispatcher==2.0.5 +# homeassistant.components.sensor.yr +xmltodict From ec88733b57ea975153f8e3e04d8083b3b6838b4f Mon Sep 17 00:00:00 2001 From: Eric Rolf Date: Fri, 5 Feb 2016 15:10:53 -0500 Subject: [PATCH 03/22] Refactor Method Name For Open and Close. --- homeassistant/components/garage_door/__init__.py | 12 ++++++------ homeassistant/components/garage_door/wink.py | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/garage_door/__init__.py b/homeassistant/components/garage_door/__init__.py index 572dd27cd90..7854d33cb17 100644 --- a/homeassistant/components/garage_door/__init__.py +++ b/homeassistant/components/garage_door/__init__.py @@ -45,13 +45,13 @@ def is_closed(hass, entity_id=None): return hass.states.is_state(entity_id, STATE_CLOSED) -def close(hass, entity_id=None): +def close_door(hass, entity_id=None): """ Closes all or specified garage door. """ data = {ATTR_ENTITY_ID: entity_id} if entity_id else None hass.services.call(DOMAIN, SERVICE_CLOSE, data) -def open(hass, entity_id=None): +def open_door(hass, entity_id=None): """ Open all or specified garage door. """ data = {ATTR_ENTITY_ID: entity_id} if entity_id else None hass.services.call(DOMAIN, SERVICE_OPEN, data) @@ -70,9 +70,9 @@ def setup(hass, config): for item in target_locks: if service.service == SERVICE_CLOSE: - item.close() + item.close_door() else: - item.open() + item.open_door() if item.should_poll: item.update_ha_state(True) @@ -96,11 +96,11 @@ class GarageDoorDevice(Entity): """ Is the garage door closed or opened. """ return None - def close(self): + def close_door(self): """ Closes the garage door. """ raise NotImplementedError() - def open(self): + def open_door(self): """ Opens the garage door. """ raise NotImplementedError() diff --git a/homeassistant/components/garage_door/wink.py b/homeassistant/components/garage_door/wink.py index 8283575f19d..5b43ff4c032 100644 --- a/homeassistant/components/garage_door/wink.py +++ b/homeassistant/components/garage_door/wink.py @@ -58,10 +58,10 @@ class WinkGarageDoorDevice(GarageDoorDevice): """ True if device is closed. """ return self.wink.state() == 0 - def close(self): + def close_door(self): """ Close the device. """ self.wink.set_state(0) - def open(self): + def open_door(self): """ Open the device. """ self.wink.set_state(1) From 6fc68e9c8a8550b74df35be839733d1817cb6732 Mon Sep 17 00:00:00 2001 From: Eric Rolf Date: Fri, 5 Feb 2016 15:16:56 -0500 Subject: [PATCH 04/22] Forgot to refactor demo. --- homeassistant/components/garage_door/demo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/garage_door/demo.py b/homeassistant/components/garage_door/demo.py index 30935a0d3ef..0562383a8bd 100644 --- a/homeassistant/components/garage_door/demo.py +++ b/homeassistant/components/garage_door/demo.py @@ -38,12 +38,12 @@ class DemoGarageDoor(GarageDoorDevice): """ True if device is closed. """ return self._state == STATE_CLOSED - def close(self, **kwargs): + def close_door(self, **kwargs): """ Close the device. """ self._state = STATE_CLOSED self.update_ha_state() - def open(self, **kwargs): + def open_door(self, **kwargs): """ Open the device. """ self._state = STATE_OPEN self.update_ha_state() From 7cdcb800a9dfe38672006008a0e312504c7558de Mon Sep 17 00:00:00 2001 From: Eric Rolf Date: Thu, 11 Feb 2016 07:41:42 -0500 Subject: [PATCH 05/22] Updated coveragec, cleaned up constants, added test for demo. --- .coveragerc | 2 +- .../components/garage_door/__init__.py | 20 +++----- tests/components/garage_door/__init__.py | 0 tests/components/garage_door/test_demo.py | 51 +++++++++++++++++++ 4 files changed, 60 insertions(+), 13 deletions(-) create mode 100644 tests/components/garage_door/__init__.py create mode 100644 tests/components/garage_door/test_demo.py diff --git a/.coveragerc b/.coveragerc index 611273b5288..f9646e689fc 100644 --- a/.coveragerc +++ b/.coveragerc @@ -144,7 +144,7 @@ omit = homeassistant/components/thermostat/honeywell.py homeassistant/components/thermostat/proliphix.py homeassistant/components/thermostat/radiotherm.py - + homeassistant/components/garage_door/wink.py [report] # Regexes for lines to exclude from consideration diff --git a/homeassistant/components/garage_door/__init__.py b/homeassistant/components/garage_door/__init__.py index 7854d33cb17..ebaa37a78c9 100644 --- a/homeassistant/components/garage_door/__init__.py +++ b/homeassistant/components/garage_door/__init__.py @@ -6,7 +6,7 @@ Component to interface with garage doors that can be controlled remotely. For more details about this component, please refer to the documentation at https://home-assistant.io/components/garage_door/ """ -from datetime import timedelta + import logging import os @@ -27,10 +27,6 @@ ENTITY_ID_ALL_GARAGE_DOORS = group.ENTITY_ID_FORMAT.format('all_garage_doors') ENTITY_ID_FORMAT = DOMAIN + '.{}' -ATTR_CLOSED = "closed" - -MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10) - # Maps discovered services to their platforms DISCOVERY_PLATFORMS = { wink.DISCOVER_GARAGE_DOORS: 'wink' @@ -38,20 +34,19 @@ DISCOVERY_PLATFORMS = { _LOGGER = logging.getLogger(__name__) - def is_closed(hass, entity_id=None): """ Returns if the garage door is closed based on the statemachine. """ entity_id = entity_id or ENTITY_ID_ALL_GARAGE_DOORS return hass.states.is_state(entity_id, STATE_CLOSED) -def close_door(hass, entity_id=None): +def close(hass, entity_id=None): """ Closes all or specified garage door. """ data = {ATTR_ENTITY_ID: entity_id} if entity_id else None hass.services.call(DOMAIN, SERVICE_CLOSE, data) -def open_door(hass, entity_id=None): +def open(hass, entity_id=None): """ Open all or specified garage door. """ data = {ATTR_ENTITY_ID: entity_id} if entity_id else None hass.services.call(DOMAIN, SERVICE_OPEN, data) @@ -70,9 +65,9 @@ def setup(hass, config): for item in target_locks: if service.service == SERVICE_CLOSE: - item.close_door() + item.close() else: - item.open_door() + item.open() if item.should_poll: item.update_ha_state(True) @@ -96,11 +91,11 @@ class GarageDoorDevice(Entity): """ Is the garage door closed or opened. """ return None - def close_door(self): + def close(self): """ Closes the garage door. """ raise NotImplementedError() - def open_door(self): + def open(self): """ Opens the garage door. """ raise NotImplementedError() @@ -110,3 +105,4 @@ class GarageDoorDevice(Entity): if closed is None: return STATE_UNKNOWN return STATE_CLOSED if closed else STATE_OPEN + diff --git a/tests/components/garage_door/__init__.py b/tests/components/garage_door/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/components/garage_door/test_demo.py b/tests/components/garage_door/test_demo.py new file mode 100644 index 00000000000..f52aaa303d3 --- /dev/null +++ b/tests/components/garage_door/test_demo.py @@ -0,0 +1,51 @@ +""" +tests.components.garage_door.test_demo +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Tests demo garage door component. +""" +import unittest + +import homeassistant.core as ha +from homeassistant.components import garage_door + + +LEFT = 'garage_door.left_garage_door' +RIGHT = 'garage_door.right_garage_door' + + +class TestGarageDoorDemo(unittest.TestCase): + """ Test the demo garage door. """ + + def setUp(self): # pylint: disable=invalid-name + self.hass = ha.HomeAssistant() + self.assertTrue(garage_door.setup(self.hass, { + 'garage_door': { + 'platform': 'demo' + } + })) + + def tearDown(self): # pylint: disable=invalid-name + """ Stop down stuff we started. """ + self.hass.stop() + + def test_is_closed(self): + self.assertTrue(garage_door.is_closed(self.hass, LEFT)) + self.hass.states.is_state(LEFT, 'close') + + self.assertFalse(garage_door.is_closed(self.hass, RIGHT)) + self.hass.states.is_state(RIGHT, 'open') + + def test_open_door(self): + garage_door.open_door(self.hass, LEFT) + + self.hass.pool.block_till_done() + + self.assertFalse(garage_door.is_closed(self.hass, LEFT)) + + def test_close_door(self): + garage_door.close_door(self.hass, RIGHT) + + self.hass.pool.block_till_done() + + self.assertTrue(garage_door.is_closed(self.hass, RIGHT)) From 6cbf19934fdc440bc7639d727d2210fc802bddca Mon Sep 17 00:00:00 2001 From: Eric Rolf Date: Thu, 11 Feb 2016 08:23:04 -0500 Subject: [PATCH 06/22] Updated Demo --- homeassistant/components/demo.py | 1 + 1 file changed, 1 insertion(+) diff --git a/homeassistant/components/demo.py b/homeassistant/components/demo.py index 37f93c0625d..e63f5f49551 100644 --- a/homeassistant/components/demo.py +++ b/homeassistant/components/demo.py @@ -21,6 +21,7 @@ COMPONENTS_WITH_DEMO_PLATFORM = [ 'binary_sensor', 'camera', 'device_tracker', + 'garage_door', 'light', 'lock', 'media_player', From aa13392983e11fd545e83afc513607f36880940e Mon Sep 17 00:00:00 2001 From: Eric Rolf Date: Thu, 11 Feb 2016 08:30:33 -0500 Subject: [PATCH 07/22] refactored test case --- tests/components/garage_door/test_demo.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/components/garage_door/test_demo.py b/tests/components/garage_door/test_demo.py index f52aaa303d3..7c959709c48 100644 --- a/tests/components/garage_door/test_demo.py +++ b/tests/components/garage_door/test_demo.py @@ -7,7 +7,7 @@ Tests demo garage door component. import unittest import homeassistant.core as ha -from homeassistant.components import garage_door +import homeassistant.components.garage_door as gd LEFT = 'garage_door.left_garage_door' @@ -19,7 +19,7 @@ class TestGarageDoorDemo(unittest.TestCase): def setUp(self): # pylint: disable=invalid-name self.hass = ha.HomeAssistant() - self.assertTrue(garage_door.setup(self.hass, { + self.assertTrue(gd.setup(self.hass, { 'garage_door': { 'platform': 'demo' } @@ -30,22 +30,22 @@ class TestGarageDoorDemo(unittest.TestCase): self.hass.stop() def test_is_closed(self): - self.assertTrue(garage_door.is_closed(self.hass, LEFT)) + self.assertTrue(gd.is_closed(self.hass, LEFT)) self.hass.states.is_state(LEFT, 'close') - self.assertFalse(garage_door.is_closed(self.hass, RIGHT)) + self.assertFalse(gd.is_closed(self.hass, RIGHT)) self.hass.states.is_state(RIGHT, 'open') def test_open_door(self): - garage_door.open_door(self.hass, LEFT) + gd.open_door(self.hass, LEFT) self.hass.pool.block_till_done() - self.assertFalse(garage_door.is_closed(self.hass, LEFT)) + self.assertFalse(gd.is_closed(self.hass, LEFT)) def test_close_door(self): - garage_door.close_door(self.hass, RIGHT) + gd.close_door(self.hass, RIGHT) self.hass.pool.block_till_done() - self.assertTrue(garage_door.is_closed(self.hass, RIGHT)) + self.assertTrue(gd.is_closed(self.hass, RIGHT)) From d2ad0620ee186e2810a83855f156115baf0d34d1 Mon Sep 17 00:00:00 2001 From: Eric Rolf Date: Sun, 31 Jan 2016 21:39:04 -0500 Subject: [PATCH 08/22] Wink Garage Door Support --- .../components/garage_door/__init__.py | 112 ++++++ homeassistant/components/garage_door/demo.py | 49 +++ .../components/garage_door/services.yaml | 0 homeassistant/components/garage_door/wink.py | 67 ++++ homeassistant/components/wink.py | 4 +- homeassistant/const.py | 3 + requirements_all.txt | 372 +++++++++--------- 7 files changed, 414 insertions(+), 193 deletions(-) create mode 100644 homeassistant/components/garage_door/__init__.py create mode 100644 homeassistant/components/garage_door/demo.py create mode 100644 homeassistant/components/garage_door/services.yaml create mode 100644 homeassistant/components/garage_door/wink.py diff --git a/homeassistant/components/garage_door/__init__.py b/homeassistant/components/garage_door/__init__.py new file mode 100644 index 00000000000..572dd27cd90 --- /dev/null +++ b/homeassistant/components/garage_door/__init__.py @@ -0,0 +1,112 @@ +""" +homeassistant.components.garage_door +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Component to interface with garage doors that can be controlled remotely. + +For more details about this component, please refer to the documentation +at https://home-assistant.io/components/garage_door/ +""" +from datetime import timedelta +import logging +import os + +from homeassistant.config import load_yaml_config_file +from homeassistant.helpers.entity_component import EntityComponent +from homeassistant.helpers.entity import Entity + +from homeassistant.const import ( + STATE_CLOSED, STATE_OPEN, STATE_UNKNOWN, SERVICE_CLOSE, SERVICE_OPEN, + ATTR_ENTITY_ID) +from homeassistant.components import (group, wink) + +DOMAIN = 'garage_door' +SCAN_INTERVAL = 30 + +GROUP_NAME_ALL_GARAGE_DOORS = 'all garage doors' +ENTITY_ID_ALL_GARAGE_DOORS = group.ENTITY_ID_FORMAT.format('all_garage_doors') + +ENTITY_ID_FORMAT = DOMAIN + '.{}' + +ATTR_CLOSED = "closed" + +MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10) + +# Maps discovered services to their platforms +DISCOVERY_PLATFORMS = { + wink.DISCOVER_GARAGE_DOORS: 'wink' +} + +_LOGGER = logging.getLogger(__name__) + + +def is_closed(hass, entity_id=None): + """ Returns if the garage door is closed based on the statemachine. """ + entity_id = entity_id or ENTITY_ID_ALL_GARAGE_DOORS + return hass.states.is_state(entity_id, STATE_CLOSED) + + +def close(hass, entity_id=None): + """ Closes all or specified garage door. """ + data = {ATTR_ENTITY_ID: entity_id} if entity_id else None + hass.services.call(DOMAIN, SERVICE_CLOSE, data) + + +def open(hass, entity_id=None): + """ Open all or specified garage door. """ + data = {ATTR_ENTITY_ID: entity_id} if entity_id else None + hass.services.call(DOMAIN, SERVICE_OPEN, data) + + +def setup(hass, config): + """ Track states and offer events for garage door. """ + component = EntityComponent( + _LOGGER, DOMAIN, hass, SCAN_INTERVAL, DISCOVERY_PLATFORMS, + GROUP_NAME_ALL_GARAGE_DOORS) + component.setup(config) + + def handle_garage_door_service(service): + """ Handles calls to the garage door services. """ + target_locks = component.extract_from_service(service) + + for item in target_locks: + if service.service == SERVICE_CLOSE: + item.close() + else: + item.open() + + if item.should_poll: + item.update_ha_state(True) + + descriptions = load_yaml_config_file( + os.path.join(os.path.dirname(__file__), 'services.yaml')) + hass.services.register(DOMAIN, SERVICE_OPEN, handle_garage_door_service, + descriptions.get(SERVICE_OPEN)) + hass.services.register(DOMAIN, SERVICE_CLOSE, handle_garage_door_service, + descriptions.get(SERVICE_CLOSE)) + + return True + + +class GarageDoorDevice(Entity): + """ Represents a garage door within Home Assistant. """ + # pylint: disable=no-self-use + + @property + def is_closed(self): + """ Is the garage door closed or opened. """ + return None + + def close(self): + """ Closes the garage door. """ + raise NotImplementedError() + + def open(self): + """ Opens the garage door. """ + raise NotImplementedError() + + @property + def state(self): + closed = self.is_closed + if closed is None: + return STATE_UNKNOWN + return STATE_CLOSED if closed else STATE_OPEN diff --git a/homeassistant/components/garage_door/demo.py b/homeassistant/components/garage_door/demo.py new file mode 100644 index 00000000000..30935a0d3ef --- /dev/null +++ b/homeassistant/components/garage_door/demo.py @@ -0,0 +1,49 @@ +""" +homeassistant.components.garage_door.demo +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Demo platform that has two fake garage doors. +""" +from homeassistant.components.garage_door import GarageDoorDevice +from homeassistant.const import STATE_CLOSED, STATE_OPEN + + +# pylint: disable=unused-argument +def setup_platform(hass, config, add_devices_callback, discovery_info=None): + """ Find and return demo garage doors. """ + add_devices_callback([ + DemoGarageDoor('Left Garage Door', STATE_CLOSED), + DemoGarageDoor('Right Garage Door', STATE_OPEN) + ]) + + +class DemoGarageDoor(GarageDoorDevice): + """ Provides a demo garage door. """ + def __init__(self, name, state): + self._name = name + self._state = state + + @property + def should_poll(self): + """ No polling needed for a demo garage door. """ + return False + + @property + def name(self): + """ Returns the name of the device if any. """ + return self._name + + @property + def is_closed(self): + """ True if device is closed. """ + return self._state == STATE_CLOSED + + def close(self, **kwargs): + """ Close the device. """ + self._state = STATE_CLOSED + self.update_ha_state() + + def open(self, **kwargs): + """ Open the device. """ + self._state = STATE_OPEN + self.update_ha_state() diff --git a/homeassistant/components/garage_door/services.yaml b/homeassistant/components/garage_door/services.yaml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/homeassistant/components/garage_door/wink.py b/homeassistant/components/garage_door/wink.py new file mode 100644 index 00000000000..8283575f19d --- /dev/null +++ b/homeassistant/components/garage_door/wink.py @@ -0,0 +1,67 @@ +""" +homeassistant.components.garage_door.wink +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Support for Wink garage doors. + +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/garage_door.wink/ +""" +import logging + +from homeassistant.components.garage_door import GarageDoorDevice +from homeassistant.const import CONF_ACCESS_TOKEN + +REQUIREMENTS = ['python-wink==0.4.2'] + + +def setup_platform(hass, config, add_devices, discovery_info=None): + """ Sets up the Wink platform. """ + import pywink + + if discovery_info is None: + token = config.get(CONF_ACCESS_TOKEN) + + if token is None: + logging.getLogger(__name__).error( + "Missing wink access_token. " + "Get one at https://winkbearertoken.appspot.com/") + return + + pywink.set_bearer_token(token) + + add_devices(WinkGarageDoorDevice(door) for door in + pywink.get_garage_doors()) + + +class WinkGarageDoorDevice(GarageDoorDevice): + """ Represents a Wink garage door. """ + + def __init__(self, wink): + self.wink = wink + + @property + def unique_id(self): + """ Returns the id of this wink garage door """ + return "{}.{}".format(self.__class__, self.wink.device_id()) + + @property + def name(self): + """ Returns the name of the garage door if any. """ + return self.wink.name() + + def update(self): + """ Update the state of the garage door. """ + self.wink.update_state() + + @property + def is_closed(self): + """ True if device is closed. """ + return self.wink.state() == 0 + + def close(self): + """ Close the device. """ + self.wink.set_state(0) + + def open(self): + """ Open the device. """ + self.wink.set_state(1) diff --git a/homeassistant/components/wink.py b/homeassistant/components/wink.py index 88881ad1ab7..6fa2b9287e9 100644 --- a/homeassistant/components/wink.py +++ b/homeassistant/components/wink.py @@ -22,6 +22,7 @@ DISCOVER_LIGHTS = "wink.lights" DISCOVER_SWITCHES = "wink.switches" DISCOVER_SENSORS = "wink.sensors" DISCOVER_LOCKS = "wink.locks" +DISCOVER_GARAGE_DOORS = "wink.garage_doors" def setup(hass, config): @@ -42,7 +43,8 @@ def setup(hass, config): pywink.get_powerstrip_outlets, DISCOVER_SWITCHES), ('sensor', lambda: pywink.get_sensors or pywink.get_eggtrays, DISCOVER_SENSORS), - ('lock', pywink.get_locks, DISCOVER_LOCKS)): + ('lock', pywink.get_locks, DISCOVER_LOCKS), + ('garage_door', pywink.get_garage_doors, DISCOVER_GARAGE_DOORS)): if func_exists(): component = get_component(component_name) diff --git a/homeassistant/const.py b/homeassistant/const.py index 42146895a01..d89b4021180 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -151,6 +151,9 @@ SERVICE_ALARM_TRIGGER = "alarm_trigger" SERVICE_LOCK = "lock" SERVICE_UNLOCK = "unlock" +SERVICE_OPEN = "open" +SERVICE_CLOSE = "close" + SERVICE_MOVE_UP = 'move_up' SERVICE_MOVE_DOWN = 'move_down' SERVICE_STOP = 'stop' diff --git a/requirements_all.txt b/requirements_all.txt index f72daaecccf..b0c07fa9ee1 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -6,150 +6,17 @@ pip>=7.0.0 vincenty==0.1.3 jinja2>=2.8 -# homeassistant.components.isy994 -PyISY==1.0.5 +# homeassistant.components.alarm_control_panel.alarmdotcom +https://github.com/Xorso/pyalarmdotcom/archive/0.0.7.zip#pyalarmdotcom==0.0.7 # homeassistant.components.arduino PyMata==2.07a -# homeassistant.components.rpi_gpio -# RPi.GPIO==0.6.1 - -# homeassistant.components.media_player.sonos -SoCo==0.11.1 - -# homeassistant.components.notify.twitter -TwitterAPI==2.3.6 - -# homeassistant.components.sun -astral==0.9 - -# homeassistant.components.light.blinksticklight -blinkstick==1.1.7 - -# homeassistant.components.sensor.bitcoin -blockchain==1.2.1 - -# homeassistant.components.notify.xmpp -dnspython3==1.12.0 - -# homeassistant.components.sensor.dweet -dweepy==0.2.0 - -# homeassistant.components.sensor.eliqonline -eliqonline==1.0.11 - -# homeassistant.components.thermostat.honeywell -evohomeclient==0.2.4 - -# homeassistant.components.notify.free_mobile -freesms==0.1.0 - -# homeassistant.components.device_tracker.fritz -# fritzconnection==0.4.6 - # homeassistant.components.conversation fuzzywuzzy==0.8.0 -# homeassistant.components.thermostat.heatmiser -heatmiserV3==0.9.1 - -# homeassistant.components.switch.hikvisioncam -hikvision==0.4 - -# homeassistant.components.sensor.dht -# http://github.com/mala-zaba/Adafruit_Python_DHT/archive/4101340de8d2457dd194bca1e8d11cbfc237e919.zip#Adafruit_DHT==1.1.0 - -# homeassistant.components.rfxtrx -https://github.com/Danielhiversen/pyRFXtrx/archive/0.2.zip#RFXtrx==0.2 - -# homeassistant.components.sensor.netatmo -https://github.com/HydrelioxGitHub/netatmo-api-python/archive/43ff238a0122b0939a0dc4e8836b6782913fb6e2.zip#lnetatmo==0.4.0 - -# homeassistant.components.alarm_control_panel.alarmdotcom -https://github.com/Xorso/pyalarmdotcom/archive/0.0.7.zip#pyalarmdotcom==0.0.7 - -# homeassistant.components.modbus -https://github.com/bashwork/pymodbus/archive/d7fc4f1cc975631e0a9011390e8017f64b612661.zip#pymodbus==1.2.0 - -# homeassistant.components.sensor.sabnzbd -https://github.com/jamespcole/home-assistant-nzb-clients/archive/616cad59154092599278661af17e2a9f2cf5e2a9.zip#python-sabnzbd==0.1 - -# homeassistant.components.ecobee -https://github.com/nkgilley/python-ecobee-api/archive/92a2f330cbaf601d0618456fdd97e5a8c42c1c47.zip#python-ecobee==0.0.4 - -# homeassistant.components.switch.edimax -https://github.com/rkabadi/pyedimax/archive/365301ce3ff26129a7910c501ead09ea625f3700.zip#pyedimax==0.1 - -# homeassistant.components.sensor.temper -https://github.com/rkabadi/temper-python/archive/3dbdaf2d87b8db9a3cd6e5585fc704537dd2d09b.zip#temperusb==1.2.3 - -# homeassistant.components.mysensors -https://github.com/theolind/pymysensors/archive/005bff4c5ca7a56acd30e816bc3bcdb5cb2d46fd.zip#pymysensors==0.4 - -# homeassistant.components.notify.googlevoice -https://github.com/w1ll1am23/pygooglevoice-sms/archive/7c5ee9969b97a7992fc86a753fe9f20e3ffa3f7c.zip#pygooglevoice-sms==0.0.1 - -# homeassistant.components.influxdb -influxdb==2.12.0 - -# homeassistant.components.insteon_hub -insteon_hub==0.4.5 - -# homeassistant.components.media_player.kodi -jsonrpc-requests==0.1 - -# homeassistant.components.light.lifx -liffylights==0.9.4 - -# homeassistant.components.light.limitlessled -limitlessled==1.0.0 - -# homeassistant.components.sensor.mfi -# homeassistant.components.switch.mfi -mficlient==0.2.2 - -# homeassistant.components.discovery -netdisco==0.5.2 - -# homeassistant.components.switch.orvibo -orvibo==1.1.1 - -# homeassistant.components.mqtt -paho-mqtt==1.1 - -# homeassistant.components.device_tracker.aruba -pexpect==4.0.1 - -# homeassistant.components.light.hue -phue==0.8 - -# homeassistant.components.media_player.plex -plexapi==1.1.0 - -# homeassistant.components.thermostat.proliphix -proliphix==0.1.0 - -# homeassistant.components.sensor.systemmonitor -psutil==3.4.2 - -# homeassistant.components.notify.pushbullet -pushbullet.py==0.9.0 - -# homeassistant.components.notify.pushetta -pushetta==1.0.15 - -# homeassistant.components.sensor.cpuspeed -py-cpuinfo==0.1.8 - -# homeassistant.components.media_player.cast -pychromecast==0.7.1 - -# homeassistant.components.zwave -pydispatcher==2.0.5 - -# homeassistant.components.ifttt -pyfttt==0.3 +# homeassistant.components.device_tracker.fritz +# fritzconnection==0.4.6 # homeassistant.components.device_tracker.icloud pyicloud==0.7.2 @@ -157,86 +24,207 @@ pyicloud==0.7.2 # homeassistant.components.device_tracker.netgear pynetgear==0.3.2 -# homeassistant.components.alarm_control_panel.nx584 -pynx584==0.1 - -# homeassistant.components.sensor.openweathermap -pyowm==2.3.0 +# homeassistant.components.device_tracker.nmap_tracker +python-nmap==0.4.3 # homeassistant.components.device_tracker.snmp pysnmp==4.2.5 -# homeassistant.components.sensor.forecast -python-forecastio==1.3.3 +# homeassistant.components.discovery +netdisco==0.5.2 -# homeassistant.components.media_player.mpd -python-mpd2==0.5.4 +# homeassistant.components.ecobee +https://github.com/nkgilley/python-ecobee-api/archive/92a2f330cbaf601d0618456fdd97e5a8c42c1c47.zip#python-ecobee==0.0.4 -# homeassistant.components.nest -python-nest==2.6.0 +# homeassistant.components.ifttt +pyfttt==0.3 -# homeassistant.components.device_tracker.nmap_tracker -python-nmap==0.4.3 +# homeassistant.components.influxdb +influxdb==2.11.0 -# homeassistant.components.notify.pushover -python-pushover==0.2 +# homeassistant.components.insteon_hub +insteon_hub==0.4.5 -# homeassistant.components.statsd -python-statsd==1.7.2 - -# homeassistant.components.notify.telegram -python-telegram-bot==3.2.0 - -# homeassistant.components.sensor.twitch -python-twitch==1.2.0 - -# homeassistant.components.wink -# homeassistant.components.light.wink -# homeassistant.components.lock.wink -# homeassistant.components.sensor.wink -# homeassistant.components.switch.wink -python-wink==0.5.0 +# homeassistant.components.isy994 +PyISY==1.0.5 # homeassistant.components.keyboard pyuserinput==0.1.9 -# homeassistant.components.light.vera -# homeassistant.components.sensor.vera -# homeassistant.components.switch.vera -pyvera==0.2.8 +# homeassistant.components.light.blinksticklight +blinkstick==1.1.7 -# homeassistant.components.switch.wemo -pywemo==0.3.9 +# homeassistant.components.light.hue +phue==0.8 -# homeassistant.components.thermostat.radiotherm -radiotherm==1.2 +# homeassistant.components.light.lifx +liffylights==0.9.3 -# homeassistant.components.media_player.samsungtv -samsungctl==0.5.1 - -# homeassistant.components.scsgate -scsgate==0.1.0 - -# homeassistant.components.notify.slack -slacker==0.6.8 - -# homeassistant.components.notify.xmpp -sleekxmpp==1.3.1 +# homeassistant.components.light.limitlessled +limitlessled==1.0.0 # homeassistant.components.light.tellstick # homeassistant.components.sensor.tellstick # homeassistant.components.switch.tellstick tellcore-py==1.1.2 -# homeassistant.components.tellduslive -tellive-py==0.5.2 +# homeassistant.components.light.vera +# homeassistant.components.sensor.vera +# homeassistant.components.switch.vera +pyvera==0.2.7 + +# homeassistant.components.wink +# homeassistant.components.light.wink +# homeassistant.components.lock.wink +# homeassistant.components.sensor.wink +# homeassistant.components.switch.wink +# homeassistant.components.garage_door.wink +python-wink==0.4.2 + +# homeassistant.components.media_player.cast +pychromecast==0.7.1 + +# homeassistant.components.media_player.kodi +jsonrpc-requests==0.1 + +# homeassistant.components.media_player.mpd +python-mpd2==0.5.4 + +# homeassistant.components.media_player.plex +plexapi==1.1.0 + +# homeassistant.components.media_player.samsungtv +samsungctl==0.5.1 + +# homeassistant.components.media_player.sonos +SoCo==0.11.1 + +# homeassistant.components.modbus +https://github.com/bashwork/pymodbus/archive/d7fc4f1cc975631e0a9011390e8017f64b612661.zip#pymodbus==1.2.0 + +# homeassistant.components.mqtt +paho-mqtt==1.1 + +# homeassistant.components.mysensors +https://github.com/theolind/pymysensors/archive/005bff4c5ca7a56acd30e816bc3bcdb5cb2d46fd.zip#pymysensors==0.4 + +# homeassistant.components.nest +python-nest==2.6.0 + +# homeassistant.components.notify.free_mobile +freesms==0.1.0 + +# homeassistant.components.notify.googlevoice +https://github.com/w1ll1am23/pygooglevoice-sms/archive/7c5ee9969b97a7992fc86a753fe9f20e3ffa3f7c.zip#pygooglevoice-sms==0.0.1 + +# homeassistant.components.notify.pushbullet +pushbullet.py==0.9.0 + +# homeassistant.components.notify.pushetta +pushetta==1.0.15 + +# homeassistant.components.notify.pushover +python-pushover==0.2 + +# homeassistant.components.notify.slack +slacker==0.6.8 + +# homeassistant.components.notify.telegram +python-telegram-bot==3.2.0 + +# homeassistant.components.notify.twitter +TwitterAPI==2.3.6 + +# homeassistant.components.notify.xmpp +sleekxmpp==1.3.1 + +# homeassistant.components.notify.xmpp +dnspython3==1.12.0 + +# homeassistant.components.rfxtrx +https://github.com/Danielhiversen/pyRFXtrx/archive/0.2.zip#RFXtrx==0.2 + +# homeassistant.components.rpi_gpio +# RPi.GPIO==0.6.1 + +# homeassistant.components.scsgate +scsgate==0.1.0 + +# homeassistant.components.sensor.bitcoin +blockchain==1.2.1 + +# homeassistant.components.sensor.cpuspeed +py-cpuinfo==0.1.8 + +# homeassistant.components.sensor.dht +# http://github.com/mala-zaba/Adafruit_Python_DHT/archive/4101340de8d2457dd194bca1e8d11cbfc237e919.zip#Adafruit_DHT==1.1.0 + +# homeassistant.components.sensor.dweet +dweepy==0.2.0 + +# homeassistant.components.sensor.eliqonline +eliqonline==1.0.11 + +# homeassistant.components.sensor.forecast +python-forecastio==1.3.3 + +# homeassistant.components.sensor.netatmo +https://github.com/HydrelioxGitHub/netatmo-api-python/archive/43ff238a0122b0939a0dc4e8836b6782913fb6e2.zip#lnetatmo==0.4.0 + +# homeassistant.components.sensor.openweathermap +pyowm==2.3.0 + +# homeassistant.components.sensor.sabnzbd +https://github.com/jamespcole/home-assistant-nzb-clients/archive/616cad59154092599278661af17e2a9f2cf5e2a9.zip#python-sabnzbd==0.1 + +# homeassistant.components.sensor.systemmonitor +psutil==3.4.2 + +# homeassistant.components.sensor.temper +https://github.com/rkabadi/temper-python/archive/3dbdaf2d87b8db9a3cd6e5585fc704537dd2d09b.zip#temperusb==1.2.3 # homeassistant.components.sensor.transmission # homeassistant.components.switch.transmission transmissionrpc==0.11 -# homeassistant.components.camera.uvc -uvcclient==0.5 +# homeassistant.components.sensor.twitch +python-twitch==1.2.0 + +# homeassistant.components.sensor.yr +xmltodict + +# homeassistant.components.statsd +python-statsd==1.7.2 + +# homeassistant.components.sun +astral==0.9 + +# homeassistant.components.switch.edimax +https://github.com/rkabadi/pyedimax/archive/365301ce3ff26129a7910c501ead09ea625f3700.zip#pyedimax==0.1 + +# homeassistant.components.switch.hikvisioncam +hikvision==0.4 + +# homeassistant.components.switch.orvibo +orvibo==1.1.1 + +# homeassistant.components.switch.wemo +pywemo==0.3.8 + +# homeassistant.components.tellduslive +tellive-py==0.5.2 + +# homeassistant.components.thermostat.heatmiser +heatmiserV3==0.9.1 + +# homeassistant.components.thermostat.honeywell +evohomeclient==0.2.4 + +# homeassistant.components.thermostat.proliphix +proliphix==0.1.0 + +# homeassistant.components.thermostat.radiotherm +radiotherm==1.2 # homeassistant.components.verisure vsure==0.5.0 @@ -244,5 +232,5 @@ vsure==0.5.0 # homeassistant.components.zigbee xbee-helper==0.0.6 -# homeassistant.components.sensor.yr -xmltodict +# homeassistant.components.zwave +pydispatcher==2.0.5 From 89f6ef9f6c265f86cc2f2a41ac04f29dbbcad276 Mon Sep 17 00:00:00 2001 From: Eric Rolf Date: Fri, 5 Feb 2016 14:20:06 -0500 Subject: [PATCH 09/22] Updated requirements_all.txt --- requirements_all.txt | 373 ++++++++++++++++++++++--------------------- 1 file changed, 188 insertions(+), 185 deletions(-) diff --git a/requirements_all.txt b/requirements_all.txt index b0c07fa9ee1..4ead1a361b3 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -6,158 +6,32 @@ pip>=7.0.0 vincenty==0.1.3 jinja2>=2.8 -# homeassistant.components.alarm_control_panel.alarmdotcom -https://github.com/Xorso/pyalarmdotcom/archive/0.0.7.zip#pyalarmdotcom==0.0.7 +# homeassistant.components.isy994 +PyISY==1.0.5 # homeassistant.components.arduino PyMata==2.07a -# homeassistant.components.conversation -fuzzywuzzy==0.8.0 - -# homeassistant.components.device_tracker.fritz -# fritzconnection==0.4.6 - -# homeassistant.components.device_tracker.icloud -pyicloud==0.7.2 - -# homeassistant.components.device_tracker.netgear -pynetgear==0.3.2 - -# homeassistant.components.device_tracker.nmap_tracker -python-nmap==0.4.3 - -# homeassistant.components.device_tracker.snmp -pysnmp==4.2.5 - -# homeassistant.components.discovery -netdisco==0.5.2 - -# homeassistant.components.ecobee -https://github.com/nkgilley/python-ecobee-api/archive/92a2f330cbaf601d0618456fdd97e5a8c42c1c47.zip#python-ecobee==0.0.4 - -# homeassistant.components.ifttt -pyfttt==0.3 - -# homeassistant.components.influxdb -influxdb==2.11.0 - -# homeassistant.components.insteon_hub -insteon_hub==0.4.5 - -# homeassistant.components.isy994 -PyISY==1.0.5 - -# homeassistant.components.keyboard -pyuserinput==0.1.9 - -# homeassistant.components.light.blinksticklight -blinkstick==1.1.7 - -# homeassistant.components.light.hue -phue==0.8 - -# homeassistant.components.light.lifx -liffylights==0.9.3 - -# homeassistant.components.light.limitlessled -limitlessled==1.0.0 - -# homeassistant.components.light.tellstick -# homeassistant.components.sensor.tellstick -# homeassistant.components.switch.tellstick -tellcore-py==1.1.2 - -# homeassistant.components.light.vera -# homeassistant.components.sensor.vera -# homeassistant.components.switch.vera -pyvera==0.2.7 - -# homeassistant.components.wink -# homeassistant.components.light.wink -# homeassistant.components.lock.wink -# homeassistant.components.sensor.wink -# homeassistant.components.switch.wink -# homeassistant.components.garage_door.wink -python-wink==0.4.2 - -# homeassistant.components.media_player.cast -pychromecast==0.7.1 - -# homeassistant.components.media_player.kodi -jsonrpc-requests==0.1 - -# homeassistant.components.media_player.mpd -python-mpd2==0.5.4 - -# homeassistant.components.media_player.plex -plexapi==1.1.0 - -# homeassistant.components.media_player.samsungtv -samsungctl==0.5.1 +# homeassistant.components.rpi_gpio +# RPi.GPIO==0.6.1 # homeassistant.components.media_player.sonos SoCo==0.11.1 -# homeassistant.components.modbus -https://github.com/bashwork/pymodbus/archive/d7fc4f1cc975631e0a9011390e8017f64b612661.zip#pymodbus==1.2.0 - -# homeassistant.components.mqtt -paho-mqtt==1.1 - -# homeassistant.components.mysensors -https://github.com/theolind/pymysensors/archive/005bff4c5ca7a56acd30e816bc3bcdb5cb2d46fd.zip#pymysensors==0.4 - -# homeassistant.components.nest -python-nest==2.6.0 - -# homeassistant.components.notify.free_mobile -freesms==0.1.0 - -# homeassistant.components.notify.googlevoice -https://github.com/w1ll1am23/pygooglevoice-sms/archive/7c5ee9969b97a7992fc86a753fe9f20e3ffa3f7c.zip#pygooglevoice-sms==0.0.1 - -# homeassistant.components.notify.pushbullet -pushbullet.py==0.9.0 - -# homeassistant.components.notify.pushetta -pushetta==1.0.15 - -# homeassistant.components.notify.pushover -python-pushover==0.2 - -# homeassistant.components.notify.slack -slacker==0.6.8 - -# homeassistant.components.notify.telegram -python-telegram-bot==3.2.0 - # homeassistant.components.notify.twitter TwitterAPI==2.3.6 -# homeassistant.components.notify.xmpp -sleekxmpp==1.3.1 +# homeassistant.components.sun +astral==0.9 -# homeassistant.components.notify.xmpp -dnspython3==1.12.0 - -# homeassistant.components.rfxtrx -https://github.com/Danielhiversen/pyRFXtrx/archive/0.2.zip#RFXtrx==0.2 - -# homeassistant.components.rpi_gpio -# RPi.GPIO==0.6.1 - -# homeassistant.components.scsgate -scsgate==0.1.0 +# homeassistant.components.light.blinksticklight +blinkstick==1.1.7 # homeassistant.components.sensor.bitcoin blockchain==1.2.1 -# homeassistant.components.sensor.cpuspeed -py-cpuinfo==0.1.8 - -# homeassistant.components.sensor.dht -# http://github.com/mala-zaba/Adafruit_Python_DHT/archive/4101340de8d2457dd194bca1e8d11cbfc237e919.zip#Adafruit_DHT==1.1.0 +# homeassistant.components.notify.xmpp +dnspython3==1.12.0 # homeassistant.components.sensor.dweet dweepy==0.2.0 @@ -165,72 +39,201 @@ dweepy==0.2.0 # homeassistant.components.sensor.eliqonline eliqonline==1.0.11 -# homeassistant.components.sensor.forecast -python-forecastio==1.3.3 +# homeassistant.components.thermostat.honeywell +evohomeclient==0.2.4 -# homeassistant.components.sensor.netatmo -https://github.com/HydrelioxGitHub/netatmo-api-python/archive/43ff238a0122b0939a0dc4e8836b6782913fb6e2.zip#lnetatmo==0.4.0 +# homeassistant.components.notify.free_mobile +freesms==0.1.0 -# homeassistant.components.sensor.openweathermap -pyowm==2.3.0 +# homeassistant.components.device_tracker.fritz +# fritzconnection==0.4.6 -# homeassistant.components.sensor.sabnzbd -https://github.com/jamespcole/home-assistant-nzb-clients/archive/616cad59154092599278661af17e2a9f2cf5e2a9.zip#python-sabnzbd==0.1 - -# homeassistant.components.sensor.systemmonitor -psutil==3.4.2 - -# homeassistant.components.sensor.temper -https://github.com/rkabadi/temper-python/archive/3dbdaf2d87b8db9a3cd6e5585fc704537dd2d09b.zip#temperusb==1.2.3 - -# homeassistant.components.sensor.transmission -# homeassistant.components.switch.transmission -transmissionrpc==0.11 - -# homeassistant.components.sensor.twitch -python-twitch==1.2.0 - -# homeassistant.components.sensor.yr -xmltodict - -# homeassistant.components.statsd -python-statsd==1.7.2 - -# homeassistant.components.sun -astral==0.9 - -# homeassistant.components.switch.edimax -https://github.com/rkabadi/pyedimax/archive/365301ce3ff26129a7910c501ead09ea625f3700.zip#pyedimax==0.1 - -# homeassistant.components.switch.hikvisioncam -hikvision==0.4 - -# homeassistant.components.switch.orvibo -orvibo==1.1.1 - -# homeassistant.components.switch.wemo -pywemo==0.3.8 - -# homeassistant.components.tellduslive -tellive-py==0.5.2 +# homeassistant.components.conversation +fuzzywuzzy==0.8.0 # homeassistant.components.thermostat.heatmiser heatmiserV3==0.9.1 -# homeassistant.components.thermostat.honeywell -evohomeclient==0.2.4 +# homeassistant.components.switch.hikvisioncam +hikvision==0.4 + +# homeassistant.components.sensor.dht +# http://github.com/mala-zaba/Adafruit_Python_DHT/archive/4101340de8d2457dd194bca1e8d11cbfc237e919.zip#Adafruit_DHT==1.1.0 + +# homeassistant.components.rfxtrx +https://github.com/Danielhiversen/pyRFXtrx/archive/0.2.zip#RFXtrx==0.2 + +# homeassistant.components.sensor.netatmo +https://github.com/HydrelioxGitHub/netatmo-api-python/archive/43ff238a0122b0939a0dc4e8836b6782913fb6e2.zip#lnetatmo==0.4.0 + +# homeassistant.components.alarm_control_panel.alarmdotcom +https://github.com/Xorso/pyalarmdotcom/archive/0.0.7.zip#pyalarmdotcom==0.0.7 + +# homeassistant.components.modbus +https://github.com/bashwork/pymodbus/archive/d7fc4f1cc975631e0a9011390e8017f64b612661.zip#pymodbus==1.2.0 + +# homeassistant.components.sensor.sabnzbd +https://github.com/jamespcole/home-assistant-nzb-clients/archive/616cad59154092599278661af17e2a9f2cf5e2a9.zip#python-sabnzbd==0.1 + +# homeassistant.components.ecobee +https://github.com/nkgilley/python-ecobee-api/archive/92a2f330cbaf601d0618456fdd97e5a8c42c1c47.zip#python-ecobee==0.0.4 + +# homeassistant.components.switch.edimax +https://github.com/rkabadi/pyedimax/archive/365301ce3ff26129a7910c501ead09ea625f3700.zip#pyedimax==0.1 + +# homeassistant.components.sensor.temper +https://github.com/rkabadi/temper-python/archive/3dbdaf2d87b8db9a3cd6e5585fc704537dd2d09b.zip#temperusb==1.2.3 + +# homeassistant.components.mysensors +https://github.com/theolind/pymysensors/archive/005bff4c5ca7a56acd30e816bc3bcdb5cb2d46fd.zip#pymysensors==0.4 + +# homeassistant.components.notify.googlevoice +https://github.com/w1ll1am23/pygooglevoice-sms/archive/7c5ee9969b97a7992fc86a753fe9f20e3ffa3f7c.zip#pygooglevoice-sms==0.0.1 + +# homeassistant.components.influxdb +influxdb==2.11.0 + +# homeassistant.components.insteon_hub +insteon_hub==0.4.5 + +# homeassistant.components.media_player.kodi +jsonrpc-requests==0.1 + +# homeassistant.components.light.lifx +liffylights==0.9.4 + +# homeassistant.components.light.limitlessled +limitlessled==1.0.0 + +# homeassistant.components.discovery +netdisco==0.5.2 + +# homeassistant.components.switch.orvibo +orvibo==1.1.1 + +# homeassistant.components.mqtt +paho-mqtt==1.1 + +# homeassistant.components.device_tracker.aruba +pexpect==4.0.1 + +# homeassistant.components.light.hue +phue==0.8 + +# homeassistant.components.media_player.plex +plexapi==1.1.0 # homeassistant.components.thermostat.proliphix proliphix==0.1.0 +# homeassistant.components.sensor.systemmonitor +psutil==3.4.2 + +# homeassistant.components.notify.pushbullet +pushbullet.py==0.9.0 + +# homeassistant.components.notify.pushetta +pushetta==1.0.15 + +# homeassistant.components.sensor.cpuspeed +py-cpuinfo==0.1.8 + +# homeassistant.components.media_player.cast +pychromecast==0.7.1 + +# homeassistant.components.zwave +pydispatcher==2.0.5 + +# homeassistant.components.ifttt +pyfttt==0.3 + +# homeassistant.components.device_tracker.icloud +pyicloud==0.7.2 + +# homeassistant.components.device_tracker.netgear +pynetgear==0.3.2 + +# homeassistant.components.sensor.openweathermap +pyowm==2.3.0 + +# homeassistant.components.device_tracker.snmp +pysnmp==4.2.5 + +# homeassistant.components.sensor.forecast +python-forecastio==1.3.3 + +# homeassistant.components.media_player.mpd +python-mpd2==0.5.4 + +# homeassistant.components.nest +python-nest==2.6.0 + +# homeassistant.components.device_tracker.nmap_tracker +python-nmap==0.4.3 + +# homeassistant.components.notify.pushover +python-pushover==0.2 + +# homeassistant.components.statsd +python-statsd==1.7.2 + +# homeassistant.components.notify.telegram +python-telegram-bot==3.2.0 + +# homeassistant.components.sensor.twitch +python-twitch==1.2.0 + +# homeassistant.components.wink +# homeassistant.components.garage_door.wink +# homeassistant.components.light.wink +# homeassistant.components.lock.wink +# homeassistant.components.sensor.wink +# homeassistant.components.switch.wink +python-wink==0.4.2 + +# homeassistant.components.keyboard +pyuserinput==0.1.9 + +# homeassistant.components.light.vera +# homeassistant.components.sensor.vera +# homeassistant.components.switch.vera +pyvera==0.2.7 + +# homeassistant.components.switch.wemo +pywemo==0.3.8 + # homeassistant.components.thermostat.radiotherm radiotherm==1.2 +# homeassistant.components.media_player.samsungtv +samsungctl==0.5.1 + +# homeassistant.components.scsgate +scsgate==0.1.0 + +# homeassistant.components.notify.slack +slacker==0.6.8 + +# homeassistant.components.notify.xmpp +sleekxmpp==1.3.1 + +# homeassistant.components.light.tellstick +# homeassistant.components.sensor.tellstick +# homeassistant.components.switch.tellstick +tellcore-py==1.1.2 + +# homeassistant.components.tellduslive +tellive-py==0.5.2 + +# homeassistant.components.sensor.transmission +# homeassistant.components.switch.transmission +transmissionrpc==0.11 + # homeassistant.components.verisure vsure==0.5.0 # homeassistant.components.zigbee xbee-helper==0.0.6 -# homeassistant.components.zwave -pydispatcher==2.0.5 +# homeassistant.components.sensor.yr +xmltodict From 5f6977acdad591f6db0c74bf1536d3622134163a Mon Sep 17 00:00:00 2001 From: Eric Rolf Date: Fri, 5 Feb 2016 15:10:53 -0500 Subject: [PATCH 10/22] Refactor Method Name For Open and Close. --- homeassistant/components/garage_door/__init__.py | 12 ++++++------ homeassistant/components/garage_door/wink.py | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/garage_door/__init__.py b/homeassistant/components/garage_door/__init__.py index 572dd27cd90..7854d33cb17 100644 --- a/homeassistant/components/garage_door/__init__.py +++ b/homeassistant/components/garage_door/__init__.py @@ -45,13 +45,13 @@ def is_closed(hass, entity_id=None): return hass.states.is_state(entity_id, STATE_CLOSED) -def close(hass, entity_id=None): +def close_door(hass, entity_id=None): """ Closes all or specified garage door. """ data = {ATTR_ENTITY_ID: entity_id} if entity_id else None hass.services.call(DOMAIN, SERVICE_CLOSE, data) -def open(hass, entity_id=None): +def open_door(hass, entity_id=None): """ Open all or specified garage door. """ data = {ATTR_ENTITY_ID: entity_id} if entity_id else None hass.services.call(DOMAIN, SERVICE_OPEN, data) @@ -70,9 +70,9 @@ def setup(hass, config): for item in target_locks: if service.service == SERVICE_CLOSE: - item.close() + item.close_door() else: - item.open() + item.open_door() if item.should_poll: item.update_ha_state(True) @@ -96,11 +96,11 @@ class GarageDoorDevice(Entity): """ Is the garage door closed or opened. """ return None - def close(self): + def close_door(self): """ Closes the garage door. """ raise NotImplementedError() - def open(self): + def open_door(self): """ Opens the garage door. """ raise NotImplementedError() diff --git a/homeassistant/components/garage_door/wink.py b/homeassistant/components/garage_door/wink.py index 8283575f19d..5b43ff4c032 100644 --- a/homeassistant/components/garage_door/wink.py +++ b/homeassistant/components/garage_door/wink.py @@ -58,10 +58,10 @@ class WinkGarageDoorDevice(GarageDoorDevice): """ True if device is closed. """ return self.wink.state() == 0 - def close(self): + def close_door(self): """ Close the device. """ self.wink.set_state(0) - def open(self): + def open_door(self): """ Open the device. """ self.wink.set_state(1) From 18b3d3df57939aba55e5c4b66496133ff1b31b48 Mon Sep 17 00:00:00 2001 From: Eric Rolf Date: Fri, 5 Feb 2016 15:16:56 -0500 Subject: [PATCH 11/22] Forgot to refactor demo. --- homeassistant/components/garage_door/demo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/garage_door/demo.py b/homeassistant/components/garage_door/demo.py index 30935a0d3ef..0562383a8bd 100644 --- a/homeassistant/components/garage_door/demo.py +++ b/homeassistant/components/garage_door/demo.py @@ -38,12 +38,12 @@ class DemoGarageDoor(GarageDoorDevice): """ True if device is closed. """ return self._state == STATE_CLOSED - def close(self, **kwargs): + def close_door(self, **kwargs): """ Close the device. """ self._state = STATE_CLOSED self.update_ha_state() - def open(self, **kwargs): + def open_door(self, **kwargs): """ Open the device. """ self._state = STATE_OPEN self.update_ha_state() From 6b962a2207b483e5b5f3cd8b6fa1ede737da6d7c Mon Sep 17 00:00:00 2001 From: Eric Rolf Date: Thu, 11 Feb 2016 07:41:42 -0500 Subject: [PATCH 12/22] Updated coveragec, cleaned up constants, added test for demo. --- .coveragerc | 2 +- .../components/garage_door/__init__.py | 20 +++----- tests/components/garage_door/__init__.py | 0 tests/components/garage_door/test_demo.py | 51 +++++++++++++++++++ 4 files changed, 60 insertions(+), 13 deletions(-) create mode 100644 tests/components/garage_door/__init__.py create mode 100644 tests/components/garage_door/test_demo.py diff --git a/.coveragerc b/.coveragerc index 3e24b33718c..068624b929a 100644 --- a/.coveragerc +++ b/.coveragerc @@ -149,7 +149,7 @@ omit = homeassistant/components/thermostat/honeywell.py homeassistant/components/thermostat/proliphix.py homeassistant/components/thermostat/radiotherm.py - + homeassistant/components/garage_door/wink.py [report] # Regexes for lines to exclude from consideration diff --git a/homeassistant/components/garage_door/__init__.py b/homeassistant/components/garage_door/__init__.py index 7854d33cb17..ebaa37a78c9 100644 --- a/homeassistant/components/garage_door/__init__.py +++ b/homeassistant/components/garage_door/__init__.py @@ -6,7 +6,7 @@ Component to interface with garage doors that can be controlled remotely. For more details about this component, please refer to the documentation at https://home-assistant.io/components/garage_door/ """ -from datetime import timedelta + import logging import os @@ -27,10 +27,6 @@ ENTITY_ID_ALL_GARAGE_DOORS = group.ENTITY_ID_FORMAT.format('all_garage_doors') ENTITY_ID_FORMAT = DOMAIN + '.{}' -ATTR_CLOSED = "closed" - -MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10) - # Maps discovered services to their platforms DISCOVERY_PLATFORMS = { wink.DISCOVER_GARAGE_DOORS: 'wink' @@ -38,20 +34,19 @@ DISCOVERY_PLATFORMS = { _LOGGER = logging.getLogger(__name__) - def is_closed(hass, entity_id=None): """ Returns if the garage door is closed based on the statemachine. """ entity_id = entity_id or ENTITY_ID_ALL_GARAGE_DOORS return hass.states.is_state(entity_id, STATE_CLOSED) -def close_door(hass, entity_id=None): +def close(hass, entity_id=None): """ Closes all or specified garage door. """ data = {ATTR_ENTITY_ID: entity_id} if entity_id else None hass.services.call(DOMAIN, SERVICE_CLOSE, data) -def open_door(hass, entity_id=None): +def open(hass, entity_id=None): """ Open all or specified garage door. """ data = {ATTR_ENTITY_ID: entity_id} if entity_id else None hass.services.call(DOMAIN, SERVICE_OPEN, data) @@ -70,9 +65,9 @@ def setup(hass, config): for item in target_locks: if service.service == SERVICE_CLOSE: - item.close_door() + item.close() else: - item.open_door() + item.open() if item.should_poll: item.update_ha_state(True) @@ -96,11 +91,11 @@ class GarageDoorDevice(Entity): """ Is the garage door closed or opened. """ return None - def close_door(self): + def close(self): """ Closes the garage door. """ raise NotImplementedError() - def open_door(self): + def open(self): """ Opens the garage door. """ raise NotImplementedError() @@ -110,3 +105,4 @@ class GarageDoorDevice(Entity): if closed is None: return STATE_UNKNOWN return STATE_CLOSED if closed else STATE_OPEN + diff --git a/tests/components/garage_door/__init__.py b/tests/components/garage_door/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/components/garage_door/test_demo.py b/tests/components/garage_door/test_demo.py new file mode 100644 index 00000000000..f52aaa303d3 --- /dev/null +++ b/tests/components/garage_door/test_demo.py @@ -0,0 +1,51 @@ +""" +tests.components.garage_door.test_demo +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Tests demo garage door component. +""" +import unittest + +import homeassistant.core as ha +from homeassistant.components import garage_door + + +LEFT = 'garage_door.left_garage_door' +RIGHT = 'garage_door.right_garage_door' + + +class TestGarageDoorDemo(unittest.TestCase): + """ Test the demo garage door. """ + + def setUp(self): # pylint: disable=invalid-name + self.hass = ha.HomeAssistant() + self.assertTrue(garage_door.setup(self.hass, { + 'garage_door': { + 'platform': 'demo' + } + })) + + def tearDown(self): # pylint: disable=invalid-name + """ Stop down stuff we started. """ + self.hass.stop() + + def test_is_closed(self): + self.assertTrue(garage_door.is_closed(self.hass, LEFT)) + self.hass.states.is_state(LEFT, 'close') + + self.assertFalse(garage_door.is_closed(self.hass, RIGHT)) + self.hass.states.is_state(RIGHT, 'open') + + def test_open_door(self): + garage_door.open_door(self.hass, LEFT) + + self.hass.pool.block_till_done() + + self.assertFalse(garage_door.is_closed(self.hass, LEFT)) + + def test_close_door(self): + garage_door.close_door(self.hass, RIGHT) + + self.hass.pool.block_till_done() + + self.assertTrue(garage_door.is_closed(self.hass, RIGHT)) From 95d9bc48eac4961e774ec54a0c79e9aa511316c0 Mon Sep 17 00:00:00 2001 From: Eric Rolf Date: Thu, 11 Feb 2016 08:23:04 -0500 Subject: [PATCH 13/22] Updated Demo --- homeassistant/components/demo.py | 1 + 1 file changed, 1 insertion(+) diff --git a/homeassistant/components/demo.py b/homeassistant/components/demo.py index 37f93c0625d..e63f5f49551 100644 --- a/homeassistant/components/demo.py +++ b/homeassistant/components/demo.py @@ -21,6 +21,7 @@ COMPONENTS_WITH_DEMO_PLATFORM = [ 'binary_sensor', 'camera', 'device_tracker', + 'garage_door', 'light', 'lock', 'media_player', From 0da09b85def78d9903f66ca2dac8ed52820bd3e0 Mon Sep 17 00:00:00 2001 From: Eric Rolf Date: Thu, 11 Feb 2016 08:30:33 -0500 Subject: [PATCH 14/22] refactored test case --- tests/components/garage_door/test_demo.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/components/garage_door/test_demo.py b/tests/components/garage_door/test_demo.py index f52aaa303d3..7c959709c48 100644 --- a/tests/components/garage_door/test_demo.py +++ b/tests/components/garage_door/test_demo.py @@ -7,7 +7,7 @@ Tests demo garage door component. import unittest import homeassistant.core as ha -from homeassistant.components import garage_door +import homeassistant.components.garage_door as gd LEFT = 'garage_door.left_garage_door' @@ -19,7 +19,7 @@ class TestGarageDoorDemo(unittest.TestCase): def setUp(self): # pylint: disable=invalid-name self.hass = ha.HomeAssistant() - self.assertTrue(garage_door.setup(self.hass, { + self.assertTrue(gd.setup(self.hass, { 'garage_door': { 'platform': 'demo' } @@ -30,22 +30,22 @@ class TestGarageDoorDemo(unittest.TestCase): self.hass.stop() def test_is_closed(self): - self.assertTrue(garage_door.is_closed(self.hass, LEFT)) + self.assertTrue(gd.is_closed(self.hass, LEFT)) self.hass.states.is_state(LEFT, 'close') - self.assertFalse(garage_door.is_closed(self.hass, RIGHT)) + self.assertFalse(gd.is_closed(self.hass, RIGHT)) self.hass.states.is_state(RIGHT, 'open') def test_open_door(self): - garage_door.open_door(self.hass, LEFT) + gd.open_door(self.hass, LEFT) self.hass.pool.block_till_done() - self.assertFalse(garage_door.is_closed(self.hass, LEFT)) + self.assertFalse(gd.is_closed(self.hass, LEFT)) def test_close_door(self): - garage_door.close_door(self.hass, RIGHT) + gd.close_door(self.hass, RIGHT) self.hass.pool.block_till_done() - self.assertTrue(garage_door.is_closed(self.hass, RIGHT)) + self.assertTrue(gd.is_closed(self.hass, RIGHT)) From cab46b91e3d191e7568c22ea070f66b8d97a4f35 Mon Sep 17 00:00:00 2001 From: Eric Rolf Date: Thu, 11 Feb 2016 08:38:05 -0500 Subject: [PATCH 15/22] Updated Requirements All. --- requirements_all.txt | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/requirements_all.txt b/requirements_all.txt index 4ead1a361b3..4bc3acf10af 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -91,7 +91,7 @@ https://github.com/theolind/pymysensors/archive/005bff4c5ca7a56acd30e816bc3bcdb5 https://github.com/w1ll1am23/pygooglevoice-sms/archive/7c5ee9969b97a7992fc86a753fe9f20e3ffa3f7c.zip#pygooglevoice-sms==0.0.1 # homeassistant.components.influxdb -influxdb==2.11.0 +influxdb==2.12.0 # homeassistant.components.insteon_hub insteon_hub==0.4.5 @@ -105,6 +105,10 @@ liffylights==0.9.4 # homeassistant.components.light.limitlessled limitlessled==1.0.0 +# homeassistant.components.sensor.mfi +# homeassistant.components.switch.mfi +mficlient==0.2.2 + # homeassistant.components.discovery netdisco==0.5.2 @@ -153,6 +157,9 @@ pyicloud==0.7.2 # homeassistant.components.device_tracker.netgear pynetgear==0.3.2 +# homeassistant.components.alarm_control_panel.nx584 +pynx584==0.1 + # homeassistant.components.sensor.openweathermap pyowm==2.3.0 @@ -183,13 +190,15 @@ python-telegram-bot==3.2.0 # homeassistant.components.sensor.twitch python-twitch==1.2.0 -# homeassistant.components.wink # homeassistant.components.garage_door.wink +python-wink==0.4.2 + +# homeassistant.components.wink # homeassistant.components.light.wink # homeassistant.components.lock.wink # homeassistant.components.sensor.wink # homeassistant.components.switch.wink -python-wink==0.4.2 +python-wink==0.5.0 # homeassistant.components.keyboard pyuserinput==0.1.9 @@ -197,10 +206,10 @@ pyuserinput==0.1.9 # homeassistant.components.light.vera # homeassistant.components.sensor.vera # homeassistant.components.switch.vera -pyvera==0.2.7 +pyvera==0.2.8 # homeassistant.components.switch.wemo -pywemo==0.3.8 +pywemo==0.3.9 # homeassistant.components.thermostat.radiotherm radiotherm==1.2 @@ -229,6 +238,9 @@ tellive-py==0.5.2 # homeassistant.components.switch.transmission transmissionrpc==0.11 +# homeassistant.components.camera.uvc +uvcclient==0.5 + # homeassistant.components.verisure vsure==0.5.0 From f464d591c9d626e95909e1bc6b660da4099b85b6 Mon Sep 17 00:00:00 2001 From: Eric Rolf Date: Thu, 11 Feb 2016 08:49:07 -0500 Subject: [PATCH 16/22] Update python wink requirement --- homeassistant/components/garage_door/wink.py | 2 +- requirements_all.txt | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/homeassistant/components/garage_door/wink.py b/homeassistant/components/garage_door/wink.py index 5b43ff4c032..73d6928b9e2 100644 --- a/homeassistant/components/garage_door/wink.py +++ b/homeassistant/components/garage_door/wink.py @@ -11,7 +11,7 @@ import logging from homeassistant.components.garage_door import GarageDoorDevice from homeassistant.const import CONF_ACCESS_TOKEN -REQUIREMENTS = ['python-wink==0.4.2'] +REQUIREMENTS = ['python-wink==0.5.0'] def setup_platform(hass, config, add_devices, discovery_info=None): diff --git a/requirements_all.txt b/requirements_all.txt index f66900c67dc..4202d34becd 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -190,9 +190,6 @@ python-telegram-bot==3.2.0 # homeassistant.components.sensor.twitch python-twitch==1.2.0 -# homeassistant.components.garage_door.wink -python-wink==0.4.2 - # homeassistant.components.wink # homeassistant.components.garage_door.wink # homeassistant.components.light.wink From 034cec7152e18307ef006e45538864db66cacea3 Mon Sep 17 00:00:00 2001 From: Eric Rolf Date: Thu, 11 Feb 2016 09:06:35 -0500 Subject: [PATCH 17/22] Fixed Demo Test Cases --- tests/components/garage_door/test_demo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/components/garage_door/test_demo.py b/tests/components/garage_door/test_demo.py index 7c959709c48..38aa2930a8b 100644 --- a/tests/components/garage_door/test_demo.py +++ b/tests/components/garage_door/test_demo.py @@ -37,14 +37,14 @@ class TestGarageDoorDemo(unittest.TestCase): self.hass.states.is_state(RIGHT, 'open') def test_open_door(self): - gd.open_door(self.hass, LEFT) + gd.open(self.hass, LEFT) self.hass.pool.block_till_done() self.assertFalse(gd.is_closed(self.hass, LEFT)) def test_close_door(self): - gd.close_door(self.hass, RIGHT) + gd.close(self.hass, RIGHT) self.hass.pool.block_till_done() From fd0afaa204f90f39e30f3e0229d6bfbcfa320246 Mon Sep 17 00:00:00 2001 From: Eric Rolf Date: Thu, 11 Feb 2016 09:12:28 -0500 Subject: [PATCH 18/22] Fixed Test Case Logic --- tests/components/garage_door/test_demo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/components/garage_door/test_demo.py b/tests/components/garage_door/test_demo.py index 38aa2930a8b..5e510851f30 100644 --- a/tests/components/garage_door/test_demo.py +++ b/tests/components/garage_door/test_demo.py @@ -41,11 +41,11 @@ class TestGarageDoorDemo(unittest.TestCase): self.hass.pool.block_till_done() - self.assertFalse(gd.is_closed(self.hass, LEFT)) + self.assertTrue(gd.is_closed(self.hass, LEFT)) def test_close_door(self): gd.close(self.hass, RIGHT) self.hass.pool.block_till_done() - self.assertTrue(gd.is_closed(self.hass, RIGHT)) + self.assertFalse(gd.is_closed(self.hass, RIGHT)) From 175b49236cdb6c47d58cee2f070fffe73c6b4211 Mon Sep 17 00:00:00 2001 From: Eric Rolf Date: Thu, 11 Feb 2016 09:20:38 -0500 Subject: [PATCH 19/22] Fixed style attribute with redefined built in method names. --- homeassistant/components/garage_door/__init__.py | 4 ++-- tests/components/garage_door/test_demo.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/garage_door/__init__.py b/homeassistant/components/garage_door/__init__.py index ebaa37a78c9..2dc77885294 100644 --- a/homeassistant/components/garage_door/__init__.py +++ b/homeassistant/components/garage_door/__init__.py @@ -91,11 +91,11 @@ class GarageDoorDevice(Entity): """ Is the garage door closed or opened. """ return None - def close(self): + def close_door(self): """ Closes the garage door. """ raise NotImplementedError() - def open(self): + def open_door(self): """ Opens the garage door. """ raise NotImplementedError() diff --git a/tests/components/garage_door/test_demo.py b/tests/components/garage_door/test_demo.py index 5e510851f30..a0b80235a94 100644 --- a/tests/components/garage_door/test_demo.py +++ b/tests/components/garage_door/test_demo.py @@ -37,14 +37,14 @@ class TestGarageDoorDemo(unittest.TestCase): self.hass.states.is_state(RIGHT, 'open') def test_open_door(self): - gd.open(self.hass, LEFT) + gd.open_door(self.hass, LEFT) self.hass.pool.block_till_done() self.assertTrue(gd.is_closed(self.hass, LEFT)) def test_close_door(self): - gd.close(self.hass, RIGHT) + gd.close_door(self.hass, RIGHT) self.hass.pool.block_till_done() From be9a2a043ec0313971c5d52d3e1945c6cbaa1c53 Mon Sep 17 00:00:00 2001 From: Eric Rolf Date: Thu, 11 Feb 2016 09:57:56 -0500 Subject: [PATCH 20/22] Refactored Method Names. --- homeassistant/components/garage_door/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/garage_door/__init__.py b/homeassistant/components/garage_door/__init__.py index 2dc77885294..835aa36cc62 100644 --- a/homeassistant/components/garage_door/__init__.py +++ b/homeassistant/components/garage_door/__init__.py @@ -34,19 +34,20 @@ DISCOVERY_PLATFORMS = { _LOGGER = logging.getLogger(__name__) + def is_closed(hass, entity_id=None): """ Returns if the garage door is closed based on the statemachine. """ entity_id = entity_id or ENTITY_ID_ALL_GARAGE_DOORS return hass.states.is_state(entity_id, STATE_CLOSED) -def close(hass, entity_id=None): +def close_door(hass, entity_id=None): """ Closes all or specified garage door. """ data = {ATTR_ENTITY_ID: entity_id} if entity_id else None hass.services.call(DOMAIN, SERVICE_CLOSE, data) -def open(hass, entity_id=None): +def open_door(hass, entity_id=None): """ Open all or specified garage door. """ data = {ATTR_ENTITY_ID: entity_id} if entity_id else None hass.services.call(DOMAIN, SERVICE_OPEN, data) @@ -65,9 +66,9 @@ def setup(hass, config): for item in target_locks: if service.service == SERVICE_CLOSE: - item.close() + item.close_door() else: - item.open() + item.open_door() if item.should_poll: item.update_ha_state(True) From 23e3b8d2f2eb88643069521469a9d081bcea0e0d Mon Sep 17 00:00:00 2001 From: Eric Rolf Date: Thu, 11 Feb 2016 10:00:12 -0500 Subject: [PATCH 21/22] Fixed Style Issue --- homeassistant/components/garage_door/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/homeassistant/components/garage_door/__init__.py b/homeassistant/components/garage_door/__init__.py index 835aa36cc62..705b4ce547e 100644 --- a/homeassistant/components/garage_door/__init__.py +++ b/homeassistant/components/garage_door/__init__.py @@ -106,4 +106,3 @@ class GarageDoorDevice(Entity): if closed is None: return STATE_UNKNOWN return STATE_CLOSED if closed else STATE_OPEN - From cca6b0c28747a3b0307fccd33dee60fcb42d910d Mon Sep 17 00:00:00 2001 From: Eric Rolf Date: Thu, 11 Feb 2016 10:16:49 -0500 Subject: [PATCH 22/22] Test Fix. --- tests/components/garage_door/test_demo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/components/garage_door/test_demo.py b/tests/components/garage_door/test_demo.py index a0b80235a94..7c959709c48 100644 --- a/tests/components/garage_door/test_demo.py +++ b/tests/components/garage_door/test_demo.py @@ -41,11 +41,11 @@ class TestGarageDoorDemo(unittest.TestCase): self.hass.pool.block_till_done() - self.assertTrue(gd.is_closed(self.hass, LEFT)) + self.assertFalse(gd.is_closed(self.hass, LEFT)) def test_close_door(self): gd.close_door(self.hass, RIGHT) self.hass.pool.block_till_done() - self.assertFalse(gd.is_closed(self.hass, RIGHT)) + self.assertTrue(gd.is_closed(self.hass, RIGHT))