Update docstrings

This commit is contained in:
Fabian Affolter committed 2016-02-03 00:35:53 +01:00
1 parent 635369ad65
commit b19fbd8e72
2 files changed
+37 -66

No files matched your search

+21 -27
View File
@@ -1,6 +1,6 @@
"""
homeassistant.components.scsgate
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Provides support for SCSGate components.
For more details about this component, please refer to the documentation at
@@ -11,16 +11,13 @@ from threading import Lock
from homeassistant.core import EVENT_HOMEASSISTANT_STOP
REQUIREMENTS = ['scsgate==0.1.0']
DOMAIN = "scsgate"
SCSGATE = None
_LOGGER = logging.getLogger(__name__)
class SCSGate:
""" Class dealing with the SCSGate device via scsgate.Reactor """
""" Class dealing with the SCSGate device via scsgate.Reactor. """
def __init__(self, device, logger):
self._logger = logger
@@ -40,7 +37,7 @@ class SCSGate:
handle_message=self.handle_message)
def handle_message(self, message):
""" Method called whenever a message is seen on the bus """
""" Method called whenever a message is seen on the bus. """
from scsgate.messages import StateMessage, ScenarioTriggeredMessage
self._logger.debug("Received message {}".format(message))
@@ -74,31 +71,30 @@ class SCSGate:
@property
def devices(self):
""" Dictionary with known devices. Key is device ID,
value is the device itself """
"""
Dictionary with known devices. Key is device ID, value is the device
itself.
"""
return self._devices
def add_device(self, device):
""" Adds the specified device to the list of the already registered ones.
"""
Adds the specified device to the list of the already registered ones.
Beware: this is not what you usually want to do, take
a look at `add_devices_to_register`
Beware: this is not what you usually want to do, take a look at
`add_devices_to_register`
"""
self._devices[device.scs_id] = device
def add_devices_to_register(self, devices):
""" List of devices to be registered.
Arguments:
* devices: list of devices to register
"""
""" List of devices to be registered. """
with self._devices_to_register_lock:
for device in devices:
self._devices_to_register[device.scs_id] = device
self._activate_next_device()
def _activate_next_device(self):
""" Starts the activation of the 1st device inside of self._devices """
""" Starts the activation of the first device. """
from scsgate.tasks import GetStatusTask
with self._devices_to_register_lock:
@@ -110,11 +106,7 @@ class SCSGate:
self._reactor.append_task(GetStatusTask(target=device.scs_id))
def is_device_registered(self, device_id):
""" Checks whether a device is already registered or not
Arguments:
device_id: the ID of the device to look for
"""
""" Checks whether a device is already registered or not. """
with self._devices_to_register_lock:
if device_id in self._devices_to_register.keys():
return False
@@ -126,15 +118,15 @@ class SCSGate:
return True
def start(self):
""" Start the scsgate.Reactor """
""" Start the scsgate.Reactor. """
self._reactor.start()
def stop(self):
""" Stop the scsgate.Reactor """
""" Stop the scsgate.Reactor. """
self._reactor.stop()
def append_task(self, task):
""" Registers a new task to be executed """
""" Registers a new task to be executed. """
self._reactor.append_task(task)
@@ -152,8 +144,10 @@ def setup(hass, config):
return False
def stop_monitor(event):
""" Invoked when home-assistant is exiting. Performs the necessary
cleanups """
"""
Invoked when home-assistant is exiting. Performs the necessary
cleanups.
"""
_LOGGER.info("Stopping SCSGate monitor thread")
SCSGATE.stop()