mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Update docstrings
This commit is contained in:
parent
bc106bcb10
commit
3e60c4801c
@ -28,7 +28,7 @@ REQUIREMENTS = ['pyfttt==0.3']
|
|||||||
|
|
||||||
|
|
||||||
def trigger(hass, event, value1=None, value2=None, value3=None):
|
def trigger(hass, event, value1=None, value2=None, value3=None):
|
||||||
""" Trigger a Maker IFTTT recipe """
|
""" Trigger a Maker IFTTT recipe. """
|
||||||
data = {
|
data = {
|
||||||
ATTR_EVENT: event,
|
ATTR_EVENT: event,
|
||||||
ATTR_VALUE1: value1,
|
ATTR_VALUE1: value1,
|
||||||
@ -39,7 +39,7 @@ def trigger(hass, event, value1=None, value2=None, value3=None):
|
|||||||
|
|
||||||
|
|
||||||
def setup(hass, config):
|
def setup(hass, config):
|
||||||
""" Setup the ifttt service component """
|
""" Setup the ifttt service component. """
|
||||||
|
|
||||||
if not validate_config(config, {DOMAIN: ['key']}, _LOGGER):
|
if not validate_config(config, {DOMAIN: ['key']}, _LOGGER):
|
||||||
return False
|
return False
|
||||||
|
@ -132,7 +132,7 @@ def setup(hass, config):
|
|||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class _JsonFmtParser(object):
|
class _JsonFmtParser(object):
|
||||||
""" Implements a json parser on xpath"""
|
""" Implements a json parser on xpath. """
|
||||||
def __init__(self, jsonpath):
|
def __init__(self, jsonpath):
|
||||||
import jsonpath_rw
|
import jsonpath_rw
|
||||||
self._expr = jsonpath_rw.parse(jsonpath)
|
self._expr = jsonpath_rw.parse(jsonpath)
|
||||||
@ -144,7 +144,7 @@ class _JsonFmtParser(object):
|
|||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class FmtParser(object):
|
class FmtParser(object):
|
||||||
""" wrapper for all supported formats """
|
""" Wrapper for all supported formats. """
|
||||||
def __init__(self, fmt):
|
def __init__(self, fmt):
|
||||||
self._parse = lambda x: x
|
self._parse = lambda x: x
|
||||||
if fmt:
|
if fmt:
|
||||||
@ -252,7 +252,7 @@ def _mqtt_on_connect(mqttc, userdata, flags, result_code):
|
|||||||
|
|
||||||
|
|
||||||
def _mqtt_on_subscribe(mqttc, userdata, mid, granted_qos):
|
def _mqtt_on_subscribe(mqttc, userdata, mid, granted_qos):
|
||||||
""" Called when subscribe successfull. """
|
""" Called when subscribe successful. """
|
||||||
topic = userdata['progress'].pop(mid, None)
|
topic = userdata['progress'].pop(mid, None)
|
||||||
if topic is None:
|
if topic is None:
|
||||||
return
|
return
|
||||||
@ -260,7 +260,7 @@ def _mqtt_on_subscribe(mqttc, userdata, mid, granted_qos):
|
|||||||
|
|
||||||
|
|
||||||
def _mqtt_on_unsubscribe(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)
|
topic = userdata['progress'].pop(mid, None)
|
||||||
if topic is None:
|
if topic is None:
|
||||||
return
|
return
|
||||||
|
@ -47,16 +47,16 @@ class PushBulletNotificationService(BaseNotificationService):
|
|||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
def refresh(self):
|
def refresh(self):
|
||||||
'''
|
"""
|
||||||
Refresh devices, contacts, etc
|
Refresh devices, contacts, etc
|
||||||
|
|
||||||
pbtargets stores all targets available from this pushbullet instance
|
pbtargets stores all targets available from this pushbullet instance
|
||||||
into a dict. These are PB objects!. It sacrifices a bit of memory
|
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
|
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.pushbullet.refresh()
|
||||||
self.pbtargets = {
|
self.pbtargets = {
|
||||||
'device': {
|
'device': {
|
||||||
@ -72,7 +72,7 @@ class PushBulletNotificationService(BaseNotificationService):
|
|||||||
If no target specified, a 'normal' push will be sent to all devices
|
If no target specified, a 'normal' push will be sent to all devices
|
||||||
linked to the PB account.
|
linked to the PB account.
|
||||||
Email is special, these are assumed to always exist. We use a special
|
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)
|
targets = kwargs.get(ATTR_TARGET)
|
||||||
title = kwargs.get(ATTR_TITLE)
|
title = kwargs.get(ATTR_TITLE)
|
||||||
|
@ -59,7 +59,7 @@ def query_events(event_query, arguments=None):
|
|||||||
|
|
||||||
|
|
||||||
def row_to_state(row):
|
def row_to_state(row):
|
||||||
""" Convert a databsae row to a state. """
|
""" Convert a database row to a state. """
|
||||||
try:
|
try:
|
||||||
return State(
|
return State(
|
||||||
row[1], row[2], json.loads(row[3]),
|
row[1], row[2], json.loads(row[3]),
|
||||||
@ -83,8 +83,9 @@ def row_to_event(row):
|
|||||||
|
|
||||||
|
|
||||||
def run_information(point_in_time=None):
|
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()
|
_verify_instance()
|
||||||
|
|
||||||
if point_in_time is None or point_in_time > _INSTANCE.recording_start:
|
if point_in_time is None or point_in_time > _INSTANCE.recording_start:
|
||||||
@ -142,8 +143,10 @@ class RecorderRun(object):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def where_after_start_run(self):
|
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))
|
return "created >= {} ".format(_adapt_datetime(self.start))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -158,9 +161,7 @@ class RecorderRun(object):
|
|||||||
|
|
||||||
|
|
||||||
class Recorder(threading.Thread):
|
class Recorder(threading.Thread):
|
||||||
"""
|
""" Threaded recorder class """
|
||||||
Threaded recorder
|
|
||||||
"""
|
|
||||||
def __init__(self, hass):
|
def __init__(self, hass):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
|
|
||||||
@ -208,8 +209,10 @@ class Recorder(threading.Thread):
|
|||||||
self.queue.task_done()
|
self.queue.task_done()
|
||||||
|
|
||||||
def event_listener(self, event):
|
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)
|
self.queue.put(event)
|
||||||
|
|
||||||
def shutdown(self, event):
|
def shutdown(self, event):
|
||||||
@ -433,6 +436,6 @@ def _adapt_datetime(datetimestamp):
|
|||||||
|
|
||||||
|
|
||||||
def _verify_instance():
|
def _verify_instance():
|
||||||
""" throws error if recorder not initialized. """
|
""" Throws error if recorder not initialized. """
|
||||||
if _INSTANCE is None:
|
if _INSTANCE is None:
|
||||||
raise RuntimeError("Recorder not initialized.")
|
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
|
# pylint: disable=too-many-arguments, too-many-instance-attributes
|
||||||
class MqttSwitch(SwitchDevice):
|
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,
|
def __init__(self, hass, name, state_topic, command_topic, qos,
|
||||||
payload_on, payload_off, optimistic, state_format):
|
payload_on, payload_off, optimistic, state_format):
|
||||||
self._state = False
|
self._state = False
|
||||||
|
@ -74,6 +74,7 @@ class RoundThermostat(ThermostatDevice):
|
|||||||
self.device.set_temperature(self._name, temperature)
|
self.device.set_temperature(self._name, temperature)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
|
""" Update the data from the thermostat. """
|
||||||
try:
|
try:
|
||||||
# Only take first thermostat data from API for now
|
# Only take first thermostat data from API for now
|
||||||
data = next(self.device.temperatures(force_refresh=True))
|
data = next(self.device.temperatures(force_refresh=True))
|
||||||
|
@ -101,6 +101,7 @@ class RadioThermostat(ThermostatDevice):
|
|||||||
return round(self._target_temperature, 1)
|
return round(self._target_temperature, 1)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
|
""" Update the data from the thermostat. """
|
||||||
self._current_temperature = self.device.temp['raw']
|
self._current_temperature = self.device.temp['raw']
|
||||||
self._name = self.device.name['raw']
|
self._name = self.device.name['raw']
|
||||||
if self.device.tmode['human'] == 'Cool':
|
if self.device.tmode['human'] == 'Cool':
|
||||||
|
@ -83,7 +83,7 @@ def _obj_to_dict(obj):
|
|||||||
|
|
||||||
|
|
||||||
def nice_print_node(node):
|
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 = _obj_to_dict(node)
|
||||||
node_dict['values'] = {value_id: _obj_to_dict(value)
|
node_dict['values'] = {value_id: _obj_to_dict(value)
|
||||||
for value_id, value in node.values.items()}
|
for value_id, value in node.values.items()}
|
||||||
@ -95,7 +95,7 @@ def nice_print_node(node):
|
|||||||
|
|
||||||
|
|
||||||
def get_config_value(node, value_index):
|
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:
|
try:
|
||||||
for value in node.values.values():
|
for value in node.values.values():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user