diff --git a/homeassistant/components/binary_sensor/wink.py b/homeassistant/components/binary_sensor/wink.py index 90d4f0a5cd5..dc1b7a005c0 100644 --- a/homeassistant/components/binary_sensor/wink.py +++ b/homeassistant/components/binary_sensor/wink.py @@ -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.""" diff --git a/homeassistant/components/garage_door/wink.py b/homeassistant/components/garage_door/wink.py index a99f35ecf5b..964711d679d 100644 --- a/homeassistant/components/garage_door/wink.py +++ b/homeassistant/components/garage_door/wink.py @@ -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): diff --git a/homeassistant/components/light/wink.py b/homeassistant/components/light/wink.py index 00e059fdc3e..4fb009d23f0 100644 --- a/homeassistant/components/light/wink.py +++ b/homeassistant/components/light/wink.py @@ -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): diff --git a/homeassistant/components/lock/wink.py b/homeassistant/components/lock/wink.py index c3232e67e03..7b3b5ef0fec 100644 --- a/homeassistant/components/lock/wink.py +++ b/homeassistant/components/lock/wink.py @@ -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): diff --git a/homeassistant/components/rollershutter/wink.py b/homeassistant/components/rollershutter/wink.py index 750e7cf654b..27bd90e0275 100644 --- a/homeassistant/components/rollershutter/wink.py +++ b/homeassistant/components/rollershutter/wink.py @@ -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): diff --git a/homeassistant/components/sensor/wink.py b/homeassistant/components/sensor/wink.py index 31bfba7b3bd..2b081a1934f 100644 --- a/homeassistant/components/sensor/wink.py +++ b/homeassistant/components/sensor/wink.py @@ -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'] diff --git a/homeassistant/components/switch/wink.py b/homeassistant/components/switch/wink.py index bb2183677ea..4f18d7d9456 100644 --- a/homeassistant/components/switch/wink.py +++ b/homeassistant/components/switch/wink.py @@ -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): diff --git a/homeassistant/components/wink.py b/homeassistant/components/wink.py index de65d3d664a..7be4c4d5cfe 100644 --- a/homeassistant/components/wink.py +++ b/homeassistant/components/wink.py @@ -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, diff --git a/requirements_all.txt b/requirements_all.txt index 3b9339cdfe2..61485b4d617 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -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