mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Add docstrings, fix typos, and update docsstring for PEP257
This commit is contained in:
parent
7a0c99a1d5
commit
fd3ea95b82
@ -1,6 +1,4 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.binary_sensor
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Component to interface with binary sensors (sensors which only know two states)
|
Component to interface with binary sensors (sensors which only know two states)
|
||||||
that can be monitored.
|
that can be monitored.
|
||||||
|
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.binary_sensor.apcupsd
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Provides a binary sensor to track online status of a UPS.
|
Provides a binary sensor to track online status of a UPS.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
@ -14,7 +12,7 @@ DEFAULT_NAME = "UPS Online Status"
|
|||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
""" Instantiate an OnlineStatus binary sensor entity and add it to HA. """
|
"""Instantiate an OnlineStatus binary sensor entity."""
|
||||||
add_entities((OnlineStatus(config, apcupsd.DATA),))
|
add_entities((OnlineStatus(config, apcupsd.DATA),))
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.binary_sensor.arest
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
The arest sensor will consume an exposed aREST API of a device.
|
The arest sensor will consume an exposed aREST API of a device.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
@ -25,7 +23,6 @@ CONF_PIN = 'pin'
|
|||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Get the aREST binary sensor."""
|
"""Get the aREST binary sensor."""
|
||||||
|
|
||||||
resource = config.get(CONF_RESOURCE)
|
resource = config.get(CONF_RESOURCE)
|
||||||
pin = config.get(CONF_PIN)
|
pin = config.get(CONF_PIN)
|
||||||
|
|
||||||
@ -89,7 +86,6 @@ class ArestBinarySensor(BinarySensorDevice):
|
|||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class ArestData(object):
|
class ArestData(object):
|
||||||
"""Class for handling the data retrieval for pins."""
|
"""Class for handling the data retrieval for pins."""
|
||||||
|
|
||||||
def __init__(self, resource, pin):
|
def __init__(self, resource, pin):
|
||||||
self._resource = resource
|
self._resource = resource
|
||||||
self._pin = pin
|
self._pin = pin
|
||||||
|
@ -38,7 +38,7 @@ class BloomSkySensor(BinarySensorDevice):
|
|||||||
""" Represents a single binary sensor in a BloomSky device. """
|
""" Represents a single binary sensor in a BloomSky device. """
|
||||||
|
|
||||||
def __init__(self, bs, device, sensor_name):
|
def __init__(self, bs, device, sensor_name):
|
||||||
"""Initialize a bloomsky binary sensor."""
|
"""Initialize a BloomSky binary sensor."""
|
||||||
self._bloomsky = bs
|
self._bloomsky = bs
|
||||||
self._device_id = device["DeviceID"]
|
self._device_id = device["DeviceID"]
|
||||||
self._sensor_name = sensor_name
|
self._sensor_name = sensor_name
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.binary_sensor.command_sensor
|
Allows to configure custom shell commands to turn a value into a logical value
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
for a binary sensor.
|
||||||
Allows to configure custom shell commands to turn a value
|
|
||||||
into a logical value for a binary sensor.
|
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/binary_sensor.command/
|
https://home-assistant.io/components/binary_sensor.command/
|
||||||
@ -28,7 +26,6 @@ MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60)
|
|||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Add the Command Sensor."""
|
"""Add the Command Sensor."""
|
||||||
|
|
||||||
if config.get('command') is None:
|
if config.get('command') is None:
|
||||||
_LOGGER.error('Missing required variable: "command"')
|
_LOGGER.error('Missing required variable: "command"')
|
||||||
return False
|
return False
|
||||||
@ -47,8 +44,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
|
|
||||||
# pylint: disable=too-many-arguments
|
# pylint: disable=too-many-arguments
|
||||||
class CommandBinarySensor(BinarySensorDevice):
|
class CommandBinarySensor(BinarySensorDevice):
|
||||||
""" Represents a binary sensor that is returning
|
"""
|
||||||
a value of a shell commands. """
|
Represents a binary sensor that is returning a value of a shell commands.
|
||||||
|
"""
|
||||||
def __init__(self, hass, data, name, payload_on,
|
def __init__(self, hass, data, name, payload_on,
|
||||||
payload_off, value_template):
|
payload_off, value_template):
|
||||||
self._hass = hass
|
self._hass = hass
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.binary_sensor.demo
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Demo platform that has two fake binary sensors.
|
Demo platform that has two fake binary sensors.
|
||||||
"""
|
"""
|
||||||
from homeassistant.components.binary_sensor import BinarySensorDevice
|
from homeassistant.components.binary_sensor import BinarySensorDevice
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
""" Sets up the Demo binary sensors. """
|
"""Sets up the Demo binary sensors """
|
||||||
add_devices([
|
add_devices([
|
||||||
DemoBinarySensor('Basement Floor Wet', False, 'moisture'),
|
DemoBinarySensor('Basement Floor Wet', False, 'moisture'),
|
||||||
DemoBinarySensor('Movement Backyard', True, 'motion'),
|
DemoBinarySensor('Movement Backyard', True, 'motion'),
|
||||||
@ -24,7 +22,7 @@ class DemoBinarySensor(BinarySensorDevice):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def sensor_class(self):
|
def sensor_class(self):
|
||||||
""" Return our class. """
|
"""Return the class of this sensor."""
|
||||||
return self._sensor_type
|
return self._sensor_type
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.binary_sensor.mqtt
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Allows to configure a MQTT binary sensor.
|
Allows to configure a MQTT binary sensor.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
|
@ -54,7 +54,8 @@ class MySensorsBinarySensor(BinarySensorDevice):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, gateway, node_id, child_id, name, value_type, child_type):
|
self, gateway, node_id, child_id, name, value_type, child_type):
|
||||||
"""Setup class attributes on instantiation.
|
"""
|
||||||
|
Setup class attributes on instantiation.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
gateway (GatewayWrapper): Gateway object.
|
gateway (GatewayWrapper): Gateway object.
|
||||||
@ -124,7 +125,7 @@ class MySensorsBinarySensor(BinarySensorDevice):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def sensor_class(self):
|
def sensor_class(self):
|
||||||
"""Return the class of this sensor, from SENSOR_CASSES."""
|
"""Return the class of this sensor, from SENSOR_CLASSES."""
|
||||||
pres = self.gateway.const.Presentation
|
pres = self.gateway.const.Presentation
|
||||||
class_map = {
|
class_map = {
|
||||||
pres.S_DOOR: 'opening',
|
pres.S_DOOR: 'opening',
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.binary_sensor.nest
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Support for Nest Thermostat Binary Sensors.
|
Support for Nest Thermostat Binary Sensors.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.sensor.nx584
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Support for exposing nx584 elements as sensors.
|
Support for exposing nx584 elements as sensors.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
@ -73,18 +71,22 @@ class NX584ZoneSensor(BinarySensorDevice):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def sensor_class(self):
|
def sensor_class(self):
|
||||||
|
"""Return the class of this sensor, from SENSOR_CLASSES."""
|
||||||
return self._zone_type
|
return self._zone_type
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
|
"""No polling needed."""
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
"""Name of the binary sensor."""
|
||||||
return self._zone['name']
|
return self._zone['name']
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
|
"""Return true if the binary sensor is on."""
|
||||||
# True means "faulted" or "open" or "abnormal state"
|
# True means "faulted" or "open" or "abnormal state"
|
||||||
return self._zone['state']
|
return self._zone['state']
|
||||||
|
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.binary_sensor.rest
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
The rest binary sensor will consume responses sent by an exposed REST API.
|
The rest binary sensor will consume responses sent by an exposed REST API.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
@ -59,7 +57,7 @@ class RestBinarySensor(BinarySensorDevice):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
""" Return if the binary sensor is on. """
|
"""Return true if the binary sensor is on."""
|
||||||
if self.rest.data is None:
|
if self.rest.data is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.binary_sensor.rpi_gpio
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Allows to configure a binary sensor using RPi GPIO.
|
Allows to configure a binary sensor using RPi GPIO.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/binary_sensor.rpi_gpio/
|
https://home-assistant.io/components/binary_sensor.rpi_gpio/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import homeassistant.components.rpi_gpio as rpi_gpio
|
import homeassistant.components.rpi_gpio as rpi_gpio
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.binary_sensor.tcp
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Provides a binary_sensor which gets its values from a TCP socket.
|
Provides a binary_sensor which gets its values from a TCP socket.
|
||||||
|
|
||||||
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/binary_sensor.tcp/
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import BinarySensorDevice
|
from homeassistant.components.binary_sensor import BinarySensorDevice
|
||||||
from homeassistant.components.sensor.tcp import Sensor, DOMAIN, CONF_VALUE_ON
|
from homeassistant.components.sensor.tcp import Sensor, DOMAIN, CONF_VALUE_ON
|
||||||
|
|
||||||
|
|
||||||
DEPENDENCIES = [DOMAIN]
|
DEPENDENCIES = [DOMAIN]
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
""" Create the BinarySensor. """
|
"""Create the binary sensor."""
|
||||||
if not BinarySensor.validate_config(config):
|
if not BinarySensor.validate_config(config):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
add_entities((BinarySensor(hass, config),))
|
add_entities((BinarySensor(hass, config),))
|
||||||
|
|
||||||
|
|
||||||
@ -27,4 +27,5 @@ class BinarySensor(BinarySensorDevice, Sensor):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
|
"""True if the binary sensor is on."""
|
||||||
return self._state == self._config[CONF_VALUE_ON]
|
return self._state == self._config[CONF_VALUE_ON]
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.binary_sensor.zigbee
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Contains functionality to use a ZigBee device as a binary sensor.
|
Contains functionality to use a ZigBee device as a binary sensor.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.binary_sensor.zwave
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Interfaces with Z-Wave sensors.
|
Interfaces with Z-Wave sensors.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation
|
For more details about this platform, please refer to the documentation
|
||||||
at https://home-assistant.io/components/zwave/
|
https://home-assistant.io/components/binary_sensor.zwave/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.zwave import (
|
from homeassistant.components.zwave import (
|
||||||
@ -23,7 +19,7 @@ DEPENDENCIES = []
|
|||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Setup the mysensors platform for sensors."""
|
"""Setup the Z-Wave platform for sensors."""
|
||||||
|
|
||||||
if discovery_info is None or NETWORK is None:
|
if discovery_info is None or NETWORK is None:
|
||||||
return
|
return
|
||||||
@ -62,6 +58,7 @@ class ZWaveBinarySensor(BinarySensorDevice, ZWaveDeviceEntity):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
|
"""No polling needed."""
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def value_changed(self, value):
|
def value_changed(self, value):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user