Support for Wink lock user codes (#2525)

This commit is contained in:
William Scanlon 2016-07-14 16:31:16 -04:00 committed by Paulus Schoutsen
parent 63356fb5eb
commit 3246b58437
9 changed files with 25 additions and 12 deletions

View File

@ -5,6 +5,7 @@ For more details about this platform, please refer to the documentation at
at https://home-assistant.io/components/sensor.wink/
"""
import logging
import json
from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.components.sensor.wink import WinkDevice
@ -12,7 +13,7 @@ from homeassistant.const import CONF_ACCESS_TOKEN
from homeassistant.helpers.entity import Entity
from homeassistant.loader import get_component
REQUIREMENTS = ['python-wink==0.7.8', 'pubnub==3.7.6']
REQUIREMENTS = ['python-wink==0.7.10', 'pubnub==3.8.2']
# These are the available sensors mapped to binary_sensor class
SENSOR_TYPES = {
@ -42,6 +43,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
if sensor.capability() in SENSOR_TYPES:
add_devices([WinkBinarySensorDevice(sensor)])
for key in pywink.get_keys():
add_devices([WinkBinarySensorDevice(key)])
class WinkBinarySensorDevice(WinkDevice, BinarySensorDevice, Entity):
"""Representation of a Wink binary sensor."""
@ -53,6 +57,14 @@ class WinkBinarySensorDevice(WinkDevice, BinarySensorDevice, Entity):
self._unit_of_measurement = self.wink.UNIT
self.capability = self.wink.capability()
def _pubnub_update(self, message, channel):
if 'data' in message:
json_data = json.dumps(message.get('data'))
else:
json_data = message
self.wink.pubnub_update(json.loads(json_data))
self.update_ha_state()
@property
def is_on(self):
"""Return true if the binary sensor is on."""

View File

@ -10,7 +10,7 @@ from homeassistant.components.garage_door import GarageDoorDevice
from homeassistant.components.wink import WinkDevice
from homeassistant.const import CONF_ACCESS_TOKEN
REQUIREMENTS = ['python-wink==0.7.8', 'pubnub==3.7.6']
REQUIREMENTS = ['python-wink==0.7.10', 'pubnub==3.8.2']
def setup_platform(hass, config, add_devices, discovery_info=None):

View File

@ -14,7 +14,7 @@ from homeassistant.util import color as color_util
from homeassistant.util.color import \
color_temperature_mired_to_kelvin as mired_to_kelvin
REQUIREMENTS = ['python-wink==0.7.8', 'pubnub==3.7.6']
REQUIREMENTS = ['python-wink==0.7.10', 'pubnub==3.8.2']
def setup_platform(hass, config, add_devices_callback, discovery_info=None):

View File

@ -10,7 +10,7 @@ from homeassistant.components.lock import LockDevice
from homeassistant.components.wink import WinkDevice
from homeassistant.const import CONF_ACCESS_TOKEN
REQUIREMENTS = ['python-wink==0.7.8', 'pubnub==3.7.6']
REQUIREMENTS = ['python-wink==0.7.10', 'pubnub==3.8.2']
def setup_platform(hass, config, add_devices, discovery_info=None):

View File

@ -10,7 +10,7 @@ from homeassistant.components.rollershutter import RollershutterDevice
from homeassistant.components.wink import WinkDevice
from homeassistant.const import CONF_ACCESS_TOKEN
REQUIREMENTS = ['python-wink==0.7.8', 'pubnub==3.7.6']
REQUIREMENTS = ['python-wink==0.7.10', 'pubnub==3.8.2']
def setup_platform(hass, config, add_devices, discovery_info=None):

View File

@ -12,7 +12,7 @@ from homeassistant.helpers.entity import Entity
from homeassistant.components.wink import WinkDevice
from homeassistant.loader import get_component
REQUIREMENTS = ['python-wink==0.7.8', 'pubnub==3.7.6']
REQUIREMENTS = ['python-wink==0.7.10', 'pubnub==3.8.2']
SENSOR_TYPES = ['temperature', 'humidity']

View File

@ -10,7 +10,7 @@ from homeassistant.components.wink import WinkDevice
from homeassistant.const import CONF_ACCESS_TOKEN
from homeassistant.helpers.entity import ToggleEntity
REQUIREMENTS = ['python-wink==0.7.8', 'pubnub==3.7.6']
REQUIREMENTS = ['python-wink==0.7.10', 'pubnub==3.8.2']
def setup_platform(hass, config, add_devices, discovery_info=None):

View File

@ -12,7 +12,7 @@ from homeassistant.const import CONF_ACCESS_TOKEN, ATTR_BATTERY_LEVEL
from homeassistant.helpers.entity import Entity
DOMAIN = "wink"
REQUIREMENTS = ['python-wink==0.7.8', 'pubnub==3.7.6']
REQUIREMENTS = ['python-wink==0.7.10', 'pubnub==3.8.2']
SUBSCRIPTION_HANDLER = None
CHANNELS = []
@ -29,7 +29,8 @@ def setup(hass, config):
from pubnub import Pubnub
pywink.set_bearer_token(config[DOMAIN][CONF_ACCESS_TOKEN])
global SUBSCRIPTION_HANDLER
SUBSCRIPTION_HANDLER = Pubnub("N/A", pywink.get_subscription_key())
SUBSCRIPTION_HANDLER = Pubnub("N/A", pywink.get_subscription_key(),
ssl_on=True)
SUBSCRIPTION_HANDLER.set_heartbeat(120)
# Load components for the devices in the Wink that we support
@ -58,7 +59,7 @@ class WinkDevice(Entity):
self.wink = wink
self._battery = self.wink.battery_level
if self.wink.pubnub_channel in CHANNELS:
pubnub = Pubnub("N/A", self.wink.pubnub_key)
pubnub = Pubnub("N/A", self.wink.pubnub_key, ssl_on=True)
pubnub.set_heartbeat(120)
pubnub.subscribe(self.wink.pubnub_channel,
self._pubnub_update,

View File

@ -237,7 +237,7 @@ psutil==4.3.0
# homeassistant.components.rollershutter.wink
# homeassistant.components.sensor.wink
# homeassistant.components.switch.wink
pubnub==3.7.6
pubnub==3.8.2
# homeassistant.components.notify.pushbullet
pushbullet.py==0.10.0
@ -340,7 +340,7 @@ python-twitch==1.2.0
# homeassistant.components.rollershutter.wink
# homeassistant.components.sensor.wink
# homeassistant.components.switch.wink
python-wink==0.7.8
python-wink==0.7.10
# homeassistant.components.keyboard
pyuserinput==0.1.9