2017-03-11 18:18:29 +00:00
|
|
|
"""
|
|
|
|
Support for Wink scenes.
|
|
|
|
|
|
|
|
For more details about this platform, please refer to the documentation at
|
|
|
|
https://home-assistant.io/components/scene.wink/
|
|
|
|
"""
|
2017-05-13 18:09:00 +00:00
|
|
|
import asyncio
|
2017-03-11 18:18:29 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
from homeassistant.components.scene import Scene
|
2018-01-21 06:35:38 +00:00
|
|
|
from homeassistant.components.wink import DOMAIN, WinkDevice
|
2017-03-11 18:18:29 +00:00
|
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
2018-01-21 06:35:38 +00:00
|
|
|
DEPENDENCIES = ['wink']
|
|
|
|
|
2017-03-11 18:18:29 +00:00
|
|
|
|
|
|
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
2017-05-02 16:18:47 +00:00
|
|
|
"""Set up the Wink platform."""
|
2017-03-11 18:18:29 +00:00
|
|
|
import pywink
|
|
|
|
|
|
|
|
for scene in pywink.get_scenes():
|
|
|
|
_id = scene.object_id() + scene.name()
|
|
|
|
if _id not in hass.data[DOMAIN]['unique_ids']:
|
|
|
|
add_devices([WinkScene(scene, hass)])
|
|
|
|
|
|
|
|
|
|
|
|
class WinkScene(WinkDevice, Scene):
|
|
|
|
"""Representation of a Wink shortcut/scene."""
|
|
|
|
|
|
|
|
def __init__(self, wink, hass):
|
|
|
|
"""Initialize the Wink device."""
|
|
|
|
super().__init__(wink, hass)
|
2017-05-13 18:09:00 +00:00
|
|
|
hass.data[DOMAIN]['entities']['scene'].append(self)
|
|
|
|
|
|
|
|
@asyncio.coroutine
|
|
|
|
def async_added_to_hass(self):
|
2018-01-21 06:35:38 +00:00
|
|
|
"""Call when entity is added to hass."""
|
2017-05-13 18:09:00 +00:00
|
|
|
self.hass.data[DOMAIN]['entities']['scene'].append(self)
|
2017-03-11 18:18:29 +00:00
|
|
|
|
2018-02-11 17:20:28 +00:00
|
|
|
def activate(self):
|
2017-03-11 18:18:29 +00:00
|
|
|
"""Activate the scene."""
|
|
|
|
self.wink.activate()
|