Merge branch 'pep257-garage' into dev

This commit is contained in:
Fabian Affolter 2016-03-08 08:10:25 +01:00
commit 391c6a358a
3 changed files with 15 additions and 11 deletions

View File

@ -33,13 +33,13 @@ _LOGGER = logging.getLogger(__name__)
def is_closed(hass, entity_id=None): def is_closed(hass, entity_id=None):
"""Returns if the garage door is closed based on the statemachine.""" """Return if the garage door is closed based on the statemachine."""
entity_id = entity_id or ENTITY_ID_ALL_GARAGE_DOORS entity_id = entity_id or ENTITY_ID_ALL_GARAGE_DOORS
return hass.states.is_state(entity_id, STATE_CLOSED) return hass.states.is_state(entity_id, STATE_CLOSED)
def close_door(hass, entity_id=None): def close_door(hass, entity_id=None):
"""Closes all or specified garage door.""" """Close all or a specified garage door."""
data = {ATTR_ENTITY_ID: entity_id} if entity_id else None data = {ATTR_ENTITY_ID: entity_id} if entity_id else None
hass.services.call(DOMAIN, SERVICE_CLOSE, data) hass.services.call(DOMAIN, SERVICE_CLOSE, data)
@ -58,7 +58,7 @@ def setup(hass, config):
component.setup(config) component.setup(config)
def handle_garage_door_service(service): def handle_garage_door_service(service):
"""Handles calls to the garage door services.""" """Handle calls to the garage door services."""
target_locks = component.extract_from_service(service) target_locks = component.extract_from_service(service)
for item in target_locks: for item in target_locks:
@ -81,7 +81,8 @@ def setup(hass, config):
class GarageDoorDevice(Entity): class GarageDoorDevice(Entity):
"""Represents a garage door.""" """Representation of a garage door."""
# pylint: disable=no-self-use # pylint: disable=no-self-use
@property @property
def is_closed(self): def is_closed(self):
@ -98,7 +99,7 @@ class GarageDoorDevice(Entity):
@property @property
def state(self): def state(self):
"""Returns the state of the garage door.""" """Return the state of the garage door."""
closed = self.is_closed closed = self.is_closed
if closed is None: if closed is None:
return STATE_UNKNOWN return STATE_UNKNOWN

View File

@ -19,7 +19,9 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
class DemoGarageDoor(GarageDoorDevice): class DemoGarageDoor(GarageDoorDevice):
"""Provides a demo garage door.""" """Provides a demo garage door."""
def __init__(self, name, state): def __init__(self, name, state):
"""Initialize the garage door."""
self._name = name self._name = name
self._state = state self._state = state

View File

@ -13,7 +13,7 @@ REQUIREMENTS = ['python-wink==0.6.2']
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
"""Sets up the Wink garage door platform.""" """Setup the Wink garage door platform."""
import pywink import pywink
if discovery_info is None: if discovery_info is None:
@ -32,19 +32,20 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class WinkGarageDoorDevice(GarageDoorDevice): class WinkGarageDoorDevice(GarageDoorDevice):
"""Represents a Wink garage door.""" """Representation of a Wink garage door."""
def __init__(self, wink): def __init__(self, wink):
"""Initialize the garage door."""
self.wink = wink self.wink = wink
@property @property
def unique_id(self): def unique_id(self):
"""Returns the id of this wink garage door.""" """Return the ID of this wink garage door."""
return "{}.{}".format(self.__class__, self.wink.device_id()) return "{}.{}".format(self.__class__, self.wink.device_id())
@property @property
def name(self): def name(self):
"""Returns the name of the garage door if any.""" """Return the name of the garage door if any."""
return self.wink.name() return self.wink.name()
def update(self): def update(self):
@ -53,11 +54,11 @@ class WinkGarageDoorDevice(GarageDoorDevice):
@property @property
def is_closed(self): def is_closed(self):
"""Returns true if door is closed.""" """Return true if door is closed."""
return self.wink.state() == 0 return self.wink.state() == 0
def close_door(self): def close_door(self):
"""Closes the door.""" """Close the door."""
self.wink.set_state(0) self.wink.set_state(0)
def open_door(self): def open_door(self):