Fix PEP257 issues

This commit is contained in:
Fabian Affolter 2016-03-07 22:50:56 +01:00
parent f6bc1a4575
commit 1b8b2acb51
2 changed files with 15 additions and 16 deletions

View file

@ -1,7 +1,5 @@
"""
homeassistant.components.scene
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Allows users to set and activate scenes.
Allow users to set and activate scenes.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/scene/
@ -25,7 +23,7 @@ SceneConfig = namedtuple('SceneConfig', ['name', 'states'])
def activate(hass, entity_id=None):
""" Activate a scene. """
"""Activate a scene."""
data = {}
if entity_id:
@ -35,8 +33,7 @@ def activate(hass, entity_id=None):
def setup(hass, config):
""" Sets up scenes. """
"""Setup the scenes."""
logger = logging.getLogger(__name__)
# You are not allowed to mutate the original config so make a copy
@ -58,7 +55,7 @@ def setup(hass, config):
component.setup(config)
def handle_scene_service(service):
""" Handles calls to the switch services. """
"""Handle calls to the switch services."""
target_scenes = component.extract_from_service(service)
for scene in target_scenes:
@ -70,16 +67,18 @@ def setup(hass, config):
class Scene(Entity):
""" A scene is a group of entities and the states we want them to be. """
"""A scene is a group of entities and the states we want them to be."""
@property
def should_poll(self):
"""No polling needed."""
return False
@property
def state(self):
"""Return the state."""
return STATE
def activate(self):
""" Activates scene. Tries to get entities into requested state. """
"""Activate scene. Tries to get entities into requested state."""
raise NotImplementedError

View file

@ -1,6 +1,4 @@
"""
homeassistant.components.scene
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Allows users to set and activate scenes.
For more details about this component, please refer to the documentation at
@ -24,7 +22,7 @@ SceneConfig = namedtuple('SceneConfig', ['name', 'states'])
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up home assistant scene entries. """
"""Setup home assistant scene entries."""
scene_config = config.get("states")
if not isinstance(scene_config, list):
@ -37,7 +35,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
def _process_config(scene_config):
""" Process passed in config into a format to work with. """
"""Process passed in config into a format to work with."""
name = scene_config.get('name')
states = {}
@ -65,23 +63,25 @@ def _process_config(scene_config):
class HomeAssistantScene(Scene):
""" A scene is a group of entities and the states we want them to be. """
"""A scene is a group of entities and the states we want them to be."""
def __init__(self, hass, scene_config):
"""Initialize the scene."""
self.hass = hass
self.scene_config = scene_config
@property
def name(self):
"""Return the name of the scene."""
return self.scene_config.name
@property
def device_state_attributes(self):
""" Scene state attributes. """
"""Return the scene state attributes."""
return {
ATTR_ENTITY_ID: list(self.scene_config.states.keys()),
}
def activate(self):
""" Activates scene. Tries to get entities into requested state. """
"""Activate scene. Tries to get entities into requested state."""
reproduce_state(self.hass, self.scene_config.states.values(), True)