From 94f5b262beb17c465e0ef8a8211953a1a59887bf Mon Sep 17 00:00:00 2001 From: David Bonnes Date: Wed, 24 Jul 2019 13:39:34 +0100 Subject: [PATCH 1/4] Bump geniushub client (#25458) --- homeassistant/components/geniushub/manifest.json | 2 +- requirements_all.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/geniushub/manifest.json b/homeassistant/components/geniushub/manifest.json index d7f8601ae25..eff5a65c6b5 100644 --- a/homeassistant/components/geniushub/manifest.json +++ b/homeassistant/components/geniushub/manifest.json @@ -3,7 +3,7 @@ "name": "Genius Hub", "documentation": "https://www.home-assistant.io/components/geniushub", "requirements": [ - "geniushub-client==0.4.15" + "geniushub-client==0.5.00" ], "dependencies": [], "codeowners": ["@zxdavb"] diff --git a/requirements_all.txt b/requirements_all.txt index 08323ea4b4d..36ed2c22b27 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -505,7 +505,7 @@ gearbest_parser==1.0.7 geizhals==0.0.9 # homeassistant.components.geniushub -geniushub-client==0.4.15 +geniushub-client==0.5.00 # homeassistant.components.geo_json_events # homeassistant.components.nsw_rural_fire_service_feed From 46b9e9cdfbebba9ed3a4cdee8450c312c5a5217b Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 25 Jul 2019 04:52:27 -0700 Subject: [PATCH 2/4] Allow cors for static files (#25468) --- homeassistant/components/http/cors.py | 8 ++++---- tests/components/http/test_cors.py | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/http/cors.py b/homeassistant/components/http/cors.py index 419b62be2c6..880cc47ac0d 100644 --- a/homeassistant/components/http/cors.py +++ b/homeassistant/components/http/cors.py @@ -1,5 +1,5 @@ """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 homeassistant.const import ( @@ -9,7 +9,7 @@ from homeassistant.core import callback ALLOWED_CORS_HEADERS = [ ORIGIN, ACCEPT, HTTP_HEADER_X_REQUESTED_WITH, CONTENT_TYPE, HTTP_HEADER_HA_AUTH, AUTHORIZATION] -VALID_CORS_TYPES = (Resource, ResourceRoute) +VALID_CORS_TYPES = (Resource, ResourceRoute, StaticResource) @callback @@ -56,7 +56,7 @@ def setup_cors(app, origins): async def cors_startup(app): """Initialize CORS when app starts up.""" - for route in list(app.router.routes()): - _allow_cors(route) + for resource in list(app.router.resources()): + _allow_cors(resource) app.on_startup.append(cors_startup) diff --git a/tests/components/http/test_cors.py b/tests/components/http/test_cors.py index d9fa6c11309..46a2766e541 100644 --- a/tests/components/http/test_cors.py +++ b/tests/components/http/test_cors.py @@ -1,4 +1,5 @@ """Test cors for the HTTP component.""" +from pathlib import Path from unittest.mock import patch from aiohttp import web @@ -152,3 +153,22 @@ async def test_cors_works_with_frontend(hass, hass_client): client = await hass_client() resp = await client.get('/') 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' From e79af97fdcd98934b54fe88c0437085dd2354bbd Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 24 Jul 2019 21:53:51 -0700 Subject: [PATCH 3/4] Fix Nest turning off eco (#25472) * Fix Nest turning off eco * Add hvac action --- homeassistant/components/nest/climate.py | 46 ++++++++++++++---------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/homeassistant/components/nest/climate.py b/homeassistant/components/nest/climate.py index 63d91cbc829..0ea721df223 100644 --- a/homeassistant/components/nest/climate.py +++ b/homeassistant/components/nest/climate.py @@ -8,7 +8,8 @@ from homeassistant.components.climate.const import ( ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, FAN_AUTO, FAN_ON, HVAC_MODE_AUTO, HVAC_MODE_COOL, HVAC_MODE_HEAT, HVAC_MODE_OFF, 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 ( ATTR_TEMPERATURE, CONF_SCAN_INTERVAL, TEMP_CELSIUS, TEMP_FAHRENHEIT) from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -28,6 +29,21 @@ NEST_MODE_HEAT = 'heat' NEST_MODE_COOL = 'cool' 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] @@ -95,6 +111,7 @@ class NestThermostat(ClimateDevice): self._temperature = None self._temperature_scale = None self._mode = None + self._action = None self._fan = None self._eco_temperature = None self._is_locked = None @@ -157,15 +174,16 @@ class NestThermostat(ClimateDevice): @property def hvac_mode(self): """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: # We assume the first operation in operation list is the main one return self._operation_list[0] - if self._mode == NEST_MODE_HEAT_COOL: - return HVAC_MODE_AUTO - return None + + return MODE_NEST_TO_HASS[self._mode] + + @property + def hvac_action(self): + """Return the current hvac action.""" + return ACTION_NEST_TO_HASS[self._action] @property def target_temperature(self): @@ -216,16 +234,7 @@ class NestThermostat(ClimateDevice): def set_hvac_mode(self, hvac_mode): """Set operation mode.""" - if hvac_mode in (HVAC_MODE_HEAT, HVAC_MODE_COOL, HVAC_MODE_OFF): - 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 + self.device.mode = MODE_HASS_TO_NEST[hvac_mode] @property def hvac_modes(self): @@ -259,7 +268,7 @@ class NestThermostat(ClimateDevice): self.structure.away = True 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: self.device.mode = NEST_MODE_ECO @@ -301,6 +310,7 @@ class NestThermostat(ClimateDevice): self._humidity = self.device.humidity self._temperature = self.device.temperature self._mode = self.device.mode + self._action = self.device.hvac_state self._target_temperature = self.device.target self._fan = self.device.fan self._away = self.structure.away == 'away' From 47f3be1fe46fcdf0644a4fbd09b7deb7173879de Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 25 Jul 2019 09:51:43 -0700 Subject: [PATCH 4/4] Bumped version to 0.96.5 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index e141391f5ed..79763c16fbc 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -2,7 +2,7 @@ """Constants used by Home Assistant components.""" MAJOR_VERSION = 0 MINOR_VERSION = 96 -PATCH_VERSION = '4' +PATCH_VERSION = '5' __short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION) __version__ = '{}.{}'.format(__short_version__, PATCH_VERSION) REQUIRED_PYTHON_VER = (3, 5, 3)