mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 14:57:09 +00:00
Add Tahoma scenes (#12498)
* add scenes to platform * add scene.tahoma * requires tahoma-api 0.0.12 * update requirements_all.txt * hound * fix pylint error
This commit is contained in:
parent
1b22f2d8b8
commit
daa00bc65a
48
homeassistant/components/scene/tahoma.py
Normal file
48
homeassistant/components/scene/tahoma.py
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
"""
|
||||||
|
Support for Tahoma scenes.
|
||||||
|
|
||||||
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/scene.tahoma/
|
||||||
|
"""
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from homeassistant.components.scene import Scene
|
||||||
|
from homeassistant.components.tahoma import (
|
||||||
|
DOMAIN as TAHOMA_DOMAIN)
|
||||||
|
|
||||||
|
DEPENDENCIES = ['tahoma']
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
|
"""Set up the Tahoma scenes."""
|
||||||
|
controller = hass.data[TAHOMA_DOMAIN]['controller']
|
||||||
|
scenes = []
|
||||||
|
for scene in hass.data[TAHOMA_DOMAIN]['scenes']:
|
||||||
|
scenes.append(TahomaScene(scene, controller))
|
||||||
|
add_devices(scenes, True)
|
||||||
|
|
||||||
|
|
||||||
|
class TahomaScene(Scene):
|
||||||
|
"""Representation of a Tahoma scene entity."""
|
||||||
|
|
||||||
|
def __init__(self, tahoma_scene, controller):
|
||||||
|
"""Initialize the scene."""
|
||||||
|
self.tahoma_scene = tahoma_scene
|
||||||
|
self.controller = controller
|
||||||
|
self._name = self.tahoma_scene.name
|
||||||
|
|
||||||
|
def activate(self):
|
||||||
|
"""Activate the scene."""
|
||||||
|
self.controller.launch_action_group(self.tahoma_scene.oid)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
"""Return the name of the scene."""
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_state_attributes(self):
|
||||||
|
"""Return the state attributes of the scene."""
|
||||||
|
return {'tahoma_scene_oid': self.tahoma_scene.oid}
|
@ -14,7 +14,7 @@ from homeassistant.helpers import discovery
|
|||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
REQUIREMENTS = ['tahoma-api==0.0.11']
|
REQUIREMENTS = ['tahoma-api==0.0.12']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ CONFIG_SCHEMA = vol.Schema({
|
|||||||
}, extra=vol.ALLOW_EXTRA)
|
}, extra=vol.ALLOW_EXTRA)
|
||||||
|
|
||||||
TAHOMA_COMPONENTS = [
|
TAHOMA_COMPONENTS = [
|
||||||
'sensor', 'cover'
|
'scene', 'sensor', 'cover'
|
||||||
]
|
]
|
||||||
|
|
||||||
TAHOMA_TYPES = {
|
TAHOMA_TYPES = {
|
||||||
@ -63,13 +63,15 @@ def setup(hass, config):
|
|||||||
try:
|
try:
|
||||||
api.get_setup()
|
api.get_setup()
|
||||||
devices = api.get_devices()
|
devices = api.get_devices()
|
||||||
|
scenes = api.get_action_groups()
|
||||||
except RequestException:
|
except RequestException:
|
||||||
_LOGGER.exception("Error when getting devices from the Tahoma API")
|
_LOGGER.exception("Error when getting devices from the Tahoma API")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
hass.data[DOMAIN] = {
|
hass.data[DOMAIN] = {
|
||||||
'controller': api,
|
'controller': api,
|
||||||
'devices': defaultdict(list)
|
'devices': defaultdict(list),
|
||||||
|
'scenes': []
|
||||||
}
|
}
|
||||||
|
|
||||||
for device in devices:
|
for device in devices:
|
||||||
@ -82,6 +84,9 @@ def setup(hass, config):
|
|||||||
continue
|
continue
|
||||||
hass.data[DOMAIN]['devices'][device_type].append(_device)
|
hass.data[DOMAIN]['devices'][device_type].append(_device)
|
||||||
|
|
||||||
|
for scene in scenes:
|
||||||
|
hass.data[DOMAIN]['scenes'].append(scene)
|
||||||
|
|
||||||
for component in TAHOMA_COMPONENTS:
|
for component in TAHOMA_COMPONENTS:
|
||||||
discovery.load_platform(hass, component, DOMAIN, {}, config)
|
discovery.load_platform(hass, component, DOMAIN, {}, config)
|
||||||
|
|
||||||
|
@ -1159,7 +1159,7 @@ steamodd==4.21
|
|||||||
suds-py3==1.3.3.0
|
suds-py3==1.3.3.0
|
||||||
|
|
||||||
# homeassistant.components.tahoma
|
# homeassistant.components.tahoma
|
||||||
tahoma-api==0.0.11
|
tahoma-api==0.0.12
|
||||||
|
|
||||||
# homeassistant.components.sensor.tank_utility
|
# homeassistant.components.sensor.tank_utility
|
||||||
tank_utility==1.4.0
|
tank_utility==1.4.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user