Skip to content

Commit

Permalink
Update python-wink version and multiple wink fixes/updates. (#11833)
Browse files Browse the repository at this point in the history
  • Loading branch information
William Scanlon committed Jan 25, 2018
1 parent 3d9ff37 commit 5123487
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 10 deletions.
7 changes: 7 additions & 0 deletions homeassistant/components/binary_sensor/wink.py
Expand Up @@ -143,6 +143,13 @@ def device_state_attributes(self):
_attributes['update_needed'] = self.wink.update_needed()
_attributes['firmware_version'] = self.wink.firmware_version()
_attributes['pairing_mode'] = self.wink.pairing_mode()
_kidde_code = self.wink.kidde_radio_code()
if _kidde_code is not None:
# The service call to set the Kidde code
# takes a string of 1s and 0s so it makes
# sense to display it to the user that way
_formatted_kidde_code = "{:b}".format(_kidde_code).zfill(8)
_attributes['kidde_radio_code'] = _formatted_kidde_code
return _attributes


Expand Down
18 changes: 18 additions & 0 deletions homeassistant/components/climate/wink.py
Expand Up @@ -30,6 +30,8 @@
ATTR_SMART_TEMPERATURE = 'smart_temperature'
ATTR_TOTAL_CONSUMPTION = 'total_consumption'
ATTR_VACATION_MODE = 'vacation_mode'
ATTR_HEAT_ON = 'heat_on'
ATTR_COOL_ON = 'cool_on'

DEPENDENCIES = ['wink']

Expand Down Expand Up @@ -131,6 +133,12 @@ def device_state_attributes(self):
if self.eco_target:
data[ATTR_ECO_TARGET] = self.eco_target

if self.heat_on:
data[ATTR_HEAT_ON] = self.heat_on

if self.cool_on:
data[ATTR_COOL_ON] = self.cool_on

current_humidity = self.current_humidity
if current_humidity is not None:
data[ATTR_CURRENT_HUMIDITY] = current_humidity
Expand Down Expand Up @@ -174,6 +182,16 @@ def occupied(self):
"""Return status of if the thermostat has detected occupancy."""
return self.wink.occupied()

@property
def heat_on(self):
"""Return whether or not the heat is actually heating."""
return self.wink.heat_on()

@property
def cool_on(self):
"""Return whether or not the heat is actually heating."""
return self.wink.heat_on()

@property
def current_operation(self):
"""Return current operation ie. heat, cool, idle."""
Expand Down
17 changes: 10 additions & 7 deletions homeassistant/components/cover/wink.py
Expand Up @@ -6,8 +6,8 @@
"""
import asyncio

from homeassistant.components.cover import CoverDevice
from homeassistant.components.wink import DOMAIN, WinkDevice
from homeassistant.components.cover import CoverDevice, STATE_UNKNOWN
from homeassistant.components.wink import WinkDevice, DOMAIN

DEPENDENCIES = ['wink']

Expand Down Expand Up @@ -35,21 +35,24 @@ def async_added_to_hass(self):
self.hass.data[DOMAIN]['entities']['cover'].append(self)

def close_cover(self, **kwargs):
"""Close the shade."""
"""Close the cover."""
self.wink.set_state(0)

def open_cover(self, **kwargs):
"""Open the shade."""
"""Open the cover."""
self.wink.set_state(1)

def set_cover_position(self, position, **kwargs):
"""Move the roller shutter to a specific position."""
"""Move the cover shutter to a specific position."""
self.wink.set_state(float(position)/100)

@property
def current_cover_position(self):
"""Return the current position of roller shutter."""
return int(self.wink.state()*100)
"""Return the current position of cover shutter."""
if self.wink.state() is not None:
return int(self.wink.state()*100)
else:
return STATE_UNKNOWN

@property
def is_closed(self):
Expand Down
6 changes: 5 additions & 1 deletion homeassistant/components/wink/__init__.py
Expand Up @@ -26,7 +26,7 @@
from homeassistant.helpers.event import track_time_interval
from homeassistant.util.json import load_json, save_json

REQUIREMENTS = ['python-wink==1.7.1', 'pubnubsub-handler==1.0.2']
REQUIREMENTS = ['python-wink==1.7.3', 'pubnubsub-handler==1.0.2']

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -357,6 +357,10 @@ def save_credentials(event):

hass.bus.listen(EVENT_HOMEASSISTANT_STOP, save_credentials)

# Save the users potentially updated oauth credentials at a regular
# interval to prevent them from being expired after a HA reboot.
track_time_interval(hass, save_credentials, timedelta(minutes=60))

def force_update(call):
"""Force all devices to poll the Wink API."""
_LOGGER.info("Refreshing Wink states from API")
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/wink/services.yaml
Expand Up @@ -10,7 +10,7 @@ pair_new_device:
description: One of ["zigbee", "zwave", "zwave_exclusion", "zwave_network_rediscovery", "lutron", "bluetooth", "kidde"].
example: 'zigbee'
kidde_radio_code:
description: 'A string of 8 1s and 0s one for each dip switch on the kidde device left --> right = 1 --> 8'
description: 'A string of 8 1s and 0s one for each dip switch on the kidde device left --> right = 1 --> 8. Down = 1 and Up = 0'
example: '10101010'

rename_wink_device:
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Expand Up @@ -948,7 +948,7 @@ python-velbus==2.0.11
python-vlc==1.1.2

# homeassistant.components.wink
python-wink==1.7.1
python-wink==1.7.3

# homeassistant.components.sensor.swiss_public_transport
python_opendata_transport==0.0.3
Expand Down

0 comments on commit 5123487

Please sign in to comment.