mirror of
https://github.com/home-assistant/core.git
synced 2025-11-16 14:30:22 +00:00
Update docstrings (#7361)
* Update docstrings * Update docstrings * Update docstrings * Update docstrings * update docstrings * Update docstrings * Update docstrings * Update docstrings * Update docstrings * Update docstrings * Update tomato.py * Update isy994.py * Lint + fix tests * Lint
This commit is contained in:
committed by
Paulus Schoutsen
parent
e22e70a01a
commit
3ee4d1060f
@@ -13,41 +13,45 @@ import voluptuous as vol
|
||||
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components.mqtt import (valid_publish_topic,
|
||||
valid_subscribe_topic)
|
||||
from homeassistant.const import (ATTR_BATTERY_LEVEL, CONF_NAME,
|
||||
CONF_OPTIMISTIC, EVENT_HOMEASSISTANT_START,
|
||||
EVENT_HOMEASSISTANT_STOP, STATE_OFF, STATE_ON)
|
||||
from homeassistant.components.mqtt import (
|
||||
valid_publish_topic, valid_subscribe_topic)
|
||||
from homeassistant.const import (
|
||||
ATTR_BATTERY_LEVEL, CONF_NAME, CONF_OPTIMISTIC, EVENT_HOMEASSISTANT_START,
|
||||
EVENT_HOMEASSISTANT_STOP, STATE_OFF, STATE_ON)
|
||||
from homeassistant.helpers import discovery
|
||||
from homeassistant.loader import get_component
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
ATTR_NODE_ID = 'node_id'
|
||||
ATTR_CHILD_ID = 'child_id'
|
||||
ATTR_DESCRIPTION = 'description'
|
||||
ATTR_DEVICE = 'device'
|
||||
CONF_BAUD_RATE = 'baud_rate'
|
||||
CONF_DEVICE = 'device'
|
||||
CONF_DEBUG = 'debug'
|
||||
CONF_GATEWAYS = 'gateways'
|
||||
CONF_PERSISTENCE = 'persistence'
|
||||
CONF_PERSISTENCE_FILE = 'persistence_file'
|
||||
CONF_TCP_PORT = 'tcp_port'
|
||||
CONF_TOPIC_IN_PREFIX = 'topic_in_prefix'
|
||||
CONF_TOPIC_OUT_PREFIX = 'topic_out_prefix'
|
||||
CONF_RETAIN = 'retain'
|
||||
CONF_VERSION = 'version'
|
||||
DEFAULT_VERSION = 1.4
|
||||
DEFAULT_BAUD_RATE = 115200
|
||||
DEFAULT_TCP_PORT = 5003
|
||||
DOMAIN = 'mysensors'
|
||||
MYSENSORS_GATEWAYS = 'mysensors_gateways'
|
||||
MQTT_COMPONENT = 'mqtt'
|
||||
REQUIREMENTS = [
|
||||
'https://github.com/theolind/pymysensors/archive/'
|
||||
'c6990eaaa741444a638608e6e00488195e2ca74c.zip#pymysensors==0.9.1']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
ATTR_CHILD_ID = 'child_id'
|
||||
ATTR_DESCRIPTION = 'description'
|
||||
ATTR_DEVICE = 'device'
|
||||
ATTR_NODE_ID = 'node_id'
|
||||
|
||||
CONF_BAUD_RATE = 'baud_rate'
|
||||
CONF_DEBUG = 'debug'
|
||||
CONF_DEVICE = 'device'
|
||||
CONF_GATEWAYS = 'gateways'
|
||||
CONF_PERSISTENCE = 'persistence'
|
||||
CONF_PERSISTENCE_FILE = 'persistence_file'
|
||||
CONF_RETAIN = 'retain'
|
||||
CONF_TCP_PORT = 'tcp_port'
|
||||
CONF_TOPIC_IN_PREFIX = 'topic_in_prefix'
|
||||
CONF_TOPIC_OUT_PREFIX = 'topic_out_prefix'
|
||||
CONF_VERSION = 'version'
|
||||
|
||||
DEFAULT_BAUD_RATE = 115200
|
||||
DEFAULT_TCP_PORT = 5003
|
||||
DEFAULT_VERSION = 1.4
|
||||
DOMAIN = 'mysensors'
|
||||
|
||||
MQTT_COMPONENT = 'mqtt'
|
||||
MYSENSORS_GATEWAYS = 'mysensors_gateways'
|
||||
|
||||
|
||||
def is_socket_address(value):
|
||||
"""Validate that value is a valid address."""
|
||||
@@ -148,7 +152,7 @@ CONFIG_SCHEMA = vol.Schema({
|
||||
|
||||
|
||||
def setup(hass, config):
|
||||
"""Setup the MySensors component."""
|
||||
"""Set up the MySensors component."""
|
||||
import mysensors.mysensors as mysensors
|
||||
|
||||
version = config[DOMAIN].get(CONF_VERSION)
|
||||
@@ -201,7 +205,7 @@ def setup(hass, config):
|
||||
gateway.event_callback = gateway.callback_factory()
|
||||
|
||||
def gw_start(event):
|
||||
"""Callback to trigger start of gateway and any persistence."""
|
||||
"""Trigger to start of the gateway and any persistence."""
|
||||
if persistence:
|
||||
for node_id in gateway.sensors:
|
||||
node = gateway.sensors[node_id]
|
||||
@@ -220,7 +224,7 @@ def setup(hass, config):
|
||||
gateways = hass.data.get(MYSENSORS_GATEWAYS)
|
||||
if gateways is not None:
|
||||
_LOGGER.error(
|
||||
'%s already exists in %s, will not setup %s component',
|
||||
"%s already exists in %s, will not setup %s component",
|
||||
MYSENSORS_GATEWAYS, hass.data, DOMAIN)
|
||||
return False
|
||||
|
||||
@@ -245,7 +249,7 @@ def setup(hass, config):
|
||||
|
||||
if not gateways:
|
||||
_LOGGER.error(
|
||||
'No devices could be setup as gateways, check your configuration')
|
||||
"No devices could be setup as gateways, check your configuration")
|
||||
return False
|
||||
|
||||
hass.data[MYSENSORS_GATEWAYS] = gateways
|
||||
@@ -266,9 +270,9 @@ def setup(hass, config):
|
||||
def pf_callback_factory(map_sv_types, devices, entity_class, add_devices=None):
|
||||
"""Return a new callback for the platform."""
|
||||
def mysensors_callback(gateway, msg):
|
||||
"""Callback for mysensors platform."""
|
||||
"""Run when a message from the gateway arrives."""
|
||||
if gateway.sensors[msg.node_id].sketch_name is None:
|
||||
_LOGGER.debug('No sketch_name: node %s', msg.node_id)
|
||||
_LOGGER.debug("No sketch_name: node %s", msg.node_id)
|
||||
return
|
||||
child = gateway.sensors[msg.node_id].children.get(msg.child_id)
|
||||
if child is None:
|
||||
@@ -294,7 +298,7 @@ def pf_callback_factory(map_sv_types, devices, entity_class, add_devices=None):
|
||||
devices[key] = device_class(
|
||||
gateway, msg.node_id, child.id, name, value_type)
|
||||
if add_devices:
|
||||
_LOGGER.info('Adding new devices: %s', [devices[key]])
|
||||
_LOGGER.info("Adding new devices: %s", [devices[key]])
|
||||
add_devices([devices[key]], True)
|
||||
else:
|
||||
devices[key].update()
|
||||
@@ -305,7 +309,7 @@ class GatewayWrapper(object):
|
||||
"""Gateway wrapper class."""
|
||||
|
||||
def __init__(self, gateway, optimistic, device):
|
||||
"""Setup class attributes on instantiation.
|
||||
"""Set up the class attributes on instantiation.
|
||||
|
||||
Args:
|
||||
gateway (mysensors.SerialGateway): Gateway to wrap.
|
||||
@@ -348,7 +352,7 @@ class GatewayWrapper(object):
|
||||
def node_update(msg):
|
||||
"""Callback for node updates from the MySensors gateway."""
|
||||
_LOGGER.debug(
|
||||
'Update: node %s, child %s sub_type %s',
|
||||
"Update: node %s, child %s sub_type %s",
|
||||
msg.node_id, msg.child_id, msg.sub_type)
|
||||
for callback in self.platform_callbacks:
|
||||
callback(self, msg)
|
||||
@@ -357,10 +361,10 @@ class GatewayWrapper(object):
|
||||
|
||||
|
||||
class MySensorsDeviceEntity(object):
|
||||
"""Represent a MySensors entity."""
|
||||
"""Representation of a MySensors entity."""
|
||||
|
||||
def __init__(self, gateway, node_id, child_id, name, value_type):
|
||||
"""Set up MySensors device."""
|
||||
"""Set up the MySensors device."""
|
||||
self.gateway = gateway
|
||||
self.node_id = node_id
|
||||
self.child_id = child_id
|
||||
|
||||
Reference in New Issue
Block a user