Merge pull request #1570 from w1ll1am23/wink_availability

Added available method to all wink components
This commit is contained in:
Paulus Schoutsen 2016-03-17 21:00:42 -07:00
commit a1f8466754
8 changed files with 38 additions and 8 deletions

View file

@ -10,7 +10,7 @@ from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.const import CONF_ACCESS_TOKEN from homeassistant.const import CONF_ACCESS_TOKEN
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
REQUIREMENTS = ['python-wink==0.6.3'] REQUIREMENTS = ['python-wink==0.6.4']
# These are the available sensors mapped to binary_sensor class # These are the available sensors mapped to binary_sensor class
SENSOR_TYPES = { SENSOR_TYPES = {
@ -77,6 +77,11 @@ class WinkBinarySensorDevice(BinarySensorDevice, Entity):
"""Return the name of the sensor if any.""" """Return the name of the sensor if any."""
return self.wink.name() return self.wink.name()
@property
def available(self):
"""True if connection == True."""
return self.wink.available
def update(self): def update(self):
"""Update state of the sensor.""" """Update state of the sensor."""
self.wink.update_state() self.wink.update_state()

View file

@ -9,7 +9,7 @@ import logging
from homeassistant.components.garage_door import GarageDoorDevice from homeassistant.components.garage_door import GarageDoorDevice
from homeassistant.const import CONF_ACCESS_TOKEN from homeassistant.const import CONF_ACCESS_TOKEN
REQUIREMENTS = ['python-wink==0.6.3'] REQUIREMENTS = ['python-wink==0.6.4']
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
@ -57,6 +57,11 @@ class WinkGarageDoorDevice(GarageDoorDevice):
"""Return true if door is closed.""" """Return true if door is closed."""
return self.wink.state() == 0 return self.wink.state() == 0
@property
def available(self):
"""True if connection == True."""
return self.wink.available
def close_door(self): def close_door(self):
"""Close the door.""" """Close the door."""
self.wink.set_state(0) self.wink.set_state(0)

View file

@ -9,7 +9,7 @@ import logging
from homeassistant.components.light import ATTR_BRIGHTNESS, Light from homeassistant.components.light import ATTR_BRIGHTNESS, Light
from homeassistant.const import CONF_ACCESS_TOKEN from homeassistant.const import CONF_ACCESS_TOKEN
REQUIREMENTS = ['python-wink==0.6.3'] REQUIREMENTS = ['python-wink==0.6.4']
def setup_platform(hass, config, add_devices_callback, discovery_info=None): def setup_platform(hass, config, add_devices_callback, discovery_info=None):
@ -58,6 +58,11 @@ class WinkLight(Light):
"""Return the brightness of the light.""" """Return the brightness of the light."""
return int(self.wink.brightness() * 255) return int(self.wink.brightness() * 255)
@property
def available(self):
"""True if connection == True."""
return self.wink.available
# pylint: disable=too-few-public-methods # pylint: disable=too-few-public-methods
def turn_on(self, **kwargs): def turn_on(self, **kwargs):
"""Turn the switch on.""" """Turn the switch on."""

View file

@ -9,7 +9,7 @@ import logging
from homeassistant.components.lock import LockDevice from homeassistant.components.lock import LockDevice
from homeassistant.const import CONF_ACCESS_TOKEN from homeassistant.const import CONF_ACCESS_TOKEN
REQUIREMENTS = ['python-wink==0.6.3'] REQUIREMENTS = ['python-wink==0.6.4']
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
@ -56,6 +56,11 @@ class WinkLockDevice(LockDevice):
"""Return true if device is locked.""" """Return true if device is locked."""
return self.wink.state() return self.wink.state()
@property
def available(self):
"""True if connection == True."""
return self.wink.available
def lock(self, **kwargs): def lock(self, **kwargs):
"""Lock the device.""" """Lock the device."""
self.wink.set_state(True) self.wink.set_state(True)

View file

@ -10,7 +10,7 @@ from homeassistant.const import (CONF_ACCESS_TOKEN, STATE_CLOSED,
STATE_OPEN, TEMP_CELCIUS) STATE_OPEN, TEMP_CELCIUS)
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
REQUIREMENTS = ['python-wink==0.6.3'] REQUIREMENTS = ['python-wink==0.6.4']
SENSOR_TYPES = ['temperature', 'humidity'] SENSOR_TYPES = ['temperature', 'humidity']
@ -74,6 +74,11 @@ class WinkSensorDevice(Entity):
"""Return the name of the sensor if any.""" """Return the name of the sensor if any."""
return self.wink.name() return self.wink.name()
@property
def available(self):
"""True if connection == True."""
return self.wink.available
def update(self): def update(self):
"""Update state of the sensor.""" """Update state of the sensor."""
self.wink.update_state() self.wink.update_state()

View file

@ -9,7 +9,7 @@ import logging
from homeassistant.components.wink import WinkToggleDevice from homeassistant.components.wink import WinkToggleDevice
from homeassistant.const import CONF_ACCESS_TOKEN from homeassistant.const import CONF_ACCESS_TOKEN
REQUIREMENTS = ['python-wink==0.6.3'] REQUIREMENTS = ['python-wink==0.6.4']
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):

View file

@ -15,7 +15,7 @@ from homeassistant.helpers.entity import ToggleEntity
from homeassistant.loader import get_component from homeassistant.loader import get_component
DOMAIN = "wink" DOMAIN = "wink"
REQUIREMENTS = ['python-wink==0.6.3'] REQUIREMENTS = ['python-wink==0.6.4']
DISCOVER_LIGHTS = "wink.lights" DISCOVER_LIGHTS = "wink.lights"
DISCOVER_SWITCHES = "wink.switches" DISCOVER_SWITCHES = "wink.switches"
@ -84,6 +84,11 @@ class WinkToggleDevice(ToggleEntity):
"""Return true if device is on.""" """Return true if device is on."""
return self.wink.state() return self.wink.state()
@property
def available(self):
"""True if connection == True."""
return self.wink.available
def turn_on(self, **kwargs): def turn_on(self, **kwargs):
"""Turn the device on.""" """Turn the device on."""
self.wink.set_state(True) self.wink.set_state(True)

View file

@ -213,7 +213,7 @@ python-twitch==1.2.0
# homeassistant.components.lock.wink # homeassistant.components.lock.wink
# homeassistant.components.sensor.wink # homeassistant.components.sensor.wink
# homeassistant.components.switch.wink # homeassistant.components.switch.wink
python-wink==0.6.3 python-wink==0.6.4
# homeassistant.components.keyboard # homeassistant.components.keyboard
pyuserinput==0.1.9 pyuserinput==0.1.9