Initial version wink component by @loghound
This commit is contained in:
1 parent
cd896627ea
commit
249cf244ca
4 files changed
+25
-56
No files matched your search
@@ -1,35 +1,26 @@
|
||||
""" Support for WeMo switchces. """
|
||||
import logging
|
||||
|
||||
import homeassistant as ha
|
||||
import homeassistant.external.wink.pywink as pywink
|
||||
|
||||
from homeassistant.helpers import ToggleDevice
|
||||
from homeassistant.const import ATTR_FRIENDLY_NAME
|
||||
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
def get_devices(hass, config):
|
||||
""" Find and return WeMo switches. """
|
||||
""" Find and return Wink switches. """
|
||||
token = config.get('access_token')
|
||||
|
||||
try:
|
||||
# Pylint does not play nice if not every folders has an __init__.py
|
||||
# pylint: disable=no-name-in-module, import-error
|
||||
import homeassistant.components.hubs.pywink.pywink as pywink
|
||||
except ImportError:
|
||||
logging.getLogger(__name__).exception((
|
||||
"Failed to import pywink. "
|
||||
"Did you maybe not run `git submodule init` "
|
||||
"and `git submodule update`?"))
|
||||
if token is None:
|
||||
logging.getLogger(__name__).error(
|
||||
"Missing wink access_token - "
|
||||
"get one at https://winkbearertoken.appspot.com/")
|
||||
return False
|
||||
|
||||
return []
|
||||
token = config["access_token"]
|
||||
pywink.set_bearer_token(token)
|
||||
|
||||
switches = pywink.get_switches()
|
||||
|
||||
|
||||
|
||||
# Filter out the switches and wrap in WemoSwitch object
|
||||
return [WinkSwitch(switch) for switch in switches]
|
||||
return [WinkSwitch(switch) for switch in pywink.get_switches()]
|
||||
|
||||
|
||||
class WinkSwitch(ToggleDevice):
|
||||
|
||||
Reference in new issue
Block a user