Support for Wink lock user codes (#2525)
This commit is contained in:
parent
63356fb5eb
commit
3246b58437
9 changed files with 25 additions and 12 deletions
|
@ -5,6 +5,7 @@ For more details about this platform, please refer to the documentation at
|
||||||
at https://home-assistant.io/components/sensor.wink/
|
at https://home-assistant.io/components/sensor.wink/
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
import json
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import BinarySensorDevice
|
from homeassistant.components.binary_sensor import BinarySensorDevice
|
||||||
from homeassistant.components.sensor.wink import WinkDevice
|
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.helpers.entity import Entity
|
||||||
from homeassistant.loader import get_component
|
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
|
# These are the available sensors mapped to binary_sensor class
|
||||||
SENSOR_TYPES = {
|
SENSOR_TYPES = {
|
||||||
|
@ -42,6 +43,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
if sensor.capability() in SENSOR_TYPES:
|
if sensor.capability() in SENSOR_TYPES:
|
||||||
add_devices([WinkBinarySensorDevice(sensor)])
|
add_devices([WinkBinarySensorDevice(sensor)])
|
||||||
|
|
||||||
|
for key in pywink.get_keys():
|
||||||
|
add_devices([WinkBinarySensorDevice(key)])
|
||||||
|
|
||||||
|
|
||||||
class WinkBinarySensorDevice(WinkDevice, BinarySensorDevice, Entity):
|
class WinkBinarySensorDevice(WinkDevice, BinarySensorDevice, Entity):
|
||||||
"""Representation of a Wink binary sensor."""
|
"""Representation of a Wink binary sensor."""
|
||||||
|
@ -53,6 +57,14 @@ class WinkBinarySensorDevice(WinkDevice, BinarySensorDevice, Entity):
|
||||||
self._unit_of_measurement = self.wink.UNIT
|
self._unit_of_measurement = self.wink.UNIT
|
||||||
self.capability = self.wink.capability()
|
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
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
"""Return true if the binary sensor is on."""
|
"""Return true if the binary sensor is on."""
|
||||||
|
|
|
@ -10,7 +10,7 @@ from homeassistant.components.garage_door import GarageDoorDevice
|
||||||
from homeassistant.components.wink import WinkDevice
|
from homeassistant.components.wink import WinkDevice
|
||||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
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):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
|
|
|
@ -14,7 +14,7 @@ from homeassistant.util import color as color_util
|
||||||
from homeassistant.util.color import \
|
from homeassistant.util.color import \
|
||||||
color_temperature_mired_to_kelvin as mired_to_kelvin
|
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):
|
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||||
|
|
|
@ -10,7 +10,7 @@ from homeassistant.components.lock import LockDevice
|
||||||
from homeassistant.components.wink import WinkDevice
|
from homeassistant.components.wink import WinkDevice
|
||||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
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):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
|
|
|
@ -10,7 +10,7 @@ from homeassistant.components.rollershutter import RollershutterDevice
|
||||||
from homeassistant.components.wink import WinkDevice
|
from homeassistant.components.wink import WinkDevice
|
||||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
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):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
|
|
|
@ -12,7 +12,7 @@ from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.components.wink import WinkDevice
|
from homeassistant.components.wink import WinkDevice
|
||||||
from homeassistant.loader import get_component
|
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']
|
SENSOR_TYPES = ['temperature', 'humidity']
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ from homeassistant.components.wink import WinkDevice
|
||||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
from homeassistant.const import CONF_ACCESS_TOKEN
|
||||||
from homeassistant.helpers.entity import ToggleEntity
|
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):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
|
|
|
@ -12,7 +12,7 @@ from homeassistant.const import CONF_ACCESS_TOKEN, ATTR_BATTERY_LEVEL
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
DOMAIN = "wink"
|
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
|
SUBSCRIPTION_HANDLER = None
|
||||||
CHANNELS = []
|
CHANNELS = []
|
||||||
|
@ -29,7 +29,8 @@ def setup(hass, config):
|
||||||
from pubnub import Pubnub
|
from pubnub import Pubnub
|
||||||
pywink.set_bearer_token(config[DOMAIN][CONF_ACCESS_TOKEN])
|
pywink.set_bearer_token(config[DOMAIN][CONF_ACCESS_TOKEN])
|
||||||
global SUBSCRIPTION_HANDLER
|
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)
|
SUBSCRIPTION_HANDLER.set_heartbeat(120)
|
||||||
|
|
||||||
# Load components for the devices in the Wink that we support
|
# Load components for the devices in the Wink that we support
|
||||||
|
@ -58,7 +59,7 @@ class WinkDevice(Entity):
|
||||||
self.wink = wink
|
self.wink = wink
|
||||||
self._battery = self.wink.battery_level
|
self._battery = self.wink.battery_level
|
||||||
if self.wink.pubnub_channel in CHANNELS:
|
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.set_heartbeat(120)
|
||||||
pubnub.subscribe(self.wink.pubnub_channel,
|
pubnub.subscribe(self.wink.pubnub_channel,
|
||||||
self._pubnub_update,
|
self._pubnub_update,
|
||||||
|
|
|
@ -237,7 +237,7 @@ psutil==4.3.0
|
||||||
# homeassistant.components.rollershutter.wink
|
# homeassistant.components.rollershutter.wink
|
||||||
# homeassistant.components.sensor.wink
|
# homeassistant.components.sensor.wink
|
||||||
# homeassistant.components.switch.wink
|
# homeassistant.components.switch.wink
|
||||||
pubnub==3.7.6
|
pubnub==3.8.2
|
||||||
|
|
||||||
# homeassistant.components.notify.pushbullet
|
# homeassistant.components.notify.pushbullet
|
||||||
pushbullet.py==0.10.0
|
pushbullet.py==0.10.0
|
||||||
|
@ -340,7 +340,7 @@ python-twitch==1.2.0
|
||||||
# homeassistant.components.rollershutter.wink
|
# homeassistant.components.rollershutter.wink
|
||||||
# homeassistant.components.sensor.wink
|
# homeassistant.components.sensor.wink
|
||||||
# homeassistant.components.switch.wink
|
# homeassistant.components.switch.wink
|
||||||
python-wink==0.7.8
|
python-wink==0.7.10
|
||||||
|
|
||||||
# homeassistant.components.keyboard
|
# homeassistant.components.keyboard
|
||||||
pyuserinput==0.1.9
|
pyuserinput==0.1.9
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue