Merge pull request #25486 from home-assistant/rc

0.96.5
This commit is contained in:
Paulus Schoutsen 2019-07-25 10:51:55 -07:00 committed by GitHub
commit 4f8a93fb3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 55 additions and 25 deletions

View File

@ -3,7 +3,7 @@
"name": "Genius Hub", "name": "Genius Hub",
"documentation": "https://www.home-assistant.io/components/geniushub", "documentation": "https://www.home-assistant.io/components/geniushub",
"requirements": [ "requirements": [
"geniushub-client==0.4.15" "geniushub-client==0.5.00"
], ],
"dependencies": [], "dependencies": [],
"codeowners": ["@zxdavb"] "codeowners": ["@zxdavb"]

View File

@ -1,5 +1,5 @@
"""Provide CORS support for the HTTP component.""" """Provide CORS support for the HTTP component."""
from aiohttp.web_urldispatcher import Resource, ResourceRoute from aiohttp.web_urldispatcher import Resource, ResourceRoute, StaticResource
from aiohttp.hdrs import ACCEPT, CONTENT_TYPE, ORIGIN, AUTHORIZATION from aiohttp.hdrs import ACCEPT, CONTENT_TYPE, ORIGIN, AUTHORIZATION
from homeassistant.const import ( from homeassistant.const import (
@ -9,7 +9,7 @@ from homeassistant.core import callback
ALLOWED_CORS_HEADERS = [ ALLOWED_CORS_HEADERS = [
ORIGIN, ACCEPT, HTTP_HEADER_X_REQUESTED_WITH, CONTENT_TYPE, ORIGIN, ACCEPT, HTTP_HEADER_X_REQUESTED_WITH, CONTENT_TYPE,
HTTP_HEADER_HA_AUTH, AUTHORIZATION] HTTP_HEADER_HA_AUTH, AUTHORIZATION]
VALID_CORS_TYPES = (Resource, ResourceRoute) VALID_CORS_TYPES = (Resource, ResourceRoute, StaticResource)
@callback @callback
@ -56,7 +56,7 @@ def setup_cors(app, origins):
async def cors_startup(app): async def cors_startup(app):
"""Initialize CORS when app starts up.""" """Initialize CORS when app starts up."""
for route in list(app.router.routes()): for resource in list(app.router.resources()):
_allow_cors(route) _allow_cors(resource)
app.on_startup.append(cors_startup) app.on_startup.append(cors_startup)

View File

@ -8,7 +8,8 @@ from homeassistant.components.climate.const import (
ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, FAN_AUTO, FAN_ON, ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, FAN_AUTO, FAN_ON,
HVAC_MODE_AUTO, HVAC_MODE_COOL, HVAC_MODE_HEAT, HVAC_MODE_OFF, HVAC_MODE_AUTO, HVAC_MODE_COOL, HVAC_MODE_HEAT, HVAC_MODE_OFF,
SUPPORT_PRESET_MODE, SUPPORT_FAN_MODE, SUPPORT_TARGET_TEMPERATURE, SUPPORT_PRESET_MODE, SUPPORT_FAN_MODE, SUPPORT_TARGET_TEMPERATURE,
SUPPORT_TARGET_TEMPERATURE_RANGE, PRESET_AWAY, PRESET_ECO, PRESET_NONE) SUPPORT_TARGET_TEMPERATURE_RANGE, PRESET_AWAY, PRESET_ECO, PRESET_NONE,
CURRENT_HVAC_HEAT, CURRENT_HVAC_IDLE, CURRENT_HVAC_COOL)
from homeassistant.const import ( from homeassistant.const import (
ATTR_TEMPERATURE, CONF_SCAN_INTERVAL, TEMP_CELSIUS, TEMP_FAHRENHEIT) ATTR_TEMPERATURE, CONF_SCAN_INTERVAL, TEMP_CELSIUS, TEMP_FAHRENHEIT)
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
@ -28,6 +29,21 @@ NEST_MODE_HEAT = 'heat'
NEST_MODE_COOL = 'cool' NEST_MODE_COOL = 'cool'
NEST_MODE_OFF = 'off' NEST_MODE_OFF = 'off'
MODE_HASS_TO_NEST = {
HVAC_MODE_AUTO: NEST_MODE_HEAT_COOL,
HVAC_MODE_HEAT: NEST_MODE_HEAT,
HVAC_MODE_COOL: NEST_MODE_COOL,
HVAC_MODE_OFF: NEST_MODE_OFF,
}
MODE_NEST_TO_HASS = {v: k for k, v in MODE_HASS_TO_NEST.items()}
ACTION_NEST_TO_HASS = {
'off': CURRENT_HVAC_IDLE,
'heating': CURRENT_HVAC_HEAT,
'cooling': CURRENT_HVAC_COOL,
}
PRESET_MODES = [PRESET_NONE, PRESET_AWAY, PRESET_ECO] PRESET_MODES = [PRESET_NONE, PRESET_AWAY, PRESET_ECO]
@ -95,6 +111,7 @@ class NestThermostat(ClimateDevice):
self._temperature = None self._temperature = None
self._temperature_scale = None self._temperature_scale = None
self._mode = None self._mode = None
self._action = None
self._fan = None self._fan = None
self._eco_temperature = None self._eco_temperature = None
self._is_locked = None self._is_locked = None
@ -157,15 +174,16 @@ class NestThermostat(ClimateDevice):
@property @property
def hvac_mode(self): def hvac_mode(self):
"""Return current operation ie. heat, cool, idle.""" """Return current operation ie. heat, cool, idle."""
if self._mode in \
(NEST_MODE_HEAT, NEST_MODE_COOL, NEST_MODE_OFF):
return self._mode
if self._mode == NEST_MODE_ECO: if self._mode == NEST_MODE_ECO:
# We assume the first operation in operation list is the main one # We assume the first operation in operation list is the main one
return self._operation_list[0] return self._operation_list[0]
if self._mode == NEST_MODE_HEAT_COOL:
return HVAC_MODE_AUTO return MODE_NEST_TO_HASS[self._mode]
return None
@property
def hvac_action(self):
"""Return the current hvac action."""
return ACTION_NEST_TO_HASS[self._action]
@property @property
def target_temperature(self): def target_temperature(self):
@ -216,16 +234,7 @@ class NestThermostat(ClimateDevice):
def set_hvac_mode(self, hvac_mode): def set_hvac_mode(self, hvac_mode):
"""Set operation mode.""" """Set operation mode."""
if hvac_mode in (HVAC_MODE_HEAT, HVAC_MODE_COOL, HVAC_MODE_OFF): self.device.mode = MODE_HASS_TO_NEST[hvac_mode]
device_mode = hvac_mode
elif hvac_mode == HVAC_MODE_AUTO:
device_mode = NEST_MODE_HEAT_COOL
else:
device_mode = HVAC_MODE_OFF
_LOGGER.error(
"An error occurred while setting device mode. "
"Invalid operation mode: %s", hvac_mode)
self.device.mode = device_mode
@property @property
def hvac_modes(self): def hvac_modes(self):
@ -259,7 +268,7 @@ class NestThermostat(ClimateDevice):
self.structure.away = True self.structure.away = True
if self.preset_mode == PRESET_ECO: if self.preset_mode == PRESET_ECO:
self.device.mode = self._operation_list[0] self.device.mode = MODE_HASS_TO_NEST[self._operation_list[0]]
elif preset_mode == PRESET_ECO: elif preset_mode == PRESET_ECO:
self.device.mode = NEST_MODE_ECO self.device.mode = NEST_MODE_ECO
@ -301,6 +310,7 @@ class NestThermostat(ClimateDevice):
self._humidity = self.device.humidity self._humidity = self.device.humidity
self._temperature = self.device.temperature self._temperature = self.device.temperature
self._mode = self.device.mode self._mode = self.device.mode
self._action = self.device.hvac_state
self._target_temperature = self.device.target self._target_temperature = self.device.target
self._fan = self.device.fan self._fan = self.device.fan
self._away = self.structure.away == 'away' self._away = self.structure.away == 'away'

View File

@ -2,7 +2,7 @@
"""Constants used by Home Assistant components.""" """Constants used by Home Assistant components."""
MAJOR_VERSION = 0 MAJOR_VERSION = 0
MINOR_VERSION = 96 MINOR_VERSION = 96
PATCH_VERSION = '4' PATCH_VERSION = '5'
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION) __short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION) __version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
REQUIRED_PYTHON_VER = (3, 5, 3) REQUIRED_PYTHON_VER = (3, 5, 3)

View File

@ -505,7 +505,7 @@ gearbest_parser==1.0.7
geizhals==0.0.9 geizhals==0.0.9
# homeassistant.components.geniushub # homeassistant.components.geniushub
geniushub-client==0.4.15 geniushub-client==0.5.00
# homeassistant.components.geo_json_events # homeassistant.components.geo_json_events
# homeassistant.components.nsw_rural_fire_service_feed # homeassistant.components.nsw_rural_fire_service_feed

View File

@ -1,4 +1,5 @@
"""Test cors for the HTTP component.""" """Test cors for the HTTP component."""
from pathlib import Path
from unittest.mock import patch from unittest.mock import patch
from aiohttp import web from aiohttp import web
@ -152,3 +153,22 @@ async def test_cors_works_with_frontend(hass, hass_client):
client = await hass_client() client = await hass_client()
resp = await client.get('/') resp = await client.get('/')
assert resp.status == 200 assert resp.status == 200
async def test_cors_on_static_files(hass, hass_client):
"""Test that we enable CORS for static files."""
assert await async_setup_component(hass, 'frontend', {
'http': {
'cors_allowed_origins': ['http://www.example.com']
}
})
hass.http.register_static_path('/something', Path(__file__).parent)
client = await hass_client()
resp = await client.options('/something/__init__.py', headers={
'origin': 'http://www.example.com',
ACCESS_CONTROL_REQUEST_METHOD: 'GET',
})
assert resp.status == 200
assert resp.headers[ACCESS_CONTROL_ALLOW_ORIGIN] == \
'http://www.example.com'