Add link to docs and modify docstrings to match PEP257

This commit is contained in:
Fabian Affolter 2016-02-24 10:38:06 +01:00
parent 3f82b9d6b0
commit 4563c54a3e
13 changed files with 155 additions and 152 deletions

View file

@ -1,13 +1,14 @@
""" """
homeassistant.components.alarm_control_panel.demo
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo platform that has two fake alarm control panels. Demo platform that has two fake alarm control panels.
For more details about this platform, please refer to the documentation
https://home-assistant.io/components/demo/
""" """
import homeassistant.components.alarm_control_panel.manual as manual import homeassistant.components.alarm_control_panel.manual as manual
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the Demo alarm control panels. """ """Setup the Demo alarm control panel platform."""
add_devices([ add_devices([
manual.ManualAlarm(hass, 'Alarm', '1234', 5, 10), manual.ManualAlarm(hass, 'Alarm', '1234', 5, 10),
]) ])

View file

@ -1,11 +1,14 @@
""" """
Demo platform that has two fake binary sensors. Demo platform that has two fake binary sensors.
For more details about this platform, please refer to the documentation
https://home-assistant.io/components/demo/
""" """
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 """ """Setup the Demo binary sensor platform."""
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'),
@ -14,7 +17,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class DemoBinarySensor(BinarySensorDevice): class DemoBinarySensor(BinarySensorDevice):
"""A Demo binary sensor.""" """A Demo binary sensor."""
def __init__(self, name, state, sensor_class): def __init__(self, name, state, sensor_class):
self._name = name self._name = name
self._state = state self._state = state
@ -32,10 +34,10 @@ class DemoBinarySensor(BinarySensorDevice):
@property @property
def name(self): def name(self):
"""Returns the name of the binary sensor.""" """Return the name of the binary sensor."""
return self._name return self._name
@property @property
def is_on(self): def is_on(self):
"""True if the binary sensor is on.""" """Return true if the binary sensor is on."""
return self._state return self._state

View file

@ -1,7 +1,8 @@
""" """
homeassistant.components.camera.demo Demo camera platform that has a fake camera.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo platform that has a fake camera. For more details about this platform, please refer to the documentation
https://home-assistant.io/components/demo/
""" """
import os import os
@ -10,21 +11,21 @@ from homeassistant.components.camera import Camera
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the Demo camera. """ """Setup the Demo camera platform."""
add_devices([ add_devices([
DemoCamera('Demo camera') DemoCamera('Demo camera')
]) ])
class DemoCamera(Camera): class DemoCamera(Camera):
""" A Demo camera. """ """A Demo camera."""
def __init__(self, name): def __init__(self, name):
super().__init__() super().__init__()
self._name = name self._name = name
def camera_image(self): def camera_image(self):
""" Return a faked still image response. """ """Return a faked still image response."""
now = dt_util.utcnow() now = dt_util.utcnow()
image_path = os.path.join(os.path.dirname(__file__), image_path = os.path.join(os.path.dirname(__file__),
@ -34,5 +35,5 @@ class DemoCamera(Camera):
@property @property
def name(self): def name(self):
""" Return the name of this device. """ """Return the name of this camera."""
return self._name return self._name

View file

@ -1,8 +1,8 @@
""" """
homeassistant.components.demo
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sets up a demo environment that mimics interaction with devices. Sets up a demo environment that mimics interaction with devices.
For more details about this component, please refer to the documentation
https://home-assistant.io/components/demo/
""" """
import time import time
@ -33,7 +33,7 @@ COMPONENTS_WITH_DEMO_PLATFORM = [
def setup(hass, config): def setup(hass, config):
""" Setup a demo environment. """ """Setup a demo environment."""
group = loader.get_component('group') group = loader.get_component('group')
configurator = loader.get_component('configurator') configurator = loader.get_component('configurator')
@ -116,7 +116,7 @@ def setup(hass, config):
configurator_ids = [] configurator_ids = []
def hue_configuration_callback(data): def hue_configuration_callback(data):
""" Fake callback, mark config as done. """ """Fake callback, mark config as done."""
time.sleep(2) time.sleep(2)
# First time it is called, pretend it failed. # First time it is called, pretend it failed.

View file

@ -30,20 +30,20 @@ class DemoGarageDoor(GarageDoorDevice):
@property @property
def name(self): def name(self):
"""Returns the name of the device if any.""" """Return the name of the device if any."""
return self._name return self._name
@property @property
def is_closed(self): def is_closed(self):
"""True if device is closed.""" """Return true if garage door is closed."""
return self._state == STATE_CLOSED return self._state == STATE_CLOSED
def close_door(self, **kwargs): def close_door(self, **kwargs):
"""Close the device.""" """Close the garage door."""
self._state = STATE_CLOSED self._state = STATE_CLOSED
self.update_ha_state() self.update_ha_state()
def open_door(self, **kwargs): def open_door(self, **kwargs):
"""Open the device.""" """Open the garage door."""
self._state = STATE_OPEN self._state = STATE_OPEN
self.update_ha_state() self.update_ha_state()

View file

@ -1,8 +1,8 @@
""" """
homeassistant.components.light.demo Demo light platform that implements lights.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo platform that implements lights.
For more details about this platform, please refer to the documentation
https://home-assistant.io/components/demo/
""" """
import random import random
@ -18,7 +18,7 @@ LIGHT_TEMPS = [240, 380]
def setup_platform(hass, config, add_devices_callback, discovery_info=None): def setup_platform(hass, config, add_devices_callback, discovery_info=None):
""" Find and return demo lights. """ """Setup demo light platform."""
add_devices_callback([ add_devices_callback([
DemoLight("Bed Light", False), DemoLight("Bed Light", False),
DemoLight("Ceiling Lights", True, LIGHT_COLORS[0], LIGHT_TEMPS[1]), DemoLight("Ceiling Lights", True, LIGHT_COLORS[0], LIGHT_TEMPS[1]),
@ -27,7 +27,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
class DemoLight(Light): class DemoLight(Light):
""" Provides a demo switch. """ """Provides a demo light."""
# pylint: disable=too-many-arguments # pylint: disable=too-many-arguments
def __init__(self, name, state, rgb=None, ct=None, brightness=180): def __init__(self, name, state, rgb=None, ct=None, brightness=180):
self._name = name self._name = name
@ -38,36 +38,36 @@ class DemoLight(Light):
@property @property
def should_poll(self): def should_poll(self):
""" No polling needed for a demo light. """ """No polling needed for a demo light."""
return False return False
@property @property
def name(self): def name(self):
""" Returns the name of the device if any. """ """Return the name of the light if any."""
return self._name return self._name
@property @property
def brightness(self): def brightness(self):
""" Brightness of this light between 0..255. """ """Return the brightness of this light between 0..255."""
return self._brightness return self._brightness
@property @property
def rgb_color(self): def rgb_color(self):
""" rgb color value. """ """Return the RBG color value."""
return self._rgb return self._rgb
@property @property
def color_temp(self): def color_temp(self):
""" CT color temperature. """ """Return the CT color temperature."""
return self._ct return self._ct
@property @property
def is_on(self): def is_on(self):
""" True if device is on. """ """Return true if light is on."""
return self._state return self._state
def turn_on(self, **kwargs): def turn_on(self, **kwargs):
""" Turn the device on. """ """Turn the light on."""
self._state = True self._state = True
if ATTR_RGB_COLOR in kwargs: if ATTR_RGB_COLOR in kwargs:
@ -82,6 +82,6 @@ class DemoLight(Light):
self.update_ha_state() self.update_ha_state()
def turn_off(self, **kwargs): def turn_off(self, **kwargs):
""" Turn the device off. """ """Turn the light off."""
self._state = False self._state = False
self.update_ha_state() self.update_ha_state()

View file

@ -1,8 +1,8 @@
""" """
homeassistant.components.lock.demo Demo lock platform that has two fake locks.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo platform that has two fake locks. For more details about this platform, please refer to the documentation
https://home-assistant.io/components/demo/
""" """
from homeassistant.components.lock import LockDevice from homeassistant.components.lock import LockDevice
from homeassistant.const import STATE_LOCKED, STATE_UNLOCKED from homeassistant.const import STATE_LOCKED, STATE_UNLOCKED
@ -10,7 +10,7 @@ from homeassistant.const import STATE_LOCKED, STATE_UNLOCKED
# pylint: disable=unused-argument # pylint: disable=unused-argument
def setup_platform(hass, config, add_devices_callback, discovery_info=None): def setup_platform(hass, config, add_devices_callback, discovery_info=None):
""" Find and return demo locks. """ """Setup the demo lock platform. """
add_devices_callback([ add_devices_callback([
DemoLock('Front Door', STATE_LOCKED), DemoLock('Front Door', STATE_LOCKED),
DemoLock('Kitchen Door', STATE_UNLOCKED) DemoLock('Kitchen Door', STATE_UNLOCKED)
@ -18,32 +18,32 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
class DemoLock(LockDevice): class DemoLock(LockDevice):
""" Provides a demo lock. """ """Provides a demo lock."""
def __init__(self, name, state): def __init__(self, name, state):
self._name = name self._name = name
self._state = state self._state = state
@property @property
def should_poll(self): def should_poll(self):
""" No polling needed for a demo lock. """ """No polling needed for a demo lock."""
return False return False
@property @property
def name(self): def name(self):
""" Returns the name of the device if any. """ """Return the name of the lock if any."""
return self._name return self._name
@property @property
def is_locked(self): def is_locked(self):
""" True if device is locked. """ """Return true if lock is locked."""
return self._state == STATE_LOCKED return self._state == STATE_LOCKED
def lock(self, **kwargs): def lock(self, **kwargs):
""" Lock the device. """ """Lock the device."""
self._state = STATE_LOCKED self._state = STATE_LOCKED
self.update_ha_state() self.update_ha_state()
def unlock(self, **kwargs): def unlock(self, **kwargs):
""" Unlock the device. """ """Unlock the device."""
self._state = STATE_UNLOCKED self._state = STATE_UNLOCKED
self.update_ha_state() self.update_ha_state()

View file

@ -1,7 +1,8 @@
""" """
homeassistant.components.media_player.demo
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo implementation of the media player. Demo implementation of the media player.
For more details about this platform, please refer to the documentation
https://home-assistant.io/components/demo/
""" """
from homeassistant.components.media_player import ( from homeassistant.components.media_player import (
MEDIA_TYPE_MUSIC, MEDIA_TYPE_TVSHOW, MEDIA_TYPE_VIDEO, SUPPORT_NEXT_TRACK, MEDIA_TYPE_MUSIC, MEDIA_TYPE_TVSHOW, MEDIA_TYPE_VIDEO, SUPPORT_NEXT_TRACK,
@ -13,7 +14,7 @@ from homeassistant.const import STATE_OFF, STATE_PAUSED, STATE_PLAYING
# 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):
""" Sets up the cast platform. """ """Setup the media palyer demo platform."""
add_devices([ add_devices([
DemoYoutubePlayer( DemoYoutubePlayer(
'Living Room', 'eyU3bRy2x44', 'Living Room', 'eyU3bRy2x44',
@ -38,10 +39,9 @@ NETFLIX_PLAYER_SUPPORT = \
class AbstractDemoPlayer(MediaPlayerDevice): class AbstractDemoPlayer(MediaPlayerDevice):
""" Base class for demo media players. """ """A demo media players"""
# We only implement the methods that we support # We only implement the methods that we support
# pylint: disable=abstract-method # pylint: disable=abstract-method
def __init__(self, name): def __init__(self, name):
self._name = name self._name = name
self._player_state = STATE_PLAYING self._player_state = STATE_PLAYING
@ -50,65 +50,64 @@ class AbstractDemoPlayer(MediaPlayerDevice):
@property @property
def should_poll(self): def should_poll(self):
""" We will push an update after each command. """ """Push an update after each command."""
return False return False
@property @property
def name(self): def name(self):
""" Name of the media player. """ """Return the name of the media player."""
return self._name return self._name
@property @property
def state(self): def state(self):
""" State of the player. """ """Return the state of the player."""
return self._player_state return self._player_state
@property @property
def volume_level(self): def volume_level(self):
""" Volume level of the media player (0..1). """ """Return the volume level of the media player (0..1)."""
return self._volume_level return self._volume_level
@property @property
def is_volume_muted(self): def is_volume_muted(self):
""" Boolean if volume is currently muted. """ """Return boolean if volume is currently muted."""
return self._volume_muted return self._volume_muted
def turn_on(self): def turn_on(self):
""" turn the media player on. """ """Turn the media player on."""
self._player_state = STATE_PLAYING self._player_state = STATE_PLAYING
self.update_ha_state() self.update_ha_state()
def turn_off(self): def turn_off(self):
""" turn the media player off. """ """Turn the media player off."""
self._player_state = STATE_OFF self._player_state = STATE_OFF
self.update_ha_state() self.update_ha_state()
def mute_volume(self, mute): def mute_volume(self, mute):
""" mute the volume. """ """Mute the volume."""
self._volume_muted = mute self._volume_muted = mute
self.update_ha_state() self.update_ha_state()
def set_volume_level(self, volume): def set_volume_level(self, volume):
""" set volume level, range 0..1. """ """Set the volume level, range 0..1."""
self._volume_level = volume self._volume_level = volume
self.update_ha_state() self.update_ha_state()
def media_play(self): def media_play(self):
""" Send play commmand. """ """Send play command."""
self._player_state = STATE_PLAYING self._player_state = STATE_PLAYING
self.update_ha_state() self.update_ha_state()
def media_pause(self): def media_pause(self):
""" Send pause command. """ """Send pause command."""
self._player_state = STATE_PAUSED self._player_state = STATE_PAUSED
self.update_ha_state() self.update_ha_state()
class DemoYoutubePlayer(AbstractDemoPlayer): class DemoYoutubePlayer(AbstractDemoPlayer):
""" A Demo media player that only supports YouTube. """ """A Demo media player that only supports YouTube."""
# We only implement the methods that we support # We only implement the methods that we support
# pylint: disable=abstract-method # pylint: disable=abstract-method
def __init__(self, name, youtube_id=None, media_title=None): def __init__(self, name, youtube_id=None, media_title=None):
super().__init__(name) super().__init__(name)
self.youtube_id = youtube_id self.youtube_id = youtube_id
@ -116,50 +115,49 @@ class DemoYoutubePlayer(AbstractDemoPlayer):
@property @property
def media_content_id(self): def media_content_id(self):
""" Content ID of current playing media. """ """Return the content ID of current playing media."""
return self.youtube_id return self.youtube_id
@property @property
def media_content_type(self): def media_content_type(self):
""" Content type of current playing media. """ """Return the content type of current playing media."""
return MEDIA_TYPE_VIDEO return MEDIA_TYPE_VIDEO
@property @property
def media_duration(self): def media_duration(self):
""" Duration of current playing media in seconds. """ """ Return the duration of current playing media in seconds."""
return 360 return 360
@property @property
def media_image_url(self): def media_image_url(self):
""" Image url of current playing media. """ """Return the image url of current playing media."""
return YOUTUBE_COVER_URL_FORMAT.format(self.youtube_id) return YOUTUBE_COVER_URL_FORMAT.format(self.youtube_id)
@property @property
def media_title(self): def media_title(self):
""" Title of current playing media. """ """Return the title of current playing media."""
return self._media_title return self._media_title
@property @property
def app_name(self): def app_name(self):
""" Current running app. """ """Return the current running application."""
return "YouTube" return "YouTube"
@property @property
def supported_media_commands(self): def supported_media_commands(self):
""" Flags of media commands that are supported. """ """Flags of media commands that are supported."""
return YOUTUBE_PLAYER_SUPPORT return YOUTUBE_PLAYER_SUPPORT
def play_media(self, media_type, media_id): def play_media(self, media_type, media_id):
""" Plays a piece of media. """ """Play a piece of media."""
self.youtube_id = media_id self.youtube_id = media_id
self.update_ha_state() self.update_ha_state()
class DemoMusicPlayer(AbstractDemoPlayer): class DemoMusicPlayer(AbstractDemoPlayer):
""" A Demo media player that only supports YouTube. """ """A Demo media player that only supports YouTube."""
# We only implement the methods that we support # We only implement the methods that we support
# pylint: disable=abstract-method # pylint: disable=abstract-method
tracks = [ tracks = [
('Technohead', 'I Wanna Be A Hippy (Flamman & Abraxas Radio Mix)'), ('Technohead', 'I Wanna Be A Hippy (Flamman & Abraxas Radio Mix)'),
('Paul Elstak', 'Luv U More'), ('Paul Elstak', 'Luv U More'),
@ -188,48 +186,50 @@ class DemoMusicPlayer(AbstractDemoPlayer):
@property @property
def media_content_id(self): def media_content_id(self):
""" Content ID of current playing media. """ """Return the content ID of current playing media."""
return 'bounzz-1' return 'bounzz-1'
@property @property
def media_content_type(self): def media_content_type(self):
""" Content type of current playing media. """ """Return the content type of current playing media."""
return MEDIA_TYPE_MUSIC return MEDIA_TYPE_MUSIC
@property @property
def media_duration(self): def media_duration(self):
""" Duration of current playing media in seconds. """ """Return the duration of current playing media in seconds."""
return 213 return 213
@property @property
def media_image_url(self): def media_image_url(self):
""" Image url of current playing media. """ """Return the image url of current playing media."""
return 'https://graph.facebook.com/107771475912710/picture' return 'https://graph.facebook.com/107771475912710/picture'
@property @property
def media_title(self): def media_title(self):
""" Title of current playing media. """ """Return the title of current playing media."""
return self.tracks[self._cur_track][1] return self.tracks[self._cur_track][1]
@property @property
def media_artist(self): def media_artist(self):
""" Artist of current playing media. (Music track only) """ """Return the artist of current playing media (Music track only)."""
return self.tracks[self._cur_track][0] return self.tracks[self._cur_track][0]
@property @property
def media_album_name(self): def media_album_name(self):
""" Album of current playing media. (Music track only) """ """Return the album of current playing media (Music track only)."""
# pylint: disable=no-self-use # pylint: disable=no-self-use
return "Bounzz" return "Bounzz"
@property @property
def media_track(self): def media_track(self):
""" Track number of current playing media. (Music track only) """ """
Return the track number of current playing media (Music track only).
"""
return self._cur_track + 1 return self._cur_track + 1
@property @property
def supported_media_commands(self): def supported_media_commands(self):
""" Flags of media commands that are supported. """ """Flags of media commands that are supported."""
support = MUSIC_PLAYER_SUPPORT support = MUSIC_PLAYER_SUPPORT
if self._cur_track > 0: if self._cur_track > 0:
@ -241,23 +241,22 @@ class DemoMusicPlayer(AbstractDemoPlayer):
return support return support
def media_previous_track(self): def media_previous_track(self):
""" Send previous track command. """ """Send previous track command."""
if self._cur_track > 0: if self._cur_track > 0:
self._cur_track -= 1 self._cur_track -= 1
self.update_ha_state() self.update_ha_state()
def media_next_track(self): def media_next_track(self):
""" Send next track command. """ """Send next track command."""
if self._cur_track < len(self.tracks)-1: if self._cur_track < len(self.tracks)-1:
self._cur_track += 1 self._cur_track += 1
self.update_ha_state() self.update_ha_state()
class DemoTVShowPlayer(AbstractDemoPlayer): class DemoTVShowPlayer(AbstractDemoPlayer):
""" A Demo media player that only supports YouTube. """ """A Demo media player that only supports YouTube."""
# We only implement the methods that we support # We only implement the methods that we support
# pylint: disable=abstract-method # pylint: disable=abstract-method
def __init__(self): def __init__(self):
super().__init__('Lounge room') super().__init__('Lounge room')
self._cur_episode = 1 self._cur_episode = 1
@ -265,52 +264,52 @@ class DemoTVShowPlayer(AbstractDemoPlayer):
@property @property
def media_content_id(self): def media_content_id(self):
""" Content ID of current playing media. """ """Return the content ID of current playing media."""
return 'house-of-cards-1' return 'house-of-cards-1'
@property @property
def media_content_type(self): def media_content_type(self):
""" Content type of current playing media. """ """Return the content type of current playing media."""
return MEDIA_TYPE_TVSHOW return MEDIA_TYPE_TVSHOW
@property @property
def media_duration(self): def media_duration(self):
""" Duration of current playing media in seconds. """ """Return the duration of current playing media in seconds."""
return 3600 return 3600
@property @property
def media_image_url(self): def media_image_url(self):
""" Image url of current playing media. """ """Return the image url of current playing media."""
return 'https://graph.facebook.com/HouseofCards/picture' return 'https://graph.facebook.com/HouseofCards/picture'
@property @property
def media_title(self): def media_title(self):
""" Title of current playing media. """ """Return the title of current playing media."""
return 'Chapter {}'.format(self._cur_episode) return 'Chapter {}'.format(self._cur_episode)
@property @property
def media_series_title(self): def media_series_title(self):
""" Series title of current playing media. (TV Show only)""" """Return the series title of current playing media (TV Show only)."""
return 'House of Cards' return 'House of Cards'
@property @property
def media_season(self): def media_season(self):
""" Season of current playing media. (TV Show only) """ """Return the season of current playing media (TV Show only)."""
return 1 return 1
@property @property
def media_episode(self): def media_episode(self):
""" Episode of current playing media. (TV Show only) """ """Return the episode of current playing media (TV Show only)."""
return self._cur_episode return self._cur_episode
@property @property
def app_name(self): def app_name(self):
""" Current running app. """ """Return the current running application."""
return "Netflix" return "Netflix"
@property @property
def supported_media_commands(self): def supported_media_commands(self):
""" Flags of media commands that are supported. """ """Flag of media commands that are supported."""
support = NETFLIX_PLAYER_SUPPORT support = NETFLIX_PLAYER_SUPPORT
if self._cur_episode > 1: if self._cur_episode > 1:
@ -322,13 +321,13 @@ class DemoTVShowPlayer(AbstractDemoPlayer):
return support return support
def media_previous_track(self): def media_previous_track(self):
""" Send previous track command. """ """Send previous track command."""
if self._cur_episode > 1: if self._cur_episode > 1:
self._cur_episode -= 1 self._cur_episode -= 1
self.update_ha_state() self.update_ha_state()
def media_next_track(self): def media_next_track(self):
""" Send next track command. """ """Send next track command."""
if self._cur_episode < self._episode_count: if self._cur_episode < self._episode_count:
self._cur_episode += 1 self._cur_episode += 1
self.update_ha_state() self.update_ha_state()

View file

@ -1,8 +1,8 @@
""" """
homeassistant.components.notify.demo
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo notification service. Demo notification service.
For more details about this platform, please refer to the documentation
https://home-assistant.io/components/demo/
""" """
from homeassistant.components.notify import ATTR_TITLE, BaseNotificationService from homeassistant.components.notify import ATTR_TITLE, BaseNotificationService
@ -10,15 +10,13 @@ EVENT_NOTIFY = "notify"
def get_service(hass, config): def get_service(hass, config):
""" Get the demo notification service. """ """Get the demo notification service."""
return DemoNotificationService(hass) return DemoNotificationService(hass)
# pylint: disable=too-few-public-methods # pylint: disable=too-few-public-methods
class DemoNotificationService(BaseNotificationService): class DemoNotificationService(BaseNotificationService):
""" Implements demo notification service. """ """Implements demo notification service."""
def __init__(self, hass): def __init__(self, hass):
self.hass = hass self.hass = hass

View file

@ -1,7 +1,8 @@
""" """
homeassistant.components.rollershutter.demo Demo platform for the rollor shutter component.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo platform for the rollorshutter component. For more details about this platform, please refer to the documentation
https://home-assistant.io/components/demo/
""" """
from homeassistant.components.rollershutter import RollershutterDevice from homeassistant.components.rollershutter import RollershutterDevice
from homeassistant.const import EVENT_TIME_CHANGED from homeassistant.const import EVENT_TIME_CHANGED
@ -9,7 +10,7 @@ from homeassistant.helpers.event import track_utc_time_change
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the Demo rollershutters. """ """Setup the Demo roller shutters."""
add_devices([ add_devices([
DemoRollershutter(hass, 'Kitchen Window', 0), DemoRollershutter(hass, 'Kitchen Window', 0),
DemoRollershutter(hass, 'Living Room Window', 100), DemoRollershutter(hass, 'Living Room Window', 100),
@ -17,9 +18,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class DemoRollershutter(RollershutterDevice): class DemoRollershutter(RollershutterDevice):
""" Represents a rollershutter.. """ """Represents a roller shutter."""
# pylint: disable=no-self-use # pylint: disable=no-self-use
def __init__(self, hass, name, position): def __init__(self, hass, name, position):
self.hass = hass self.hass = hass
self._name = name self._name = name
@ -29,21 +29,21 @@ class DemoRollershutter(RollershutterDevice):
@property @property
def name(self): def name(self):
""" Returns the name of the rollershutter. """ """Returns the name of the roller shutter."""
return self._name return self._name
@property @property
def should_poll(self): def should_poll(self):
""" No polling needed for a demo rollershutter. """ """No polling needed for a demo roller shutter."""
return False return False
@property @property
def current_position(self): def current_position(self):
""" Returns the current position of the rollershutter. """ """Return the current position of the roller shutter."""
return self._position return self._position
def move_up(self, **kwargs): def move_up(self, **kwargs):
""" Move the rollershutter down. """ """Move the roller shutter down."""
if self._position == 0: if self._position == 0:
return return
@ -51,7 +51,7 @@ class DemoRollershutter(RollershutterDevice):
self._moving_up = True self._moving_up = True
def move_down(self, **kwargs): def move_down(self, **kwargs):
""" Move the rollershutter up. """ """Move the roller shutter up."""
if self._position == 100: if self._position == 100:
return return
@ -59,19 +59,19 @@ class DemoRollershutter(RollershutterDevice):
self._moving_up = False self._moving_up = False
def stop(self, **kwargs): def stop(self, **kwargs):
""" Stop the rollershutter. """ """Stops the roller shutter."""
if self._listener is not None: if self._listener is not None:
self.hass.bus.remove_listener(EVENT_TIME_CHANGED, self._listener) self.hass.bus.remove_listener(EVENT_TIME_CHANGED, self._listener)
self._listener = None self._listener = None
def _listen(self): def _listen(self):
""" Listens for changes. """ """Listen for changes."""
if self._listener is None: if self._listener is None:
self._listener = track_utc_time_change(self.hass, self._listener = track_utc_time_change(self.hass,
self._time_changed) self._time_changed)
def _time_changed(self, now): def _time_changed(self, now):
""" Track time changes. """ """Track time changes."""
if self._moving_up: if self._moving_up:
self._position -= 10 self._position -= 10
else: else:

View file

@ -1,5 +1,8 @@
""" """
Demo platform that has a couple of fake sensors. Demo platform that has a couple of fake sensors.
For more details about this platform, please refer to the documentation
https://home-assistant.io/components/demo/
""" """
from homeassistant.const import ATTR_BATTERY_LEVEL, TEMP_CELCIUS from homeassistant.const import ATTR_BATTERY_LEVEL, TEMP_CELCIUS
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
@ -29,22 +32,22 @@ class DemoSensor(Entity):
@property @property
def name(self): def name(self):
"""Returns the name of the sensor.""" """Return the name of the sensor."""
return self._name return self._name
@property @property
def state(self): def state(self):
"""Returns the state of the sensor.""" """Return the state of the sensor."""
return self._state return self._state
@property @property
def unit_of_measurement(self): def unit_of_measurement(self):
"""Unit this state is expressed in.""" """Return the unit this state is expressed in."""
return self._unit_of_measurement return self._unit_of_measurement
@property @property
def device_state_attributes(self): def device_state_attributes(self):
"""Returns the state attributes.""" """Return the state attributes."""
if self._battery: if self._battery:
return { return {
ATTR_BATTERY_LEVEL: self._battery, ATTR_BATTERY_LEVEL: self._battery,

View file

@ -1,8 +1,8 @@
""" """
homeassistant.components.switch.demo
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo platform that has two fake switches. 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.components.switch import SwitchDevice
from homeassistant.const import DEVICE_DEFAULT_NAME from homeassistant.const import DEVICE_DEFAULT_NAME
@ -10,7 +10,7 @@ from homeassistant.const import DEVICE_DEFAULT_NAME
# pylint: disable=unused-argument # pylint: disable=unused-argument
def setup_platform(hass, config, add_devices_callback, discovery_info=None): def setup_platform(hass, config, add_devices_callback, discovery_info=None):
""" Find and return demo switches. """ """Setup the demo switches."""
add_devices_callback([ add_devices_callback([
DemoSwitch('Decorative Lights', True, None, True), DemoSwitch('Decorative Lights', True, None, True),
DemoSwitch('AC', False, 'mdi:air-conditioner', False) 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): class DemoSwitch(SwitchDevice):
""" Provides a demo switch. """ """Provide a demo switch."""
def __init__(self, name, state, icon, assumed): def __init__(self, name, state, icon, assumed):
self._name = name or DEVICE_DEFAULT_NAME self._name = name or DEVICE_DEFAULT_NAME
self._state = state self._state = state
@ -27,17 +27,17 @@ class DemoSwitch(SwitchDevice):
@property @property
def should_poll(self): def should_poll(self):
""" No polling needed for a demo switch. """ """No polling needed for a demo switch."""
return False return False
@property @property
def name(self): def name(self):
""" Returns the name of the device if any. """ """Return the name of the device if any."""
return self._name return self._name
@property @property
def icon(self): def icon(self):
""" Returns the icon to use for device if any. """ """Return the icon to use for device if any."""
return self._icon return self._icon
@property @property
@ -47,26 +47,26 @@ class DemoSwitch(SwitchDevice):
@property @property
def current_power_mwh(self): def current_power_mwh(self):
""" Current power usage in mwh. """ """Returns the current power usage in mwh."""
if self._state: if self._state:
return 100 return 100
@property @property
def today_power_mw(self): def today_power_mw(self):
""" Today total power usage in mw. """ """Return the today total power usage in mw."""
return 1500 return 1500
@property @property
def is_on(self): def is_on(self):
""" True if device is on. """ """Return true if switch is on."""
return self._state return self._state
def turn_on(self, **kwargs): def turn_on(self, **kwargs):
""" Turn the device on. """ """Turn the switch on."""
self._state = True self._state = True
self.update_ha_state() self.update_ha_state()
def turn_off(self, **kwargs): def turn_off(self, **kwargs):
""" Turn the device off. """ """Turn the device off."""
self._state = False self._state = False
self.update_ha_state() self.update_ha_state()

View file

@ -1,15 +1,15 @@
""" """
homeassistant.components.thermostat.demo
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo platform that offers a fake thermostat. Demo platform that offers a fake thermostat.
For more details about this platform, please refer to the documentation
https://home-assistant.io/components/demo/
""" """
from homeassistant.components.thermostat import ThermostatDevice from homeassistant.components.thermostat import ThermostatDevice
from homeassistant.const import TEMP_CELCIUS, TEMP_FAHRENHEIT from homeassistant.const import TEMP_CELCIUS, TEMP_FAHRENHEIT
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the Demo thermostats. """ """Setup the Demo thermostats."""
add_devices([ add_devices([
DemoThermostat("Nest", 21, TEMP_CELCIUS, False, 19), DemoThermostat("Nest", 21, TEMP_CELCIUS, False, 19),
DemoThermostat("Thermostat", 68, TEMP_FAHRENHEIT, True, 77), DemoThermostat("Thermostat", 68, TEMP_FAHRENHEIT, True, 77),
@ -18,8 +18,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
# pylint: disable=too-many-arguments # pylint: disable=too-many-arguments
class DemoThermostat(ThermostatDevice): class DemoThermostat(ThermostatDevice):
""" Represents a HeatControl thermostat. """ """Represents a HeatControl thermostat."""
def __init__(self, name, target_temperature, unit_of_measurement, def __init__(self, name, target_temperature, unit_of_measurement,
away, current_temperature): away, current_temperature):
self._name = name self._name = name
@ -30,42 +29,42 @@ class DemoThermostat(ThermostatDevice):
@property @property
def should_poll(self): def should_poll(self):
""" No polling needed for a demo thermostat. """ """No polling needed for a demo thermostat."""
return False return False
@property @property
def name(self): def name(self):
""" Returns the name. """ """Return the thermostat."""
return self._name return self._name
@property @property
def unit_of_measurement(self): def unit_of_measurement(self):
""" Returns the unit of measurement. """ """Return the unit of measurement."""
return self._unit_of_measurement return self._unit_of_measurement
@property @property
def current_temperature(self): def current_temperature(self):
""" Returns the current temperature. """ """Return the current temperature."""
return self._current_temperature return self._current_temperature
@property @property
def target_temperature(self): def target_temperature(self):
""" Returns the temperature we try to reach. """ """Return the temperature we try to reach."""
return self._target_temperature return self._target_temperature
@property @property
def is_away_mode_on(self): def is_away_mode_on(self):
""" Returns if away mode is on. """ """Return if away mode is on."""
return self._away return self._away
def set_temperature(self, temperature): def set_temperature(self, temperature):
""" Set new target temperature. """ """Set new target temperature."""
self._target_temperature = temperature self._target_temperature = temperature
def turn_away_mode_on(self): def turn_away_mode_on(self):
""" Turns away mode on. """ """Turn away mode on."""
self._away = True self._away = True
def turn_away_mode_off(self): def turn_away_mode_off(self):
""" Turns away mode off. """ """Turn away mode off."""
self._away = False self._away = False