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 Allow users to set and activate scenes.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Allows users to set and activate scenes.
For more details about this component, please refer to the documentation at For more details about this component, please refer to the documentation at
https://home-assistant.io/components/scene/ https://home-assistant.io/components/scene/
@ -35,8 +33,7 @@ def activate(hass, entity_id=None):
def setup(hass, config): def setup(hass, config):
""" Sets up scenes. """ """Setup the scenes."""
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
# You are not allowed to mutate the original config so make a copy # You are not allowed to mutate the original config so make a copy
@ -58,7 +55,7 @@ def setup(hass, config):
component.setup(config) component.setup(config)
def handle_scene_service(service): def handle_scene_service(service):
""" Handles calls to the switch services. """ """Handle calls to the switch services."""
target_scenes = component.extract_from_service(service) target_scenes = component.extract_from_service(service)
for scene in target_scenes: for scene in target_scenes:
@ -74,12 +71,14 @@ class Scene(Entity):
@property @property
def should_poll(self): def should_poll(self):
"""No polling needed."""
return False return False
@property @property
def state(self): def state(self):
"""Return the state."""
return STATE return STATE
def activate(self): def activate(self):
""" Activates scene. Tries to get entities into requested state. """ """Activate scene. Tries to get entities into requested state."""
raise NotImplementedError raise NotImplementedError

View File

@ -1,6 +1,4 @@
""" """
homeassistant.components.scene
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Allows users to set and activate scenes. Allows users to set and activate scenes.
For more details about this component, please refer to the documentation at 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 # 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 home assistant scene entries. """ """Setup home assistant scene entries."""
scene_config = config.get("states") scene_config = config.get("states")
if not isinstance(scene_config, list): if not isinstance(scene_config, list):
@ -68,20 +66,22 @@ 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): def __init__(self, hass, scene_config):
"""Initialize the scene."""
self.hass = hass self.hass = hass
self.scene_config = scene_config self.scene_config = scene_config
@property @property
def name(self): def name(self):
"""Return the name of the scene."""
return self.scene_config.name return self.scene_config.name
@property @property
def device_state_attributes(self): def device_state_attributes(self):
""" Scene state attributes. """ """Return the scene state attributes."""
return { return {
ATTR_ENTITY_ID: list(self.scene_config.states.keys()), ATTR_ENTITY_ID: list(self.scene_config.states.keys()),
} }
def activate(self): 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) reproduce_state(self.hass, self.scene_config.states.values(), True)