Update docstrings to match PEP257

This commit is contained in:
Fabian Affolter 2016-03-07 18:49:31 +01:00
parent 7ff9aecd4e
commit b8a40457ee
40 changed files with 371 additions and 483 deletions

View File

@ -1,8 +1,5 @@
"""
homeassistant.components.apcupsd
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sets up and provides access to the status output of APCUPSd via its Network
Information Server (NIS).
Support for status output of APCUPSd via its Network Information Server (NIS).
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/apcupsd/

View File

@ -1,8 +1,5 @@
"""
components.arduino
~~~~~~~~~~~~~~~~~~
Arduino component that connects to a directly attached Arduino board which
runs with the Firmata firmware.
Support for Arduino boards running with the Firmata firmware.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/arduino/
@ -21,7 +18,6 @@ _LOGGER = logging.getLogger(__name__)
def setup(hass, config):
"""Setup the Arduino component."""
if not validate_config(config,
{DOMAIN: ['port']},
_LOGGER):
@ -54,14 +50,13 @@ def setup(hass, config):
class ArduinoBoard(object):
"""Represents an Arduino board."""
def __init__(self, port):
from PyMata.pymata import PyMata
self._port = port
self._board = PyMata(self._port, verbose=False)
def set_mode(self, pin, direction, mode):
""" Sets the mode and the direction of a given pin. """
"""Set the mode and the direction of a given pin."""
if mode == 'analog' and direction == 'in':
self._board.set_pin_mode(pin,
self._board.INPUT,
@ -89,19 +84,19 @@ class ArduinoBoard(object):
return self._board.get_analog_response_table()
def set_digital_out_high(self, pin):
""" Sets a given digital pin to high. """
"""Set a given digital pin to high."""
self._board.digital_write(pin, 1)
def set_digital_out_low(self, pin):
""" Sets a given digital pin to low. """
"""Set a given digital pin to low."""
self._board.digital_write(pin, 0)
def get_digital_in(self, pin):
""" Gets the value from a given digital pin. """
"""Get the value from a given digital pin."""
self._board.digital_read(pin)
def get_analog_in(self, pin):
""" Gets the value from a given analog pin. """
"""Get the value from a given analog pin."""
self._board.analog_read(pin)
def get_firmata(self):

View File

@ -1,6 +1,4 @@
"""
homeassistant.components.bloomsky
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support for BloomSky weather station.
For more details about this component, please refer to the documentation at

View File

@ -1,8 +1,5 @@
"""
homeassistant.components.configurator
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A component to allow pieces of code to request configuration from the user.
Support to allow pieces of code to request configuration from the user.
Initiate a request by calling the `request_config` method with a callback.
This will return a request id that has to be used for future calls.
@ -38,9 +35,9 @@ _LOGGER = logging.getLogger(__name__)
def request_config(
hass, name, callback, description=None, description_image=None,
submit_caption=None, fields=None):
""" Create a new request for config.
Will return an ID to be used for sequent calls. """
"""Create a new request for configuration.
Will return an ID to be used for sequent calls.
"""
instance = _get_instance(hass)
request_id = instance.request_config(
@ -62,7 +59,7 @@ def notify_errors(request_id, error):
def request_done(request_id):
""" Mark a config request as done. """
"""Mark a configuration request as done."""
try:
_REQUESTS.pop(request_id).request_done(request_id)
except KeyError:
@ -71,7 +68,7 @@ def request_done(request_id):
def setup(hass, config):
""" Set up Configurator. """
"""Setup the configurator component."""
return True
@ -89,10 +86,7 @@ def _get_instance(hass):
class Configurator(object):
"""
Class to keep track of current configuration requests.
"""
"""Class to keep track of current configuration requests."""
def __init__(self, hass):
self.hass = hass
self._cur_id = 0
@ -105,7 +99,6 @@ class Configurator(object):
self, name, callback,
description, description_image, submit_caption, fields):
"""Setup a request for configuration."""
entity_id = generate_entity_id(ENTITY_ID_FORMAT, name, hass=self.hass)
if fields is None:
@ -147,7 +140,7 @@ class Configurator(object):
self.hass.states.set(entity_id, STATE_CONFIGURE, new_data)
def request_done(self, request_id):
""" Remove the config request. """
"""Remove the configuration request."""
if not self._validate_request_id(request_id):
return
@ -180,7 +173,7 @@ class Configurator(object):
callback(call.data.get(ATTR_FIELDS, {}))
def _generate_unique_id(self):
""" Generates a unique configurator id. """
"""Generates a unique configurator ID."""
self._cur_id += 1
return "{}-{}".format(id(self), self._cur_id)

View File

@ -1,7 +1,5 @@
"""
homeassistant.components.conversation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Provides functionality to have conversations with Home Assistant.
Support for functionality to have conversations with Home Assistant.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/conversation/
@ -31,7 +29,7 @@ def setup(hass, config):
logger = logging.getLogger(__name__)
def process(service):
""" Parses text into commands for Home Assistant. """
"""Parses text into commands."""
if ATTR_TEXT not in service.data:
logger.error("Received process service call without a text")
return

View File

@ -29,7 +29,7 @@ CONF_DEVICE_GROUP = 'device_group'
# pylint: disable=too-many-locals
def setup(hass, config):
""" Triggers to turn lights on or off based on device precense. """
"""Triggers to turn lights on or off based on device presence."""
logger = logging.getLogger(__name__)
device_tracker = get_component('device_tracker')
group = get_component('group')
@ -78,26 +78,29 @@ def setup(hass, config):
@track_state_change(sun.ENTITY_ID, sun.STATE_BELOW_HORIZON,
sun.STATE_ABOVE_HORIZON)
def schedule_lights_at_sun_set(hass, entity, old_state, new_state):
"""The moment sun sets we want to have all the lights on.
"""
The moment sun sets we want to have all the lights on.
We will schedule to have each light start after one another
and slowly transition in."""
and slowly transition in.
"""
start_point = calc_time_for_light_when_sunset()
if not start_point:
return
def turn_on(light_id):
""" Lambda can keep track of function parameters but not local
"""
Lambda can keep track of function parameters but not local
parameters. If we put the lambda directly in the below statement
only the last light will be turned on.. """
only the last light will be turned on.
"""
return lambda now: turn_light_on_before_sunset(light_id)
for index, light_id in enumerate(light_ids):
track_point_in_time(hass, turn_on(light_id),
start_point + index * LIGHT_TRANSITION_TIME)
# If the sun is already above horizon
# schedule the time-based pre-sun set event
# If the sun is already above horizon schedule the time-based pre-sun set
# event.
if sun.is_on(hass):
schedule_lights_at_sun_set(hass, None, None, None)

View File

@ -37,8 +37,8 @@ SERVICE_HANDLERS = {
def listen(hass, service, callback):
"""Setup listener for discovery of specific service.
"""
Setup listener for discovery of specific service.
Service can be a string or a list/tuple.
"""
if isinstance(service, str):
@ -55,10 +55,7 @@ def listen(hass, service, callback):
def discover(hass, service, discovered=None, component=None, hass_config=None):
"""Fire discovery event.
Can ensure a component is loaded.
"""
"""Fire discovery event. Can ensure a component is loaded."""
if component is not None:
bootstrap.setup_component(hass, component, hass_config)
@ -90,7 +87,7 @@ def setup(hass, config):
component = SERVICE_HANDLERS.get(service)
# We do not know how to handle this service
# We do not know how to handle this service.
if not component:
return

View File

@ -1,7 +1,5 @@
"""
homeassistant.components.downloader
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Provides functionality to download files.
Support for functionality to download files.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/downloader/
@ -29,7 +27,6 @@ CONF_DOWNLOAD_DIR = 'download_dir'
# pylint: disable=too-many-branches
def setup(hass, config):
"""Listens for download events to download files."""
logger = logging.getLogger(__name__)
if not validate_config(config, {DOMAIN: [CONF_DOWNLOAD_DIR]}, logger):
@ -50,8 +47,7 @@ def setup(hass, config):
return False
def download_file(service):
""" Starts thread to download file specified in the url. """
"""Starts thread to download file specified in the URL."""
if ATTR_URL not in service.data:
logger.error("Service called but 'url' parameter not specified.")
return

View File

@ -1,7 +1,5 @@
"""
homeassistant.components.ecobee
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ecobee component
Support for Ecobee.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/ecobee/
@ -31,7 +29,7 @@ _LOGGER = logging.getLogger(__name__)
ECOBEE_CONFIG_FILE = 'ecobee.conf'
_CONFIGURING = {}
# Return cached results if last scan was less then this time ago
# Return cached results if last scan was less then this time ago.
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=180)
@ -94,7 +92,6 @@ def setup_ecobee(hass, network, config):
# pylint: disable=too-few-public-methods
class EcobeeData(object):
"""Gets the latest data and update the states."""
def __init__(self, config_file):
from pyecobee import Ecobee
self.ecobee = Ecobee(config_file)

View File

@ -1,6 +1,4 @@
"""
homeassistant.components.history
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Provide pre-made queries on top of the recorder component.
For more details about this component, please refer to the documentation at
@ -39,12 +37,12 @@ def last_5_states(entity_id):
def get_significant_states(start_time, end_time=None, entity_id=None):
"""Return states changes during UTC period start_time - end_time.
"""
Return states changes during UTC period start_time - end_time.
Significant states are all states where there is a state change,
as well as all states from certain domains (for instance
thermostat so that we get current temperature in our graphs).
"""
where = """
(domain IN ({}) OR last_changed=last_updated)
@ -124,7 +122,8 @@ def get_states(utc_point_in_time, entity_ids=None, run=None):
def states_to_json(states, start_time, entity_id):
"""Converts SQL results into JSON friendly data structure.
"""
Converts SQL results into JSON friendly data structure.
This takes our state list and turns it into a JSON friendly data
structure {'entity_id': [list of states], 'entity_id2': [list of states]}
@ -133,7 +132,6 @@ def states_to_json(states, start_time, entity_id):
each list of states, otherwise our graphs won't start on the Y
axis correctly.
"""
result = defaultdict(list)
entity_ids = [entity_id] if entity_id is not None else None
@ -206,7 +204,8 @@ def _api_history_period(handler, path_match, data):
def _is_significant(state):
"""Test if state is significant for history charts.
"""
Test if state is significant for history charts.
Will only test for things that are not filtered out in SQL.
"""

View File

@ -1,6 +1,4 @@
"""
homeassistant.components.http
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This module provides an API and a HTTP interface for debug purposes.
For more details about the RESTful API, please refer to the documentation at
@ -89,7 +87,6 @@ def setup(hass, config):
class HomeAssistantHTTPServer(ThreadingMixIn, HTTPServer):
"""Handle HTTP requests in a threaded fashion."""
# pylint: disable=too-few-public-methods
allow_reuse_address = True
daemon_threads = True
@ -144,7 +141,7 @@ class HomeAssistantHTTPServer(ThreadingMixIn, HTTPServer):
self.paths.append((method, url, callback, require_auth))
def log_message(self, fmt, *args):
""" Redirect built-in log to HA logging """
"""Redirect built-in log to HA logging."""
# pylint: disable=no-self-use
_LOGGER.info(fmt, *args)
@ -157,17 +154,16 @@ class RequestHandler(SimpleHTTPRequestHandler):
We extend from SimpleHTTPRequestHandler instead of Base so we
can use the guess content type methods.
"""
server_version = "HomeAssistant/1.0"
def __init__(self, req, client_addr, server):
""" Contructor, call the base constructor and set up session """
"""Contructor, call the base constructor and set up session."""
# Track if this was an authenticated request
self.authenticated = False
SimpleHTTPRequestHandler.__init__(self, req, client_addr, server)
def log_message(self, fmt, *arguments):
""" Redirect built-in log to HA logging """
"""Redirect built-in log to HA logging."""
if self.server.api_password is None:
_LOGGER.info(fmt, *arguments)
else:
@ -354,7 +350,7 @@ class RequestHandler(SimpleHTTPRequestHandler):
self.copyfile(inp, self.wfile)
def set_cache_header(self):
""" Add cache headers if not in development """
"""Add cache headers if not in development."""
if self.server.development:
return
@ -369,7 +365,7 @@ class RequestHandler(SimpleHTTPRequestHandler):
self.date_time_string(time.time()+cache_time))
def set_session_cookie_header(self):
""" Add the header for the session cookie and return session id. """
"""Add the header for the session cookie and return session ID."""
if not self.authenticated:
return None
@ -392,8 +388,8 @@ class RequestHandler(SimpleHTTPRequestHandler):
def get_cookie_session_id(self):
"""
Extracts the current session id from the
cookie or returns None if not set or invalid
Extracts the current session id from the cookie or returns None if not
set or invalid.
"""
if 'Cookie' not in self.headers:
return None
@ -433,9 +429,9 @@ def session_valid_time():
class SessionStore(object):
""" Responsible for storing and retrieving http sessions """
"""Responsible for storing and retrieving HTTP sessions."""
def __init__(self):
""" Set up the session store """
"""Setup the session store."""
self._sessions = {}
self._lock = threading.RLock()

View File

@ -1,7 +1,5 @@
"""
homeassistant.components.ifttt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This component enable you to trigger Maker IFTTT recipes.
Support to trigger Maker IFTTT recipes.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/ifttt/
@ -38,15 +36,14 @@ def trigger(hass, event, value1=None, value2=None, value3=None):
def setup(hass, config):
""" Setup the ifttt service component. """
"""Setup the IFTTT service component."""
if not validate_config(config, {DOMAIN: ['key']}, _LOGGER):
return False
key = config[DOMAIN]['key']
def trigger_service(call):
""" Handle ifttt trigger service calls. """
"""Handle IFTTT trigger service calls."""
event = call.data.get(ATTR_EVENT)
value1 = call.data.get(ATTR_VALUE1)
value2 = call.data.get(ATTR_VALUE2)

View File

@ -1,6 +1,4 @@
"""
homeassistant.components.input_boolean
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Component to keep track of user controlled booleans for within automation.
For more details about this component, please refer to the documentation
@ -87,7 +85,6 @@ def setup(hass, config):
class InputBoolean(ToggleEntity):
"""Represent a boolean input."""
def __init__(self, object_id, name, state, icon):
""" Initialize a boolean input. """
self.entity_id = ENTITY_ID_FORMAT.format(object_id)
@ -97,22 +94,22 @@ class InputBoolean(ToggleEntity):
@property
def should_poll(self):
"""If entitiy should be polled."""
"""If entity should be polled."""
return False
@property
def name(self):
"""Name of the boolean input."""
"""Return name of the boolean input."""
return self._name
@property
def icon(self):
"""Icon to be used for this entity."""
"""Returh the icon to be used for this entity."""
return self._icon
@property
def is_on(self):
"""True if entity is on."""
"""Return true if entity is on."""
return self._state
def turn_on(self, **kwargs):

View File

@ -1,6 +1,4 @@
"""
homeassistant.components.input_select
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Component to offer a way to select an option from a list.
For more details about this component, please refer to the documentation
@ -93,7 +91,6 @@ def setup(hass, config):
class InputSelect(Entity):
"""Represent a select input."""
# pylint: disable=too-many-arguments
def __init__(self, object_id, name, state, options, icon):
""" Initialize a select input. """
@ -110,22 +107,22 @@ class InputSelect(Entity):
@property
def name(self):
""" Name of the select input. """
"""Return the name of the select input."""
return self._name
@property
def icon(self):
""" Icon to be used for this entity. """
"""Return the icon to be used for this entity."""
return self._icon
@property
def state(self):
""" State of the component. """
"""Return the state of the component."""
return self._current_option
@property
def state_attributes(self):
""" State attributes. """
"""Return the state attributes."""
return {
ATTR_OPTIONS: self._options,
}

View File

@ -1,6 +1,4 @@
"""
homeassistant.components.insteon_hub
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support for Insteon Hub.
For more details about this component, please refer to the documentation at
@ -58,20 +56,19 @@ def setup(hass, config):
class InsteonToggleDevice(ToggleEntity):
""" Abstract Class for an Insteon node. """
""" An abstract Class for an Insteon node."""
def __init__(self, node):
self.node = node
self._value = 0
@property
def name(self):
""" Returns the name of the node. """
"""Return the the name of the node."""
return self.node.DeviceName
@property
def unique_id(self):
""" Returns the id of this insteon node. """
"""Return the ID of this insteon node."""
return self.node.DeviceID
def update(self):
@ -84,7 +81,7 @@ class InsteonToggleDevice(ToggleEntity):
@property
def is_on(self):
""" Returns boolean response if the node is on. """
"""Return the boolean response if the node is on."""
return self._value != 0
def turn_on(self, **kwargs):

View File

@ -1,6 +1,4 @@
"""
homeassistant.components.introduction
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Component that will help guide the user taking its first steps.
For more details about this component, please refer to the documentation at

View File

@ -1,8 +1,5 @@
"""
homeassistant.components.isy994
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Connects to an ISY-994 controller and loads relevant components to control its
devices. Also contains the base classes for ISY Sensors, Lights, and Switches.
Support the ISY-994 controllers.
For configuration details please visit the documentation for this component at
https://home-assistant.io/components/isy994/
@ -45,7 +42,7 @@ def setup(hass, config):
_LOGGER):
return False
# pull and parse standard configuration
# Pull and parse standard configuration.
user = config[DOMAIN][CONF_USERNAME]
password = config[DOMAIN][CONF_PASSWORD]
host = urlparse(config[DOMAIN][CONF_HOST])
@ -62,24 +59,24 @@ def setup(hass, config):
port = host.port
addr = addr.replace(':{}'.format(port), '')
# pull and parse optional configuration
# Pull and parse optional configuration.
global SENSOR_STRING
global HIDDEN_STRING
SENSOR_STRING = str(config[DOMAIN].get('sensor_string', SENSOR_STRING))
HIDDEN_STRING = str(config[DOMAIN].get('hidden_string', HIDDEN_STRING))
tls_version = config[DOMAIN].get(CONF_TLS_VER, None)
# connect to ISY controller
# Connect to ISY controller.
global ISY
ISY = PyISY.ISY(addr, port, user, password, use_https=https,
tls_ver=tls_version, log=_LOGGER)
if not ISY.connected:
return False
# listen for HA stop to disconnect
# Listen for HA stop to disconnect.
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop)
# Load components for the devices in the ISY controller that we support
# Load components for the devices in the ISY controller that we support.
for comp_name, discovery in ((('sensor', DISCOVER_SENSORS),
('light', DISCOVER_LIGHTS),
('switch', DISCOVER_SWITCHES))):
@ -99,8 +96,7 @@ def stop(event):
class ISYDeviceABC(ToggleEntity):
""" Abstract Class for an ISY device. """
"""An abstract Class for an ISY device."""
_attrs = {}
_onattrs = []
_states = []
@ -117,35 +113,35 @@ class ISYDeviceABC(ToggleEntity):
subscribe('changed', self.on_update)
def __del__(self):
""" cleanup subscriptions because it is the right thing to do. """
"""Cleanup subscriptions because it is the right thing to do."""
self._change_handler.unsubscribe()
@property
def domain(self):
""" Returns the domain of the entity. """
"""Return the domain of the entity."""
return self._domain
@property
def dtype(self):
""" Returns the data type of the entity (binary or analog). """
"""Return the data type of the entity (binary or analog)."""
if self._dtype in ['analog', 'binary']:
return self._dtype
return 'binary' if self.unit_of_measurement is None else 'analog'
@property
def should_poll(self):
""" Tells Home Assistant not to poll this entity. """
"""No polling needed."""
return False
@property
def value(self):
""" Returns the unclean value from the controller. """
"""Return the unclean value from the controller."""
# pylint: disable=protected-access
return self.node.status._val
@property
def state_attributes(self):
""" Returns the state attributes for the node. """
"""Return the state attributes for the node."""
attr = {}
for name, prop in self._attrs.items():
attr[name] = getattr(self, prop)
@ -153,25 +149,25 @@ class ISYDeviceABC(ToggleEntity):
return attr
def _attr_filter(self, attr):
""" Placeholder for attribute filters. """
"""A Placeholder for attribute filters."""
# pylint: disable=no-self-use
return attr
@property
def unique_id(self):
""" Returns the id of this ISY sensor. """
"""Return the ID of this ISY sensor."""
# pylint: disable=protected-access
return self.node._id
@property
def raw_name(self):
""" Returns the unclean node name. """
"""Return the unclean node name."""
return str(self._name) \
if self._name is not None else str(self.node.name)
@property
def name(self):
""" Returns the cleaned name of the node. """
"""Return the cleaned name of the node."""
return self.raw_name.replace(HIDDEN_STRING, '').strip() \
.replace('_', ' ')
@ -191,17 +187,17 @@ class ISYDeviceABC(ToggleEntity):
@property
def is_on(self):
""" Returns boolean response if the node is on. """
"""Return a boolean response if the node is on."""
return bool(self.value)
@property
def is_open(self):
""" Returns boolean respons if the node is open. On = Open. """
"""Return boolean response if the node is open. On = Open."""
return self.is_on
@property
def state(self):
""" Returns the state of the node. """
"""Return the state of the node."""
if len(self._states) > 0:
return self._states[0] if self.is_on else self._states[1]
return self.value
@ -223,7 +219,7 @@ class ISYDeviceABC(ToggleEntity):
@property
def unit_of_measurement(self):
""" Returns the defined units of measurement or None. """
"""Return the defined units of measurement or None."""
try:
return self.node.units
except AttributeError:

View File

@ -1,6 +1,4 @@
"""
homeassistant.components.keyboard
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Provides functionality to emulate keyboard presses on host machine.
For more details about this component, please refer to the documentation at

View File

@ -56,7 +56,6 @@ def log_entry(hass, name, message, domain=None, entity_id=None):
def setup(hass, config):
"""Listens for download events to download files."""
def log_message(service):
"""Handle sending notification message service calls."""
message = service.data.get(ATTR_MESSAGE)
@ -101,7 +100,6 @@ def _handle_get_logbook(handler, path_match, data):
class Entry(object):
"""A human readable version of the log."""
# pylint: disable=too-many-arguments, too-few-public-methods
def __init__(self, when=None, name=None, message=None, domain=None,
entity_id=None):
@ -237,7 +235,6 @@ def _entry_message_from_state(domain, state):
"""Convert a state to a message for the logbook."""
# We pass domain in so we don't have to split entity_id again
# pylint: disable=too-many-return-statements
if domain == 'device_tracker':
if state.state == STATE_NOT_HOME:
return 'is away'

View File

@ -1,6 +1,4 @@
"""
homeassistant.components.logger
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Component that will help set the level of logging for components.
For more details about this component, please refer to the documentation at
@ -29,14 +27,13 @@ LOGGER_LOGS = 'logs'
class HomeAssistantLogFilter(logging.Filter):
"""A log filter."""
# pylint: disable=no-init,too-few-public-methods
def __init__(self, logfilter):
super().__init__()
self.logfilter = logfilter
def filter(self, record):
"""A filter to use."""
# Log with filtered severity
if LOGGER_LOGS in self.logfilter:
for filtername in self.logfilter[LOGGER_LOGS]:
@ -51,7 +48,6 @@ class HomeAssistantLogFilter(logging.Filter):
def setup(hass, config=None):
"""Setup the logger component."""
logfilter = dict()
# Set default log severity

View File

@ -157,7 +157,6 @@ def pf_callback_factory(map_sv_types, devices, add_devices, entity_class):
class GatewayWrapper(object):
"""Gateway wrapper class."""
def __init__(self, gateway, version, optimistic):
"""Setup class attributes on instantiation.

View File

@ -1,7 +1,5 @@
"""
homeassistant.components.thermostat.nest
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Adds support for Nest thermostats.
Support for Nest thermostats.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/thermostat.nest/
@ -18,7 +16,7 @@ NEST = None
# pylint: disable=unused-argument
def setup(hass, config):
""" Sets up the nest thermostat. """
"""Setup the Nest thermostat component."""
global NEST
logger = logging.getLogger(__name__)

View File

@ -1,6 +1,4 @@
"""
homeassistant.components.proximity
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Component to monitor the proximity of devices to a particular zone and the
direction of travel.
@ -38,7 +36,7 @@ def setup(hass, config): # pylint: disable=too-many-locals,too-many-statements
for variable in config[DOMAIN]['ignored_zones']:
ignored_zones.append(variable)
# Get the devices from configuration.yaml
# Get the devices from configuration.yaml.
if 'devices' not in config[DOMAIN]:
_LOGGER.error('devices not found in config')
return False
@ -47,10 +45,10 @@ def setup(hass, config): # pylint: disable=too-many-locals,too-many-statements
for variable in config[DOMAIN]['devices']:
proximity_devices.append(variable)
# Get the direction of travel tolerance from configuration.yaml
# Get the direction of travel tolerance from configuration.yaml.
tolerance = config[DOMAIN].get('tolerance', DEFAULT_TOLERANCE)
# Get the zone to monitor proximity to from configuration.yaml
# Get the zone to monitor proximity to from configuration.yaml.
proximity_zone = config[DOMAIN].get('zone', DEFAULT_PROXIMITY_ZONE)
entity_id = DOMAIN + '.' + proximity_zone
@ -59,7 +57,7 @@ def setup(hass, config): # pylint: disable=too-many-locals,too-many-statements
state = hass.states.get(proximity_zone)
zone_friendly_name = (state.name).lower()
# set the default values
# Set the default values.
dist_to_zone = 'not set'
dir_of_travel = 'not set'
nearest = 'not set'
@ -71,7 +69,7 @@ def setup(hass, config): # pylint: disable=too-many-locals,too-many-statements
proximity.update_ha_state()
# Main command to monitor proximity of devices
# Main command to monitor proximity of devices.
track_state_change(hass, proximity_devices,
proximity.check_proximity_state_change)
@ -101,17 +99,17 @@ class Proximity(Entity): # pylint: disable=too-many-instance-attributes
@property
def state(self):
""" Returns the state. """
"""Return the state."""
return self.dist_to
@property
def unit_of_measurement(self):
""" Unit of measurement of this entity. """
"""Return the unit of measurement of this entity."""
return "km"
@property
def state_attributes(self):
""" Returns the state attributes. """
"""Return the state attributes."""
return {
ATTR_DIR_OF_TRAVEL: self.dir_of_travel,
ATTR_NEAREST: self.nearest,
@ -128,21 +126,21 @@ class Proximity(Entity): # pylint: disable=too-many-instance-attributes
proximity_latitude = zone_state.attributes.get('latitude')
proximity_longitude = zone_state.attributes.get('longitude')
# Check for devices in the monitored zone
# Check for devices in the monitored zone.
for device in self.proximity_devices:
device_state = self.hass.states.get(device)
if device_state.state not in self.ignored_zones:
devices_to_calculate = True
# Check the location of all devices
# Check the location of all devices.
if (device_state.state).lower() == (self.friendly_name).lower():
device_friendly = device_state.name
if devices_in_zone != '':
devices_in_zone = devices_in_zone + ', '
devices_in_zone = devices_in_zone + device_friendly
# No-one to track so reset the entity
# No-one to track so reset the entity.
if not devices_to_calculate:
self.dist_to = 'not set'
self.dir_of_travel = 'not set'
@ -150,7 +148,7 @@ class Proximity(Entity): # pylint: disable=too-many-instance-attributes
self.update_ha_state()
return
# At least one device is in the monitored zone so update the entity
# At least one device is in the monitored zone so update the entity.
if devices_in_zone != '':
self.dist_to = 0
self.dir_of_travel = 'arrived'
@ -158,32 +156,33 @@ class Proximity(Entity): # pylint: disable=too-many-instance-attributes
self.update_ha_state()
return
# We can't check proximity because latitude and longitude don't exist
# We can't check proximity because latitude and longitude don't exist.
if 'latitude' not in new_state.attributes:
return
# Collect distances to the zone for all devices
# Collect distances to the zone for all devices.
distances_to_zone = {}
for device in self.proximity_devices:
# Ignore devices in an ignored zone
# Ignore devices in an ignored zone.
device_state = self.hass.states.get(device)
if device_state.state in self.ignored_zones:
continue
# Ignore devices if proximity cannot be calculated
# Ignore devices if proximity cannot be calculated.
if 'latitude' not in device_state.attributes:
continue
# Calculate the distance to the proximity zone
# Calculate the distance to the proximity zone.
dist_to_zone = distance(proximity_latitude,
proximity_longitude,
device_state.attributes['latitude'],
device_state.attributes['longitude'])
# Add the device and distance to a dictionary
# Add the device and distance to a dictionary.
distances_to_zone[device] = round(dist_to_zone / 1000, 1)
# Loop through each of the distances collected and work out the closest
# Loop through each of the distances collected and work out the
# closest.
closest_device = ''
dist_to_zone = 1000000
@ -192,7 +191,7 @@ class Proximity(Entity): # pylint: disable=too-many-instance-attributes
closest_device = device
dist_to_zone = distances_to_zone[device]
# If the closest device is one of the other devices
# If the closest device is one of the other devices.
if closest_device != entity:
self.dist_to = round(distances_to_zone[closest_device])
self.dir_of_travel = 'unknown'
@ -202,7 +201,7 @@ class Proximity(Entity): # pylint: disable=too-many-instance-attributes
return
# Stop if we cannot calculate the direction of travel (i.e. we don't
# have a previous state and a current LAT and LONG)
# have a previous state and a current LAT and LONG).
if old_state is None or 'latitude' not in old_state.attributes:
self.dist_to = round(distances_to_zone[entity])
self.dir_of_travel = 'unknown'
@ -213,7 +212,7 @@ class Proximity(Entity): # pylint: disable=too-many-instance-attributes
# Reset the variables
distance_travelled = 0
# Calculate the distance travelled
# Calculate the distance travelled.
old_distance = distance(proximity_latitude, proximity_longitude,
old_state.attributes['latitude'],
old_state.attributes['longitude'])

View File

@ -1,6 +1,4 @@
"""
homeassistant.components.recorder
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Component that records all events and state changes. Allows other components
to query this database.
@ -160,7 +158,7 @@ class RecorderRun(object):
class Recorder(threading.Thread):
""" Threaded recorder class """
"""A threaded recorder class."""
def __init__(self, hass):
threading.Thread.__init__(self)
@ -305,11 +303,11 @@ class Recorder(threading.Thread):
# without the STOP event being fired.
atexit.register(self._close_connection)
# Have datetime objects be saved as integers
# Have datetime objects be saved as integers.
sqlite3.register_adapter(date, _adapt_datetime)
sqlite3.register_adapter(datetime, _adapt_datetime)
# Validate we are on the correct schema or that we have to migrate
# Validate we are on the correct schema or that we have to migrate.
cur = self.conn.cursor()
def save_migration(migration_id):
@ -324,7 +322,7 @@ class Recorder(threading.Thread):
migration_id = cur.fetchone()[0] or 0
except sqlite3.OperationalError:
# The table does not exist
# The table does not exist.
cur.execute('CREATE TABLE schema_version ('
'migration_id integer primary key, performed integer)')
migration_id = 0
@ -399,7 +397,7 @@ class Recorder(threading.Thread):
save_migration(3)
if migration_id < 4:
# We had a bug where we did not save utc offset for recorder runs
# We had a bug where we did not save utc offset for recorder runs.
cur.execute(
"""UPDATE recorder_runs SET utc_offset=?
WHERE utc_offset IS NULL""", [self.utc_offset])
@ -412,15 +410,15 @@ class Recorder(threading.Thread):
save_migration(4)
if migration_id < 5:
# Add domain so that thermostat graphs look right
# Add domain so that thermostat graphs look right.
try:
cur.execute("""
ALTER TABLE states
ADD COLUMN domain text
""")
except sqlite3.OperationalError:
# We had a bug in this migration for a while on dev
# Without this, dev-users will have to throw away their db
# We had a bug in this migration for a while on dev.
# Without this, dev-users will have to throw away their db.
pass
# TravisCI has Python compiled against an old version of SQLite3
@ -429,13 +427,13 @@ class Recorder(threading.Thread):
"instr", 2,
lambda string, substring: string.find(substring) + 1)
# populate domain with defaults
# Populate domain with defaults.
cur.execute("""
UPDATE states
set domain=substr(entity_id, 0, instr(entity_id, '.'))
""")
# add indexes we are going to use a lot on selects
# Add indexes we are going to use a lot on selects.
cur.execute("""
CREATE INDEX states__state_changes ON
states (last_changed, last_updated, entity_id)""")

View File

@ -1,7 +1,5 @@
"""
homeassistant.components.rfxtrx
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Provides support for RFXtrx components.
Support for RFXtrx components.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/rfxtrx/
@ -34,7 +32,6 @@ RFXOBJECT = None
def setup(hass, config):
"""Setup the RFXtrx component."""
# Declare the Handle event
def handle_receive(event):
"""Callback all subscribers for RFXtrx gateway."""
@ -47,14 +44,14 @@ def setup(hass, config):
_LOGGER.info("Receive RFXCOM event from %s => %s",
event.device, entity_name)
# Callback to HA registered components
# Callback to HA registered components.
for subscriber in RECEIVED_EVT_SUBSCRIBERS:
subscriber(event)
# Try to load the RFXtrx module
# Try to load the RFXtrx module.
import RFXtrx as rfxtrxmod
# Init the rfxtrx module
# Init the rfxtrx module.
global RFXOBJECT
if ATTR_DEVICE not in config[DOMAIN]:

View File

@ -1,7 +1,5 @@
"""
homeassistant.components.rpi_gpio
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Allows to control the GPIO pins of a Raspberry Pi.
Support for controlling GPIO pins of a Raspberry Pi.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/rpi_gpio/
@ -19,11 +17,11 @@ _LOGGER = logging.getLogger(__name__)
# pylint: disable=no-member
def setup(hass, config):
""" Sets up the Raspberry PI GPIO component. """
"""Setup the Raspberry PI GPIO component."""
import RPi.GPIO as GPIO
def cleanup_gpio(event):
""" Stuff to do before stop home assistant. """
"""Stuff to do before stopping."""
GPIO.cleanup()
def prepare_gpio(event):

View File

@ -1,6 +1,4 @@
"""
homeassistant.components.script
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Scripts are a sequence of actions that can be triggered manually
by the user or automatically based upon automation events, etc.
@ -68,7 +66,6 @@ def toggle(hass, entity_id):
def setup(hass, config):
"""Load the scripts from the configuration."""
component = EntityComponent(_LOGGER, DOMAIN, hass)
def service_handler(service):
@ -136,16 +133,17 @@ class Script(ToggleEntity):
@property
def should_poll(self):
"""No polling needed."""
return False
@property
def name(self):
""" Returns the name of the entity. """
"""Return the name of the entity."""
return self._name
@property
def state_attributes(self):
""" Returns the state attributes. """
"""Return the state attributes."""
attrs = {}
if self._can_cancel:
attrs[ATTR_CAN_CANCEL] = self._can_cancel

View File

@ -1,7 +1,5 @@
"""
homeassistant.components.scsgate
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Provides support for SCSGate components.
Support for SCSGate components.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/scsgate/
@ -19,7 +17,6 @@ _LOGGER = logging.getLogger(__name__)
class SCSGate:
"""Class dealing with the SCSGate device via scsgate.Reactor."""
def __init__(self, device, logger):
self._logger = logger
self._devices = {}

View File

@ -1,6 +1,4 @@
"""
homeassistant.components.shell_command
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Exposes regular shell commands as services.
For more details about this platform, please refer to the documentation at

View File

@ -51,7 +51,6 @@ def setup(hass, config):
def statsd_event_listener(event):
"""Listen for new messages on the bus and sends them to StatsD."""
state = event.data.get('new_state')
if state is None:

View File

@ -1,6 +1,4 @@
"""
homeassistant.components.sun
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Provides functionality to keep track of the sun.
For more details about this component, please refer to the documentation at

View File

@ -1,7 +1,5 @@
"""
homeassistant.components.tellduslive
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tellduslive Component.
Support for Telldus Live.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/tellduslive/
@ -41,10 +39,10 @@ NETWORK = None
@Throttle(MIN_TIME_BETWEEN_SWITCH_UPDATES)
def request_switches():
""" make request to online service """
"""Make request to online service."""
_LOGGER.debug("Updating switches from Telldus Live")
switches = NETWORK.request("devices/list")["device"]
# filter out any group of switches
# Filter out any group of switches.
switches = {switch["id"]: switch for switch in switches
if switch["type"] == "device"}
return switches
@ -52,10 +50,10 @@ def request_switches():
@Throttle(MIN_TIME_BETWEEN_SENSOR_UPDATES)
def request_sensors():
""" make request to online service """
"""Make request to online service."""
_LOGGER.debug("Updating sensors from Telldus Live")
units = NETWORK.request("sensors/list")["sensor"]
# one unit can contain many sensors
# One unit can contain many sensors.
sensors = {unit["id"]+sensor["name"]: dict(unit, data=sensor)
for unit in units
for sensor in unit["data"]}
@ -64,7 +62,6 @@ def request_sensors():
class TelldusLiveData(object):
"""Gets the latest data and update the states."""
def __init__(self, hass, config):
public_key = config[DOMAIN].get(CONF_PUBLIC_KEY)
private_key = config[DOMAIN].get(CONF_PRIVATE_KEY)
@ -85,18 +82,17 @@ class TelldusLiveData(object):
access_secret=token_secret)
def validate_session(self):
""" Make a dummy request to see if the session is valid """
"""Make a dummy request to see if the session is valid."""
response = self.request("user/profile")
return response and 'email' in response
def discover(self):
""" Update states, will trigger discover """
"""Update states, will trigger discover."""
self.update_sensors()
self.update_switches()
def _discover(self, found_devices, component_name):
""" Send discovery event if component not yet discovered """
"""Send discovery event if component not yet discovered."""
if not len(found_devices):
return
@ -115,7 +111,7 @@ class TelldusLiveData(object):
ATTR_DISCOVERED: found_devices})
def request(self, what, **params):
""" Sends a request to the tellstick live API """
"""Sends a request to the Tellstick Live API."""
from tellive.live import const
supported_methods = const.TELLSTICK_TURNON \
@ -149,12 +145,8 @@ class TelldusLiveData(object):
_LOGGER.error("failed to make request to Tellduslive servers")
return None
def update_devices(self,
local_devices,
remote_devices,
component_name):
""" update local device list and discover new devices """
def update_devices(self, local_devices, remote_devices, component_name):
"""Update local device list and discover new devices."""
if remote_devices is None:
return local_devices
@ -172,28 +164,28 @@ class TelldusLiveData(object):
return remote_devices
def update_sensors(self):
""" update local list of sensors """
"""Update local list of sensors."""
self._sensors = self.update_devices(self._sensors,
request_sensors(),
"sensor")
def update_switches(self):
""" update local list of switches """
"""Update local list of switches."""
self._switches = self.update_devices(self._switches,
request_switches(),
"switch")
def _check_request(self, what, **params):
""" Make request, check result if successful """
"""Make request, check result if successful."""
response = self.request(what, **params)
return response and response.get('status') == 'success'
def get_switch(self, switch_id):
""" return switch representation """
"""Return the switch representation."""
return self._switches[switch_id]
def get_sensor(self, sensor_id):
""" return sensor representation """
"""Return the sensor representation."""
return self._sensors[sensor_id]
def turn_switch_on(self, switch_id):
@ -211,9 +203,7 @@ class TelldusLiveData(object):
def setup(hass, config):
"""Setup the Telldus Live component."""
# fixme: aquire app key and provide authentication
# using username + password
# FIXME: aquire app key and provide authentication using username+password
if not validate_config(config,
{DOMAIN: [CONF_PUBLIC_KEY,
CONF_PRIVATE_KEY,

View File

@ -1,7 +1,5 @@
"""
homeassistant.components.updater
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Component that checks for available updates.
Support to check for available updates.
For more details about this platform, please refer to the documentation at
at https://home-assistant.io/components/updater/
@ -22,7 +20,6 @@ ENTITY_ID = 'updater.updater'
def setup(hass, config):
"""Setup the updater component."""
def check_newest_version(_=None):
"""Check if a new version is available and report if one is."""
newest = get_newest_version()

View File

@ -1,7 +1,5 @@
"""
components.verisure
~~~~~~~~~~~~~~~~~~~
Provides support for verisure components.
Support for Verisure components.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/verisure/
@ -34,7 +32,6 @@ HUB = None
def setup(hass, config):
"""Setup the Verisure component."""
if not validate_config(config,
{DOMAIN: [CONF_USERNAME, CONF_PASSWORD]},
_LOGGER):
@ -46,7 +43,6 @@ def setup(hass, config):
if not HUB.login():
return False
# Load components for the devices in the ISY controller that we support
for comp_name, discovery in ((('sensor', DISCOVER_SENSORS),
('switch', DISCOVER_SWITCHES),
('alarm_control_panel', DISCOVER_ALARMS),
@ -62,8 +58,7 @@ def setup(hass, config):
# pylint: disable=too-many-instance-attributes
class VerisureHub(object):
""" Verisure wrapper class """
"""A Verisure wrapper class."""
def __init__(self, domain_config, verisure):
self.alarm_status = {}
self.lock_status = {}
@ -88,7 +83,7 @@ class VerisureHub(object):
domain_config[CONF_PASSWORD])
def login(self):
""" Login to MyPages """
"""Login to Verisure MyPages."""
try:
self.my_pages.login()
except self._verisure.Error as ex:
@ -105,21 +100,21 @@ class VerisureHub(object):
@Throttle(timedelta(seconds=1))
def update_locks(self):
""" Updates the status of the alarm. """
"""Updates the status of the locks."""
self.update_component(
self.my_pages.lock.get,
self.lock_status)
@Throttle(timedelta(seconds=60))
def update_climate(self):
""" Updates the status of the smartplugs. """
"""Updates the status of the climate units."""
self.update_component(
self.my_pages.climate.get,
self.climate_status)
@Throttle(timedelta(seconds=60))
def update_mousedetection(self):
""" Updates the status of the smartplugs. """
"""Updates the status of the mouse detectors."""
self.update_component(
self.my_pages.mousedetection.get,
self.mouse_status)
@ -132,7 +127,7 @@ class VerisureHub(object):
self.smartplug_status)
def update_component(self, get_function, status):
""" Updates the status of verisure components. """
"""Updates the status of Verisure components."""
if self._wrong_password_given:
_LOGGER.error('Wrong password for Verisure, update config')
return
@ -147,7 +142,7 @@ class VerisureHub(object):
self.reconnect()
def reconnect(self):
""" Reconnect to verisure mypages. """
"""Reconnect to Verisure MyPages."""
if self._reconnect_timeout > time.time():
return
if not self._lock.acquire(blocking=False):

View File

@ -1,8 +1,5 @@
# -*- coding: utf-8 -*-
"""
homeassistant.components.weblink
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Adds links to external webpages.
Support for links to external web pages.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/weblink/
@ -24,7 +21,6 @@ _LOGGER = logging.getLogger(__name__)
def setup(hass, config):
"""Setup weblink component."""
links = config.get(DOMAIN)
for link in links.get('entities'):
@ -40,7 +36,6 @@ def setup(hass, config):
class Link(Entity):
"""Represent a link."""
def __init__(self, hass, name, url, icon):
self.hass = hass
self._name = name
@ -51,15 +46,15 @@ class Link(Entity):
@property
def icon(self):
""" Icon to use in the frontend, if any. """
"""Return the icon to use in the frontend, if any."""
return self._icon
@property
def name(self):
""" Returns the name of the URL. """
"""Return the name of the URL."""
return self._name
@property
def state(self):
""" Returns the URL. """
"""Return the URL."""
return self._url

View File

@ -1,7 +1,5 @@
"""
homeassistant.components.wemo
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WeMo device discovery.
Support for WeMo device discovery.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/wemo/
@ -18,7 +16,7 @@ DISCOVER_LIGHTS = 'wemo.light'
DISCOVER_MOTION = 'wemo.motion'
DISCOVER_SWITCHES = 'wemo.switch'
# mapping from Wemo model_name to service
# Mapping from Wemo model_name to service.
WEMO_MODEL_DISPATCH = {
'Bridge': DISCOVER_LIGHTS,
'Insight': DISCOVER_SWITCHES,
@ -77,7 +75,7 @@ def setup(hass, config):
_LOGGER.info("Scanning for WeMo devices.")
devices = [(device.host, device) for device in pywemo.discover_devices()]
# Add static devices from the config file
# Add static devices from the config file.
devices.extend((address, None)
for address in config.get(DOMAIN, {}).get('static', []))

View File

@ -1,7 +1,6 @@
"""
homeassistant.components.wink
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Connects to a Wink hub and loads relevant components to control its devices.
Support for Wink hubs.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/wink/
"""
@ -27,7 +26,7 @@ DISCOVER_GARAGE_DOORS = "wink.garage_doors"
def setup(hass, config):
""" Sets up the Wink component. """
"""Setup the Wink component."""
logger = logging.getLogger(__name__)
if not validate_config(config, {DOMAIN: [CONF_ACCESS_TOKEN]}, logger):
@ -64,34 +63,33 @@ def setup(hass, config):
class WinkToggleDevice(ToggleEntity):
""" Represents a Wink toogle (switch) device. """
"""Represents a Wink toggle (switch) device."""
def __init__(self, wink):
self.wink = wink
@property
def unique_id(self):
""" Returns the id of this Wink switch. """
"""Return the ID of this Wink device."""
return "{}.{}".format(self.__class__, self.wink.device_id())
@property
def name(self):
""" Returns the name of the light if any. """
"""Return the name of the device."""
return self.wink.name()
@property
def is_on(self):
""" True if light is on. """
"""True if decive is on."""
return self.wink.state()
def turn_on(self, **kwargs):
""" Turns the switch on. """
"""Turns the device on."""
self.wink.set_state(True)
def turn_off(self):
""" Turns the switch off. """
"""Turns the device off."""
self.wink.set_state(False)
def update(self):
""" Update state of the light. """
"""Update state of the device."""
self.wink.update_state()

View File

@ -1,8 +1,5 @@
"""
homeassistant.components.zigbee
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sets up and provides access to a ZigBee device and contains generic entity
classes.
Support for ZigBee devices.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/zigbee/

View File

@ -1,7 +1,5 @@
"""
homeassistant.components.zone
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Allows defintion of zones in Home Assistant.
Support for the definition of zones.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/zone/
@ -108,7 +106,7 @@ def setup(hass, config):
class Zone(Entity):
""" Represents a Zone in Home Assistant. """
"""Represents a Zone."""
# pylint: disable=too-many-arguments, too-many-instance-attributes
def __init__(self, hass, name, latitude, longitude, radius, icon, passive):
self.hass = hass
@ -121,19 +119,22 @@ class Zone(Entity):
@property
def name(self):
""" Return the name of the zone."""
return self._name
@property
def state(self):
""" The state property really does nothing for a zone. """
"""Return the state property really does nothing for a zone."""
return STATE
@property
def icon(self):
"""Return the icon if any."""
return self._icon
@property
def state_attributes(self):
""" Return the state attributes of the zone."""
data = {
ATTR_HIDDEN: True,
ATTR_LATITUDE: self._latitude,

View File

@ -1,7 +1,5 @@
"""
homeassistant.components.zwave
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Connects Home Assistant to a Z-Wave network.
Support for Z-Wave.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/zwave/
@ -56,8 +54,8 @@ TYPE_BOOL = "Bool"
TYPE_DECIMAL = "Decimal"
# list of tuple (DOMAIN, discovered service, supported command
# classes, value type)
# List of tuple (DOMAIN, discovered service, supported command classes,
# value type).
DISCOVERY_COMPONENTS = [
('sensor',
DISCOVER_SENSORS,
@ -113,8 +111,8 @@ def _value_name(value):
def _object_id(value):
"""Returns the object_id of the device value.
The object_id contains node_id and value instance id
to not collide with other entity_ids"""
to not collide with other entity_ids.
"""
object_id = "{}_{}".format(slugify(_value_name(value)),
value.node.node_id)
@ -138,8 +136,7 @@ def nice_print_node(node):
def get_config_value(node, value_index):
""" Returns the current config value for a specific index. """
"""Returns the current configuration value for a specific index."""
try:
for value in node.values.values():
# 112 == config command class
@ -194,7 +191,6 @@ def setup(hass, config):
def value_added(node, value):
"""Called when a value is added to a node on the network."""
for (component,
discovery_service,
command_ids,
@ -245,11 +241,11 @@ def setup(hass, config):
scene_activated, ZWaveNetwork.SIGNAL_SCENE_EVENT, weak=False)
def add_node(event):
""" Switch into inclusion mode """
"""Switch into inclusion mode."""
NETWORK.controller.begin_command_add_device()
def remove_node(event):
""" Switch into exclusion mode"""
"""Switch into exclusion mode."""
NETWORK.controller.begin_command_remove_device()
def stop_zwave(event):
@ -257,7 +253,7 @@ def setup(hass, config):
NETWORK.stop()
def start_zwave(event):
""" Called when Home Assistant starts up. """
"""Startup """
NETWORK.start()
polling_interval = convert(
@ -267,7 +263,7 @@ def setup(hass, config):
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop_zwave)
# register add / remove node services for zwave sticks without
# Register add / remove node services for Z-Wave sticks without
# hardware inclusion button
hass.services.register(DOMAIN, SERVICE_ADD_NODE, add_node)
hass.services.register(DOMAIN, SERVICE_REMOVE_NODE, remove_node)
@ -278,14 +274,14 @@ def setup(hass, config):
class ZWaveDeviceEntity:
""" Represents a ZWave node entity within Home Assistant. """
"""Represents a Z-Wave node entity."""
def __init__(self, value, domain):
self._value = value
self.entity_id = "{}.{}".format(domain, self._object_id())
@property
def should_poll(self):
""" False because we will push our own state to HA when changed. """
"""No polling needed."""
return False
@property
@ -300,15 +296,15 @@ class ZWaveDeviceEntity:
return _value_name(self._value)
def _object_id(self):
""" Returns the object_id of the device value.
The object_id contains node_id and value instance id
to not collide with other entity_ids"""
"""
Returns the object_id of the device value. The object_id contains
node_id and value instance id to not collide with other entity_ids.
"""
return _object_id(self._value)
@property
def device_state_attributes(self):
""" Returns device specific state attributes. """
"""Return device specific state attributes."""
attrs = {
ATTR_NODE_ID: self._value.node.node_id,
}