Skip to content

Commit

Permalink
Merge pull request home-assistant#5384 from home-assistant/release-0-…
Browse files Browse the repository at this point in the history
…36-1

Release 0 36 1
  • Loading branch information
balloob authored Jan 17, 2017
2 parents c21172d + 4603cf4 commit 4d96b12
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 43 deletions.
4 changes: 3 additions & 1 deletion homeassistant/components/climate/eq3btsmart.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import homeassistant.helpers.config_validation as cv

REQUIREMENTS = ['python-eq3bt==0.1.2']
REQUIREMENTS = ['python-eq3bt==0.1.4']

_LOGGER = logging.getLogger(__name__)

Expand All @@ -29,6 +29,7 @@
ATTR_STATE_VALVE = "valve"
ATTR_STATE_LOCKED = "is_locked"
ATTR_STATE_LOW_BAT = "low_battery"
ATTR_STATE_AWAY_END = "away_end"

DEVICE_SCHEMA = vol.Schema({
vol.Required(CONF_MAC): cv.string,
Expand Down Expand Up @@ -152,6 +153,7 @@ def device_state_attributes(self):
ATTR_STATE_LOW_BAT: self._thermostat.low_battery,
ATTR_STATE_VALVE: self._thermostat.valve_state,
ATTR_STATE_WINDOW_OPEN: self._thermostat.window_open,
ATTR_STATE_AWAY_END: self._thermostat.away_end,
}

return dev_specific
Expand Down
14 changes: 5 additions & 9 deletions homeassistant/components/device_tracker/bluetooth_le_tracker.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
"""Tracking for bluetooth low energy devices."""
import logging
from datetime import timedelta

import voluptuous as vol
from homeassistant.helpers.event import track_point_in_utc_time
from homeassistant.components.device_tracker import (
YAML_DEVICES, CONF_TRACK_NEW, CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL,
PLATFORM_SCHEMA, load_config, DEFAULT_TRACK_NEW
PLATFORM_SCHEMA, load_config
)
import homeassistant.util as util
import homeassistant.util.dt as dt_util
import homeassistant.helpers.config_validation as cv

Expand Down Expand Up @@ -86,14 +84,13 @@ def discover_ble_devices():

# if track new devices is true discover new devices
# on every scan.
track_new = util.convert(config.get(CONF_TRACK_NEW), bool,
DEFAULT_TRACK_NEW)
track_new = config.get(CONF_TRACK_NEW)

if not devs_to_track and not track_new:
_LOGGER.warning("No Bluetooth LE devices to track!")
return False

interval = util.convert(config.get(CONF_SCAN_INTERVAL), int,
DEFAULT_SCAN_INTERVAL)
interval = config.get(CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL)

def update_ble(now):
"""Lookup Bluetooth LE devices and update status."""
Expand All @@ -113,8 +110,7 @@ def update_ble(now):
_LOGGER.info("Discovered Bluetooth LE device %s", address)
see_device(address, devs[address], new_device=True)

track_point_in_utc_time(hass, update_ble,
now + timedelta(seconds=interval))
track_point_in_utc_time(hass, update_ble, now + interval)

update_ble(dt_util.utcnow())

Expand Down
4 changes: 1 addition & 3 deletions homeassistant/components/device_tracker/bluetooth_tracker.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Tracking for bluetooth devices."""
import logging
from datetime import timedelta

import voluptuous as vol

Expand Down Expand Up @@ -83,8 +82,7 @@ def update_bluetooth(now):
see_device((mac, result))
except bluetooth.BluetoothError:
_LOGGER.exception('Error looking up bluetooth device!')
track_point_in_utc_time(hass, update_bluetooth,
now + timedelta(seconds=interval))
track_point_in_utc_time(hass, update_bluetooth, now + interval)

update_bluetooth(dt_util.utcnow())

Expand Down
17 changes: 7 additions & 10 deletions homeassistant/components/device_tracker/upc_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ def async_scan_devices(self):
return []

raw = yield from self._async_ws_function(CMD_DEVICES)
xml_root = ET.fromstring(raw)
if raw is None:
_LOGGER.warning("Can't read device from %s", self.host)
return

xml_root = ET.fromstring(raw)
return [mac.text for mac in xml_root.iter('MACAddr')]

@asyncio.coroutine
Expand All @@ -94,7 +97,8 @@ def async_login(self):
"http://{}/common_page/login.html".format(self.host)
)

self.token = self._async_get_token()
yield from response.text()
self.token = response.cookies['sessionToken'].value

# login
data = yield from self._async_ws_function(CMD_LOGIN, {
Expand Down Expand Up @@ -144,7 +148,7 @@ def _async_ws_function(self, function, additional_form=None):

# load data, store token for next request
raw = yield from response.text()
self.token = self._async_get_token()
self.token = response.cookies['sessionToken'].value

return raw

Expand All @@ -155,10 +159,3 @@ def _async_ws_function(self, function, additional_form=None):
finally:
if response is not None:
yield from response.release()

def _async_get_token(self):
"""Extract token from cookies."""
cookie_manager = self.websession.cookie_jar.filter_cookies(
"http://{}".format(self.host))

return cookie_manager.get('sessionToken')
5 changes: 2 additions & 3 deletions homeassistant/components/device_tracker/volvooncall.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def setup_scanner(hass, config, see):
config.get(CONF_USERNAME),
config.get(CONF_PASSWORD))

interval = max(MIN_TIME_BETWEEN_SCANS.seconds,
interval = max(MIN_TIME_BETWEEN_SCANS,
config.get(CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL))

def _see_vehicle(vehicle):
Expand Down Expand Up @@ -91,8 +91,7 @@ def update(now):

return True
finally:
track_point_in_utc_time(hass, update,
now + timedelta(seconds=interval))
track_point_in_utc_time(hass, update, now + interval)

_LOGGER.info('Logging in to service')
return update(utcnow())
1 change: 1 addition & 0 deletions homeassistant/components/light/flux_led.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
continue
device['name'] = device['id'] + " " + ipaddr
device[ATTR_MODE] = 'rgbw'
device[CONF_PROTOCOL] = None
light = FluxLight(device)
if light.is_valid:
lights.append(light)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/nest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
REQUIREMENTS = [
'http://github.com/technicalpickles/python-nest'
'/archive/e6c9d56a8df455d4d7746389811f2c1387e8cb33.zip' # nest-cam branch
'#python-nest==3.0.3']
'#python-nest==3.0.2']

DOMAIN = 'nest'

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/notify/lannouncer.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
_LOGGER = logging.getLogger(__name__)


def get_service(hass, config):
def get_service(hass, config, discovery_info=None):
"""Get the Lannouncer notification service."""
host = config.get(CONF_HOST)
port = config.get(CONF_PORT)
Expand Down
5 changes: 4 additions & 1 deletion homeassistant/components/sensor/usps.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

_LOGGER = logging.getLogger(__name__)

COOKIE = 'usps_cookies.pickle'
CONF_UPDATE_INTERVAL = 'update_interval'
ICON = 'mdi:package-variant-closed'
STATUS_DELIVERED = 'delivered'
Expand All @@ -39,8 +40,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the USPS platform."""
import myusps
try:
cookie = hass.config.path(COOKIE)
session = myusps.get_session(config.get(CONF_USERNAME),
config.get(CONF_PASSWORD))
config.get(CONF_PASSWORD),
cookie_path=cookie)
except myusps.USPSError:
_LOGGER.exception('Could not connect to My USPS')
return False
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""Constants used by Home Assistant components."""
MAJOR_VERSION = 0
MINOR_VERSION = 36
PATCH_VERSION = '0'
PATCH_VERSION = '1'
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
REQUIRED_PYTHON_VER = (3, 4, 2)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/util/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def load_yaml(fname: str) -> Union[List, Dict]:
with open(fname, encoding='utf-8') as conf_file:
# If configuration file is empty YAML returns None
# We convert that to an empty dict
return yaml.load(conf_file, Loader=SafeLineLoader) or {}
return yaml.load(conf_file, Loader=SafeLineLoader) or OrderedDict()
except yaml.YAMLError as exc:
_LOGGER.error(exc)
raise HomeAssistantError(exc)
Expand Down
4 changes: 2 additions & 2 deletions requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ hikvision==0.4
# http://github.com/adafruit/Adafruit_Python_DHT/archive/310c59b0293354d07d94375f1365f7b9b9110c7d.zip#Adafruit_DHT==1.3.0

# homeassistant.components.nest
http://github.com/technicalpickles/python-nest/archive/e6c9d56a8df455d4d7746389811f2c1387e8cb33.zip#python-nest==3.0.3
http://github.com/technicalpickles/python-nest/archive/e6c9d56a8df455d4d7746389811f2c1387e8cb33.zip#python-nest==3.0.2

# homeassistant.components.switch.dlink
https://github.com/LinuxChristian/pyW215/archive/v0.3.7.zip#pyW215==0.3.7
Expand Down Expand Up @@ -476,7 +476,7 @@ pysnmp==4.3.2
python-digitalocean==1.10.1

# homeassistant.components.climate.eq3btsmart
python-eq3bt==0.1.2
python-eq3bt==0.1.4

# homeassistant.components.sensor.darksky
python-forecastio==1.3.5
Expand Down
29 changes: 19 additions & 10 deletions tests/test_util/aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ def request(self, method, url, *,
content = b''
if params:
url = str(yarl.URL(url).with_query(params))
if cookies:
self._cookies.update(cookies)

self._mocks.append(AiohttpClientMockResponse(
method, url, status, content, exc))
method, url, status, content, cookies, exc))

def get(self, *args, **kwargs):
"""Register a mock get request."""
Expand All @@ -68,10 +66,6 @@ def call_count(self):
"""Number of requests made."""
return len(self.mock_calls)

def filter_cookies(self, host):
"""Return hosts cookies."""
return self._cookies

def clear_requests(self):
"""Reset mock calls."""
self._mocks.clear()
Expand All @@ -97,7 +91,7 @@ def match_request(self, method, url, *, data=None, auth=None, params=None,
class AiohttpClientMockResponse:
"""Mock Aiohttp client response."""

def __init__(self, method, url, status, response, exc=None):
def __init__(self, method, url, status, response, cookies=None, exc=None):
"""Initialize a fake response."""
self.method = method
self._url = url
Expand All @@ -107,6 +101,14 @@ def __init__(self, method, url, status, response, exc=None):
self.response = response
self.exc = exc

self._cookies = {}

if cookies:
for name, data in cookies.items():
cookie = mock.MagicMock()
cookie.value = data
self._cookies[name] = cookie

def match_request(self, method, url, params=None):
"""Test if response answers request."""
if method.lower() != self.method.lower():
Expand Down Expand Up @@ -140,6 +142,11 @@ def match_request(self, method, url, params=None):

return True

@property
def cookies(self):
"""Return dict of cookies."""
return self._cookies

@asyncio.coroutine
def read(self):
"""Return mock response."""
Expand All @@ -160,6 +167,10 @@ def release(self):
"""Mock release."""
pass

def close(self):
"""Mock close."""
pass


@contextmanager
def mock_aiohttp_client():
Expand All @@ -173,6 +184,4 @@ def mock_aiohttp_client():
setattr(instance, method,
functools.partial(mocker.match_request, method))

instance.cookie_jar.filter_cookies = mocker.filter_cookies

yield mocker
6 changes: 6 additions & 0 deletions tests/util/test_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ def test_include_yaml(self):
doc = yaml.yaml.safe_load(file)
assert doc["key"] == "value"

with patch_yaml_files({'test.yaml': None}):
conf = 'key: !include test.yaml'
with io.StringIO(conf) as file:
doc = yaml.yaml.safe_load(file)
assert doc["key"] == {}

@patch('homeassistant.util.yaml.os.walk')
def test_include_dir_list(self, mock_walk):
"""Test include dir list yaml."""
Expand Down

0 comments on commit 4d96b12

Please sign in to comment.