Support for Wink Switch and Light groups also fix fan speed selection (#8501)

* Support for Switch and Light groups, fix fan speed

* Fixed hound violations
This commit is contained in:
William Scanlon 2017-07-19 18:27:39 -04:00 committed by Pascal Vizeli
parent f1280d3edb
commit 84ebcd8a59
5 changed files with 24 additions and 7 deletions

View File

@ -9,7 +9,8 @@ import logging
from homeassistant.components.fan import (FanEntity, SPEED_HIGH,
SPEED_LOW, SPEED_MEDIUM,
STATE_UNKNOWN)
STATE_UNKNOWN, SUPPORT_SET_SPEED,
SUPPORT_DIRECTION)
from homeassistant.helpers.entity import ToggleEntity
from homeassistant.components.wink import WinkDevice, DOMAIN
@ -20,6 +21,8 @@ _LOGGER = logging.getLogger(__name__)
SPEED_LOWEST = 'lowest'
SPEED_AUTO = 'auto'
SUPPORTED_FEATURES = SUPPORT_DIRECTION + SUPPORT_SET_SPEED
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the Wink platform."""
@ -44,11 +47,11 @@ class WinkFanDevice(WinkDevice, FanEntity):
def set_speed(self: ToggleEntity, speed: str) -> None:
"""Set the speed of the fan."""
self.wink.set_fan_speed(speed)
self.wink.set_state(True, speed)
def turn_on(self: ToggleEntity, speed: str=None, **kwargs) -> None:
"""Turn on the fan."""
self.wink.set_state(True)
self.wink.set_state(True, speed)
def turn_off(self: ToggleEntity, **kwargs) -> None:
"""Turn off the fan."""
@ -96,3 +99,8 @@ class WinkFanDevice(WinkDevice, FanEntity):
if SPEED_HIGH in wink_supported_speeds:
supported_speeds.append(SPEED_HIGH)
return supported_speeds
@property
def supported_features(self: ToggleEntity) -> int:
"""Flag supported features."""
return SUPPORTED_FEATURES

View File

@ -28,6 +28,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
_id = light.object_id() + light.name()
if _id not in hass.data[DOMAIN]['unique_ids']:
add_devices([WinkLight(light, hass)])
for light in pywink.get_light_groups():
_id = light.object_id() + light.name()
if _id not in hass.data[DOMAIN]['unique_ids']:
add_devices([WinkLight(light, hass)])
class WinkLight(WinkDevice, Light):
@ -101,7 +105,7 @@ class WinkLight(WinkDevice, Light):
xyb = color_util.color_RGB_to_xy(*rgb_color)
state_kwargs['color_xy'] = xyb[0], xyb[1]
state_kwargs['brightness'] = xyb[2]
elif self.wink.supports_hue_saturation():
if self.wink.supports_hue_saturation():
hsv = colorsys.rgb_to_hsv(
rgb_color[0], rgb_color[1], rgb_color[2])
state_kwargs['color_hue_saturation'] = hsv[0], hsv[1]

View File

@ -32,6 +32,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
_id = sprinkler.object_id() + sprinkler.name()
if _id not in hass.data[DOMAIN]['unique_ids']:
add_devices([WinkToggleDevice(sprinkler, hass)])
for switch in pywink.get_binary_switch_groups():
_id = switch.object_id() + switch.name()
if _id not in hass.data[DOMAIN]['unique_ids']:
add_devices([WinkToggleDevice(switch, hass)])
class WinkToggleDevice(WinkDevice, ToggleEntity):

View File

@ -19,7 +19,7 @@ from homeassistant.const import (
from homeassistant.helpers.entity import Entity
import homeassistant.helpers.config_validation as cv
REQUIREMENTS = ['python-wink==1.2.4', 'pubnubsub-handler==1.0.2']
REQUIREMENTS = ['python-wink==1.3.1', 'pubnubsub-handler==1.0.2']
_LOGGER = logging.getLogger(__name__)
@ -105,7 +105,8 @@ def setup(hass, config):
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)
pywink.legacy_set_wink_credentials(email, password,
client_id, client_secret)
hass.data[DOMAIN]['oath'] = {"email": email,
"password": password,
"client_id": client_id,

View File

@ -755,7 +755,7 @@ python-twitch==1.3.0
python-vlc==1.1.2
# homeassistant.components.wink
python-wink==1.2.4
python-wink==1.3.1
# homeassistant.components.zwave
python_openzwave==0.4.0.31