mirror of
https://github.com/home-assistant/core.git
synced 2025-05-13 18:39:14 +00:00
Fix PEP257 issues
This commit is contained in:
parent
f6bc1a4575
commit
1b8b2acb51
@ -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/
|
||||||
@ -25,7 +23,7 @@ SceneConfig = namedtuple('SceneConfig', ['name', 'states'])
|
|||||||
|
|
||||||
|
|
||||||
def activate(hass, entity_id=None):
|
def activate(hass, entity_id=None):
|
||||||
""" Activate a scene. """
|
"""Activate a scene."""
|
||||||
data = {}
|
data = {}
|
||||||
|
|
||||||
if entity_id:
|
if entity_id:
|
||||||
@ -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:
|
||||||
@ -70,16 +67,18 @@ def setup(hass, config):
|
|||||||
|
|
||||||
|
|
||||||
class Scene(Entity):
|
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
|
@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
|
||||||
|
@ -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):
|
||||||
@ -37,7 +35,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
|
|
||||||
|
|
||||||
def _process_config(scene_config):
|
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')
|
name = scene_config.get('name')
|
||||||
|
|
||||||
states = {}
|
states = {}
|
||||||
@ -65,23 +63,25 @@ def _process_config(scene_config):
|
|||||||
|
|
||||||
|
|
||||||
class HomeAssistantScene(Scene):
|
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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user