Add link to docs and modify docstrings to match PEP257
This commit is contained in:
1 parent
3f82b9d6b0
commit
4563c54a3e
13 files changed
+155
-152
No files matched your search
@@ -1,8 +1,8 @@
|
||||
"""
|
||||
homeassistant.components.switch.demo
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Demo platform that has two fake switches.
|
||||
|
||||
For more details about this platform, please refer to the documentation
|
||||
https://home-assistant.io/components/demo/
|
||||
"""
|
||||
from homeassistant.components.switch import SwitchDevice
|
||||
from homeassistant.const import DEVICE_DEFAULT_NAME
|
||||
@@ -10,7 +10,7 @@ from homeassistant.const import DEVICE_DEFAULT_NAME
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||
""" Find and return demo switches. """
|
||||
"""Setup the demo switches."""
|
||||
add_devices_callback([
|
||||
DemoSwitch('Decorative Lights', True, None, True),
|
||||
DemoSwitch('AC', False, 'mdi:air-conditioner', False)
|
||||
@@ -18,7 +18,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||
|
||||
|
||||
class DemoSwitch(SwitchDevice):
|
||||
""" Provides a demo switch. """
|
||||
"""Provide a demo switch."""
|
||||
def __init__(self, name, state, icon, assumed):
|
||||
self._name = name or DEVICE_DEFAULT_NAME
|
||||
self._state = state
|
||||
@@ -27,17 +27,17 @@ class DemoSwitch(SwitchDevice):
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
""" No polling needed for a demo switch. """
|
||||
"""No polling needed for a demo switch."""
|
||||
return False
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
""" Returns the name of the device if any. """
|
||||
"""Return the name of the device if any."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
""" Returns the icon to use for device if any. """
|
||||
"""Return the icon to use for device if any."""
|
||||
return self._icon
|
||||
|
||||
@property
|
||||
@@ -47,26 +47,26 @@ class DemoSwitch(SwitchDevice):
|
||||
|
||||
@property
|
||||
def current_power_mwh(self):
|
||||
""" Current power usage in mwh. """
|
||||
"""Returns the current power usage in mwh."""
|
||||
if self._state:
|
||||
return 100
|
||||
|
||||
@property
|
||||
def today_power_mw(self):
|
||||
""" Today total power usage in mw. """
|
||||
"""Return the today total power usage in mw."""
|
||||
return 1500
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
""" True if device is on. """
|
||||
"""Return true if switch is on."""
|
||||
return self._state
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
""" Turn the device on. """
|
||||
"""Turn the switch on."""
|
||||
self._state = True
|
||||
self.update_ha_state()
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
""" Turn the device off. """
|
||||
"""Turn the device off."""
|
||||
self._state = False
|
||||
self.update_ha_state()
|
||||
Reference in new issue
Block a user