2019-02-13 20:21:14 +00:00
|
|
|
"""Support for Wink scenes."""
|
2017-03-11 18:18:29 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
from homeassistant.components.scene import Scene
|
2019-03-21 05:56:46 +00:00
|
|
|
|
|
|
|
from . import DOMAIN, WinkDevice
|
2017-03-11 18:18:29 +00:00
|
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
2018-08-24 14:37:30 +00:00
|
|
|
def setup_platform(hass, config, add_entities, 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']:
|
2018-08-24 14:37:30 +00:00
|
|
|
add_entities([WinkScene(scene, hass)])
|
2017-03-11 18:18:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
2018-10-01 06:56:50 +00:00
|
|
|
async 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()
|