-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into add_occupancy_and_async
- Loading branch information
Showing
2 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
"""Support for Tahoma scenes.""" | ||
import logging | ||
from typing import Any | ||
|
||
from homeassistant.components.scene import Scene | ||
|
||
from .const import DOMAIN | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
async def async_setup_entry(hass, entry, async_add_entities): | ||
"""Set up the Tahoma scenes from a config entry.""" | ||
|
||
data = hass.data[DOMAIN][entry.entry_id] | ||
|
||
entities = [] | ||
controller = data.get("controller") | ||
|
||
for scene in data.get("scenes"): | ||
entities.append(TahomaScene(scene, controller)) | ||
|
||
async_add_entities(entities) | ||
|
||
|
||
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, **kwargs: Any) -> None: | ||
"""Activate the scene.""" | ||
self.controller.launch_action_group(self.tahoma_scene.oid) | ||
|
||
@property | ||
def unique_id(self) -> str: | ||
"""Return a unique ID.""" | ||
return 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} |