Support for wink oath2 and relay sensors (#3496)
This commit is contained in:
parent
996d7cf1cd
commit
1f38e9fa57
4 changed files with 57 additions and 14 deletions
|
@ -20,7 +20,8 @@ SENSOR_TYPES = {
|
|||
"vibration": "vibration",
|
||||
"loudness": "sound",
|
||||
"liquid_detected": "moisture",
|
||||
"motion": "motion"
|
||||
"motion": "motion",
|
||||
"presence": "occupancy"
|
||||
}
|
||||
|
||||
|
||||
|
@ -58,17 +59,21 @@ class WinkBinarySensorDevice(WinkDevice, BinarySensorDevice, Entity):
|
|||
def is_on(self):
|
||||
"""Return true if the binary sensor is on."""
|
||||
if self.capability == "loudness":
|
||||
return self.wink.loudness_boolean()
|
||||
state = self.wink.loudness_boolean()
|
||||
elif self.capability == "vibration":
|
||||
return self.wink.vibration_boolean()
|
||||
state = self.wink.vibration_boolean()
|
||||
elif self.capability == "brightness":
|
||||
return self.wink.brightness_boolean()
|
||||
state = self.wink.brightness_boolean()
|
||||
elif self.capability == "liquid_detected":
|
||||
return self.wink.liquid_boolean()
|
||||
state = self.wink.liquid_boolean()
|
||||
elif self.capability == "motion":
|
||||
return self.wink.motion_boolean()
|
||||
state = self.wink.motion_boolean()
|
||||
elif self.capability == "presence":
|
||||
state = self.wink.presence_boolean()
|
||||
else:
|
||||
return self.wink.state()
|
||||
state = self.wink.state()
|
||||
|
||||
return state
|
||||
|
||||
@property
|
||||
def sensor_class(self):
|
||||
|
|
|
@ -14,7 +14,7 @@ from homeassistant.loader import get_component
|
|||
|
||||
DEPENDENCIES = ['wink']
|
||||
|
||||
SENSOR_TYPES = ['temperature', 'humidity', 'balance']
|
||||
SENSOR_TYPES = ['temperature', 'humidity', 'balance', 'proximity']
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
@ -58,6 +58,8 @@ class WinkSensorDevice(WinkDevice, Entity):
|
|||
return round(self.wink.temperature_float(), 1)
|
||||
elif self.capability == "balance":
|
||||
return round(self.wink.balance() / 100, 2)
|
||||
elif self.capability == "proximity":
|
||||
return self.wink.proximity_float()
|
||||
else:
|
||||
return STATE_OPEN if self.is_open else STATE_CLOSED
|
||||
|
||||
|
|
|
@ -10,11 +10,12 @@ import json
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.helpers import discovery
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN, ATTR_BATTERY_LEVEL
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN, ATTR_BATTERY_LEVEL, \
|
||||
CONF_EMAIL, CONF_PASSWORD
|
||||
from homeassistant.helpers.entity import Entity
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
REQUIREMENTS = ['python-wink==0.7.15', 'pubnub==3.8.2']
|
||||
REQUIREMENTS = ['python-wink==0.8.0', 'pubnub==3.8.2']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -23,19 +24,54 @@ CHANNELS = []
|
|||
DOMAIN = 'wink'
|
||||
|
||||
SUBSCRIPTION_HANDLER = None
|
||||
CONF_CLIENT_ID = 'client_id'
|
||||
CONF_CLIENT_SECRET = 'client_secret'
|
||||
CONF_USER_AGENT = 'user_agent'
|
||||
CONF_OATH = 'oath'
|
||||
CONF_DEFINED_BOTH_MSG = 'Remove access token to use oath2.'
|
||||
CONF_MISSING_OATH_MSG = 'Missing oath2 credentials.'
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema({
|
||||
DOMAIN: vol.Schema({
|
||||
vol.Required(CONF_ACCESS_TOKEN): cv.string,
|
||||
}),
|
||||
vol.Inclusive(CONF_EMAIL, CONF_OATH,
|
||||
msg=CONF_MISSING_OATH_MSG): cv.string,
|
||||
vol.Inclusive(CONF_PASSWORD, CONF_OATH,
|
||||
msg=CONF_MISSING_OATH_MSG): cv.string,
|
||||
vol.Inclusive(CONF_CLIENT_ID, CONF_OATH,
|
||||
msg=CONF_MISSING_OATH_MSG): cv.string,
|
||||
vol.Inclusive(CONF_CLIENT_SECRET, CONF_OATH,
|
||||
msg=CONF_MISSING_OATH_MSG): cv.string,
|
||||
vol.Exclusive(CONF_EMAIL, CONF_OATH,
|
||||
msg=CONF_DEFINED_BOTH_MSG): cv.string,
|
||||
vol.Exclusive(CONF_ACCESS_TOKEN, CONF_OATH,
|
||||
msg=CONF_DEFINED_BOTH_MSG): cv.string,
|
||||
vol.Optional(CONF_USER_AGENT, default=None): cv.string
|
||||
})
|
||||
}, extra=vol.ALLOW_EXTRA)
|
||||
|
||||
|
||||
def setup(hass, config):
|
||||
"""Setup the Wink component."""
|
||||
import pywink
|
||||
|
||||
user_agent = config[DOMAIN][CONF_USER_AGENT]
|
||||
|
||||
if user_agent:
|
||||
pywink.set_user_agent(user_agent)
|
||||
|
||||
from pubnub import Pubnub
|
||||
pywink.set_bearer_token(config[DOMAIN][CONF_ACCESS_TOKEN])
|
||||
access_token = config[DOMAIN].get(CONF_ACCESS_TOKEN)
|
||||
|
||||
if access_token:
|
||||
pywink.set_bearer_token(access_token)
|
||||
else:
|
||||
email = config[DOMAIN][CONF_EMAIL]
|
||||
password = config[DOMAIN][CONF_PASSWORD]
|
||||
client_id = config[DOMAIN]['client_id']
|
||||
client_secret = config[DOMAIN]['client_secret']
|
||||
pywink.set_wink_credentials(email, password, client_id,
|
||||
client_secret)
|
||||
|
||||
global SUBSCRIPTION_HANDLER
|
||||
SUBSCRIPTION_HANDLER = Pubnub(
|
||||
'N/A', pywink.get_subscription_key(), ssl_on=True)
|
||||
|
|
|
@ -396,7 +396,7 @@ python-telegram-bot==5.1.0
|
|||
python-twitch==1.3.0
|
||||
|
||||
# homeassistant.components.wink
|
||||
python-wink==0.7.15
|
||||
python-wink==0.8.0
|
||||
|
||||
# homeassistant.components.keyboard
|
||||
# pyuserinput==0.1.11
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue