Update docstring (config file) and attempt to honor PEP0257

This commit is contained in:
Fabian Affolter 2015-09-07 19:39:16 +02:00
parent f18928d85b
commit 78a555faf5
11 changed files with 38 additions and 31 deletions

View File

@ -6,6 +6,9 @@ supported.
Configuration: Configuration:
To use the arduino switch you will need to add something like the following
to your configuration.yaml file.
switch: switch:
platform: arduino platform: arduino
pins: pins:
@ -62,7 +65,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class ArduinoSwitch(SwitchDevice): class ArduinoSwitch(SwitchDevice):
""" Represents an Arduino Switch. """ """ Represents an Arduino switch. """
def __init__(self, name, pin, pin_type): def __init__(self, name, pin, pin_type):
self._pin = pin self._pin = pin
self._name = name or DEVICE_DEFAULT_NAME self._name = name or DEVICE_DEFAULT_NAME

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
homeassistant.components.switch.command_switch homeassistant.components.switch.command_switch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Allows to configure custom shell commands to turn a switch on/off. Allows to configure custom shell commands to turn a switch on/off.
""" """
@ -30,7 +30,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
class CommandSwitch(SwitchDevice): class CommandSwitch(SwitchDevice):
""" Represents a switch that can be togggled using shell commands """ """ Represents a switch that can be togggled using shell commands. """
def __init__(self, name, command_on, command_off): def __init__(self, name, command_on, command_off):
self._name = name self._name = name
self._state = False self._state = False
@ -39,7 +39,7 @@ class CommandSwitch(SwitchDevice):
@staticmethod @staticmethod
def _switch(command): def _switch(command):
""" Execute the actual commands """ """ Execute the actual commands. """
_LOGGER.info('Running command: %s', command) _LOGGER.info('Running command: %s', command)
success = (subprocess.call(command, shell=True) == 0) success = (subprocess.call(command, shell=True) == 0)
@ -51,12 +51,12 @@ class CommandSwitch(SwitchDevice):
@property @property
def should_poll(self): def should_poll(self):
""" No polling needed """ """ No polling needed. """
return False return False
@property @property
def name(self): def name(self):
""" The name of the switch """ """ The name of the switch. """
return self._name return self._name
@property @property

View File

@ -3,7 +3,6 @@ homeassistant.components.switch.demo
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo platform that has two fake switches. Demo platform that has two fake switches.
""" """
from homeassistant.components.switch import SwitchDevice from homeassistant.components.switch import SwitchDevice
from homeassistant.const import DEVICE_DEFAULT_NAME from homeassistant.const import DEVICE_DEFAULT_NAME

View File

@ -6,7 +6,7 @@ Support for Edimax switches.
Configuration: Configuration:
To use the Edimax switch you will need to add something like the following to To use the Edimax switch you will need to add something like the following to
your config/configuration.yaml. your configuration.yaml file.
switch: switch:
platform: edimax platform: edimax
@ -89,7 +89,7 @@ class SmartPlugSwitch(SwitchDevice):
@property @property
def current_power_mwh(self): def current_power_mwh(self):
""" Current power usage in mwh. """ """ Current power usage in mWh. """
try: try:
return float(self.smartplug.now_power) / 1000000.0 return float(self.smartplug.now_power) / 1000000.0
except ValueError: except ValueError:
@ -97,7 +97,7 @@ class SmartPlugSwitch(SwitchDevice):
@property @property
def today_power_mw(self): def today_power_mw(self):
""" Today total power usage in mw. """ """ Today total power usage in mW. """
try: try:
return float(self.smartplug.now_energy_day) / 1000.0 return float(self.smartplug.now_energy_day) / 1000.0
except ValueError: except ValueError:

View File

@ -1,12 +1,12 @@
""" """
homeassistant.components.switch.modbus homeassistant.components.switch.modbus
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support for Modbus switches. Support for Modbus switches.
Configuration: Configuration:
To use the Modbus switches you will need to add something like the following to To use the Modbus switches you will need to add something like the following to
your config/configuration.yaml your configuration.yaml file.
sensor: sensor:
platform: modbus platform: modbus
@ -42,7 +42,7 @@ DEPENDENCIES = ['modbus']
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
""" Read config and create Modbus devices """ """ Read configuration and create Modbus devices. """
switches = [] switches = []
slave = config.get("slave", None) slave = config.get("slave", None)
if modbus.TYPE == "serial" and not slave: if modbus.TYPE == "serial" and not slave:
@ -87,8 +87,10 @@ class ModbusSwitch(ToggleEntity):
@property @property
def should_poll(self): def should_poll(self):
""" We should poll, because slaves are not allowed to """
initiate communication on Modbus networks""" We should poll, because slaves are not allowed to initiate
communication on Modbus networks.
"""
return True return True
@property @property

View File

@ -2,10 +2,14 @@
homeassistant.components.switch.rpi_gpio homeassistant.components.switch.rpi_gpio
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Allows to control the GPIO pins of a Raspberry Pi. Allows to control the GPIO pins of a Raspberry Pi.
Note: To use RPi GPIO, Home Assistant must be run as root. Note: To use RPi GPIO, Home Assistant must be run as root.
Configuration: Configuration:
To use the Raspberry GPIO switches you will need to add something like the
following to your configuration.yaml file.
switch: switch:
platform: rpi_gpio platform: rpi_gpio
invert_logic: false invert_logic: false

View File

@ -1,7 +1,6 @@
""" """
homeassistant.components.switch.tellstick homeassistant.components.switch.tellstick
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support for Tellstick switches. Support for Tellstick switches.
Because the tellstick sends its actions via radio and from most Because the tellstick sends its actions via radio and from most
@ -47,7 +46,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
class TellstickSwitchDevice(ToggleEntity): class TellstickSwitchDevice(ToggleEntity):
""" Represents a Tellstick switch within Home Assistant. """ """ Represents a Tellstick switch. """
last_sent_command_mask = (tellcore_constants.TELLSTICK_TURNON | last_sent_command_mask = (tellcore_constants.TELLSTICK_TURNON |
tellcore_constants.TELLSTICK_TURNOFF) tellcore_constants.TELLSTICK_TURNOFF)

View File

@ -6,15 +6,15 @@ Enable or disable Transmission BitTorrent client Turtle Mode.
Configuration: Configuration:
To use the Transmission switch you will need to add something like the To use the Transmission switch you will need to add something like the
following to your config/configuration.yaml following to your configuration.yaml file.
switch: switch:
platform: transmission platform: transmission
name: Transmission name: Transmission
host: 192.168.1.26 host: 192.168.1.26
port: 9091 port: 9091
username: YOUR_USERNAME username: YOUR_USERNAME
password: YOUR_PASSWORD password: YOUR_PASSWORD
Variables: Variables:

View File

@ -5,7 +5,7 @@ Support for Vera switches.
Configuration: Configuration:
To use the Vera lights you will need to add something like the following to To use the Vera lights you will need to add something like the following to
your config/configuration.yaml. your configuration.yaml file.
switch: switch:
platform: vera platform: vera

View File

@ -1,7 +1,7 @@
""" """
homeassistant.components.switch.verisure homeassistant.components.switch.verisure
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support for Verisure Smartplugs Support for Verisure Smartplugs.
""" """
import logging import logging
@ -12,7 +12,7 @@ _LOGGER = logging.getLogger(__name__)
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the Arduino platform. """ """ Sets up the Verisure platform. """
if not verisure.MY_PAGES: if not verisure.MY_PAGES:
_LOGGER.error('A connection has not been made to Verisure mypages.') _LOGGER.error('A connection has not been made to Verisure mypages.')
@ -48,13 +48,13 @@ class VerisureSmartplug(SwitchDevice):
return plug_status == self.status_on return plug_status == self.status_on
def turn_on(self): def turn_on(self):
""" Set smartplug status on """ """ Set smartplug status on. """
verisure.MY_PAGES.set_smartplug_status( verisure.MY_PAGES.set_smartplug_status(
self._id, self._id,
self.status_on) self.status_on)
def turn_off(self): def turn_off(self):
""" Set smartplug status off """ """ Set smartplug status off. """
verisure.MY_PAGES.set_smartplug_status( verisure.MY_PAGES.set_smartplug_status(
self._id, self._id,
self.status_off) self.status_off)

View File

@ -36,7 +36,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
class WemoSwitch(SwitchDevice): class WemoSwitch(SwitchDevice):
""" Represents a WeMo switch within Home Assistant. """ """ Represents a WeMo switch. """
def __init__(self, wemo): def __init__(self, wemo):
self.wemo = wemo self.wemo = wemo
self.insight_params = None self.insight_params = None