Update docstrings
This commit is contained in:
parent
bc106bcb10
commit
3e60c4801c
8 changed files with 30 additions and 25 deletions
|
@ -28,7 +28,7 @@ REQUIREMENTS = ['pyfttt==0.3']
|
|||
|
||||
|
||||
def trigger(hass, event, value1=None, value2=None, value3=None):
|
||||
""" Trigger a Maker IFTTT recipe """
|
||||
""" Trigger a Maker IFTTT recipe. """
|
||||
data = {
|
||||
ATTR_EVENT: event,
|
||||
ATTR_VALUE1: value1,
|
||||
|
@ -39,7 +39,7 @@ 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
|
||||
|
|
|
@ -132,7 +132,7 @@ def setup(hass, config):
|
|||
|
||||
# pylint: disable=too-few-public-methods
|
||||
class _JsonFmtParser(object):
|
||||
""" Implements a json parser on xpath"""
|
||||
""" Implements a json parser on xpath. """
|
||||
def __init__(self, jsonpath):
|
||||
import jsonpath_rw
|
||||
self._expr = jsonpath_rw.parse(jsonpath)
|
||||
|
@ -144,7 +144,7 @@ class _JsonFmtParser(object):
|
|||
|
||||
# pylint: disable=too-few-public-methods
|
||||
class FmtParser(object):
|
||||
""" wrapper for all supported formats """
|
||||
""" Wrapper for all supported formats. """
|
||||
def __init__(self, fmt):
|
||||
self._parse = lambda x: x
|
||||
if fmt:
|
||||
|
@ -252,7 +252,7 @@ def _mqtt_on_connect(mqttc, userdata, flags, result_code):
|
|||
|
||||
|
||||
def _mqtt_on_subscribe(mqttc, userdata, mid, granted_qos):
|
||||
""" Called when subscribe successfull. """
|
||||
""" Called when subscribe successful. """
|
||||
topic = userdata['progress'].pop(mid, None)
|
||||
if topic is None:
|
||||
return
|
||||
|
@ -260,7 +260,7 @@ def _mqtt_on_subscribe(mqttc, userdata, mid, granted_qos):
|
|||
|
||||
|
||||
def _mqtt_on_unsubscribe(mqttc, userdata, mid, granted_qos):
|
||||
""" Called when subscribe successfull. """
|
||||
""" Called when subscribe successful. """
|
||||
topic = userdata['progress'].pop(mid, None)
|
||||
if topic is None:
|
||||
return
|
||||
|
|
|
@ -47,16 +47,16 @@ class PushBulletNotificationService(BaseNotificationService):
|
|||
self.refresh()
|
||||
|
||||
def refresh(self):
|
||||
'''
|
||||
"""
|
||||
Refresh devices, contacts, etc
|
||||
|
||||
pbtargets stores all targets available from this pushbullet instance
|
||||
into a dict. These are PB objects!. It sacrifices a bit of memory
|
||||
for faster processing at send_message
|
||||
for faster processing at send_message.
|
||||
|
||||
As of sept 2015, contacts were replaced by chats. This is not
|
||||
implemented in the module yet
|
||||
'''
|
||||
implemented in the module yet.
|
||||
"""
|
||||
self.pushbullet.refresh()
|
||||
self.pbtargets = {
|
||||
'device': {
|
||||
|
@ -72,7 +72,7 @@ class PushBulletNotificationService(BaseNotificationService):
|
|||
If no target specified, a 'normal' push will be sent to all devices
|
||||
linked to the PB account.
|
||||
Email is special, these are assumed to always exist. We use a special
|
||||
call which doesn't require a push object
|
||||
call which doesn't require a push object.
|
||||
"""
|
||||
targets = kwargs.get(ATTR_TARGET)
|
||||
title = kwargs.get(ATTR_TITLE)
|
||||
|
|
|
@ -59,7 +59,7 @@ def query_events(event_query, arguments=None):
|
|||
|
||||
|
||||
def row_to_state(row):
|
||||
""" Convert a databsae row to a state. """
|
||||
""" Convert a database row to a state. """
|
||||
try:
|
||||
return State(
|
||||
row[1], row[2], json.loads(row[3]),
|
||||
|
@ -83,8 +83,9 @@ def row_to_event(row):
|
|||
|
||||
|
||||
def run_information(point_in_time=None):
|
||||
""" Returns information about current run or the run that
|
||||
covers point_in_time. """
|
||||
"""
|
||||
Returns information about current run or the run that covers point_in_time.
|
||||
"""
|
||||
_verify_instance()
|
||||
|
||||
if point_in_time is None or point_in_time > _INSTANCE.recording_start:
|
||||
|
@ -142,8 +143,10 @@ class RecorderRun(object):
|
|||
|
||||
@property
|
||||
def where_after_start_run(self):
|
||||
""" Returns SQL WHERE clause to select rows
|
||||
created after the start of the run. """
|
||||
"""
|
||||
Returns SQL WHERE clause to select rows created after the start of the
|
||||
run.
|
||||
"""
|
||||
return "created >= {} ".format(_adapt_datetime(self.start))
|
||||
|
||||
@property
|
||||
|
@ -158,9 +161,7 @@ class RecorderRun(object):
|
|||
|
||||
|
||||
class Recorder(threading.Thread):
|
||||
"""
|
||||
Threaded recorder
|
||||
"""
|
||||
""" Threaded recorder class """
|
||||
def __init__(self, hass):
|
||||
threading.Thread.__init__(self)
|
||||
|
||||
|
@ -208,8 +209,10 @@ class Recorder(threading.Thread):
|
|||
self.queue.task_done()
|
||||
|
||||
def event_listener(self, event):
|
||||
""" Listens for new events on the EventBus and puts them
|
||||
in the process queue. """
|
||||
"""
|
||||
Listens for new events on the EventBus and puts them in the process
|
||||
queue.
|
||||
"""
|
||||
self.queue.put(event)
|
||||
|
||||
def shutdown(self, event):
|
||||
|
@ -433,6 +436,6 @@ def _adapt_datetime(datetimestamp):
|
|||
|
||||
|
||||
def _verify_instance():
|
||||
""" throws error if recorder not initialized. """
|
||||
""" Throws error if recorder not initialized. """
|
||||
if _INSTANCE is None:
|
||||
raise RuntimeError("Recorder not initialized.")
|
||||
|
|
|
@ -43,7 +43,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
|||
|
||||
# pylint: disable=too-many-arguments, too-many-instance-attributes
|
||||
class MqttSwitch(SwitchDevice):
|
||||
""" Represents a switch that can be togggled using MQTT. """
|
||||
""" Represents a switch that can be toggled using MQTT. """
|
||||
def __init__(self, hass, name, state_topic, command_topic, qos,
|
||||
payload_on, payload_off, optimistic, state_format):
|
||||
self._state = False
|
||||
|
|
|
@ -74,6 +74,7 @@ class RoundThermostat(ThermostatDevice):
|
|||
self.device.set_temperature(self._name, temperature)
|
||||
|
||||
def update(self):
|
||||
""" Update the data from the thermostat. """
|
||||
try:
|
||||
# Only take first thermostat data from API for now
|
||||
data = next(self.device.temperatures(force_refresh=True))
|
||||
|
|
|
@ -101,6 +101,7 @@ class RadioThermostat(ThermostatDevice):
|
|||
return round(self._target_temperature, 1)
|
||||
|
||||
def update(self):
|
||||
""" Update the data from the thermostat. """
|
||||
self._current_temperature = self.device.temp['raw']
|
||||
self._name = self.device.name['raw']
|
||||
if self.device.tmode['human'] == 'Cool':
|
||||
|
|
|
@ -83,7 +83,7 @@ def _obj_to_dict(obj):
|
|||
|
||||
|
||||
def nice_print_node(node):
|
||||
""" Prints a nice formatted node to the output (debug method) """
|
||||
""" Prints a nice formatted node to the output (debug method). """
|
||||
node_dict = _obj_to_dict(node)
|
||||
node_dict['values'] = {value_id: _obj_to_dict(value)
|
||||
for value_id, value in node.values.items()}
|
||||
|
@ -95,7 +95,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 config value for a specific index. """
|
||||
|
||||
try:
|
||||
for value in node.values.values():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue