From 1e81d148222ee07e6b0f2c431036876dfa48eab3 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 6 Feb 2020 03:55:11 -0800 Subject: [PATCH 01/11] Fix automation sun import (#31521) --- homeassistant/components/automation/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/homeassistant/components/automation/__init__.py b/homeassistant/components/automation/__init__.py index 528a314dd7b..1a73de885c0 100644 --- a/homeassistant/components/automation/__init__.py +++ b/homeassistant/components/automation/__init__.py @@ -5,7 +5,6 @@ from typing import Any, Awaitable, Callable, List, Optional, Set import voluptuous as vol -from homeassistant.components import sun from homeassistant.const import ( ATTR_ENTITY_ID, ATTR_NAME, @@ -578,6 +577,6 @@ def _trigger_extract_entities(trigger_conf: dict) -> List[str]: return [trigger_conf[CONF_ZONE]] if trigger_conf[CONF_PLATFORM] == "sun": - return [sun.ENTITY_ID] + return ["sun.sun"] return [] From 60c5ef5b343eefa80c1081a174faf329b7e48e3d Mon Sep 17 00:00:00 2001 From: Robert Chmielowiec Date: Thu, 6 Feb 2020 15:53:16 +0100 Subject: [PATCH 02/11] Fix migrating huawei_lte entry without recipient (#31522) --- homeassistant/components/huawei_lte/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/huawei_lte/__init__.py b/homeassistant/components/huawei_lte/__init__.py index 1b8cb658c28..1d54f972907 100644 --- a/homeassistant/components/huawei_lte/__init__.py +++ b/homeassistant/components/huawei_lte/__init__.py @@ -510,7 +510,7 @@ async def async_migrate_entry(hass: HomeAssistantType, config_entry: ConfigEntry """Migrate config entry to new version.""" if config_entry.version == 1: options = config_entry.options - recipient = options[CONF_RECIPIENT] + recipient = options.get(CONF_RECIPIENT) if isinstance(recipient, str): options[CONF_RECIPIENT] = [x.strip() for x in recipient.split(",")] config_entry.version = 2 From 6b5cd74771e78489514d194bfa67d8f4dd0ebe40 Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Thu, 6 Feb 2020 16:52:46 +0000 Subject: [PATCH 03/11] Only normalise Garmin connect data to minutes if the value is not None (#31526) Otherwise this causes additional TypeError messages to be logged for division of None. --- homeassistant/components/garmin_connect/sensor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/garmin_connect/sensor.py b/homeassistant/components/garmin_connect/sensor.py index 6a3128cae01..154f7010db4 100644 --- a/homeassistant/components/garmin_connect/sensor.py +++ b/homeassistant/components/garmin_connect/sensor.py @@ -165,9 +165,9 @@ class GarminConnectSensor(Entity): return data = self._data.data - if "Duration" in self._type: + if "Duration" in self._type and data[self._type]: self._state = data[self._type] // 60 - elif "Seconds" in self._type: + elif "Seconds" in self._type and data[self._type]: self._state = data[self._type] // 60 else: self._state = data[self._type] From bf1b78f621543d7fce2df074493afe4cfc049451 Mon Sep 17 00:00:00 2001 From: Quentame Date: Thu, 6 Feb 2020 17:53:42 +0100 Subject: [PATCH 04/11] Fix iCloud determine_interval: add default interval to max_interval (#31533) --- homeassistant/components/icloud/account.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/icloud/account.py b/homeassistant/components/icloud/account.py index af7963d8dc1..5d681539668 100644 --- a/homeassistant/components/icloud/account.py +++ b/homeassistant/components/icloud/account.py @@ -26,6 +26,7 @@ from .const import ( DEVICE_DISPLAY_NAME, DEVICE_ID, DEVICE_LOCATION, + DEVICE_LOCATION_HORIZONTAL_ACCURACY, DEVICE_LOCATION_LATITUDE, DEVICE_LOCATION_LONGITUDE, DEVICE_LOST_MODE_CAPABLE, @@ -175,8 +176,9 @@ class IcloudAccount: def _determine_interval(self) -> int: """Calculate new interval between two API fetch (in minutes).""" - intervals = {} + intervals = {"default": self._max_interval} for device in self._devices.values(): + # Max interval if no location if device.location is None: continue @@ -186,10 +188,11 @@ class IcloudAccount: self.hass, device.location[DEVICE_LOCATION_LATITUDE], device.location[DEVICE_LOCATION_LONGITUDE], + device.location[DEVICE_LOCATION_HORIZONTAL_ACCURACY], ).result() + # Max interval if in zone if current_zone is not None: - intervals[device.name] = self._max_interval continue zones = ( @@ -209,6 +212,7 @@ class IcloudAccount: ) distances.append(round(zone_distance / 1000, 1)) + # Max interval if no zone if not distances: continue mindistance = min(distances) From 080f9725dcf10e667bbeb49eb00f64aebed67b05 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Thu, 6 Feb 2020 17:00:27 +0100 Subject: [PATCH 05/11] Limit OAuth scopes for Netatmo and Home Assistant Cloud (#31538) * Limit OAuth scopes for Netatmo and Home Assistant Cloud * Fix tests by making order of scopes predictable --- .../components/netatmo/config_flow.py | 34 +++++++++---------- tests/components/netatmo/test_config_flow.py | 8 ++--- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/homeassistant/components/netatmo/config_flow.py b/homeassistant/components/netatmo/config_flow.py index 8f59382dd46..dce87fb7931 100644 --- a/homeassistant/components/netatmo/config_flow.py +++ b/homeassistant/components/netatmo/config_flow.py @@ -25,24 +25,22 @@ class NetatmoFlowHandler( @property def extra_authorize_data(self) -> dict: """Extra data that needs to be appended to the authorize url.""" - return { - "scope": ( - " ".join( - [ - "read_station", - "read_camera", - "access_camera", - "write_camera", - "read_presence", - "access_presence", - "read_homecoach", - "read_smokedetector", - "read_thermostat", - "write_thermostat", - ] - ) - ) - } + scopes = [ + "read_camera", + "read_homecoach", + "read_presence", + "read_smokedetector", + "read_station", + "read_thermostat", + "write_camera", + "write_thermostat", + ] + + if self.flow_impl.name != "Home Assistant Cloud": + scopes.extend(["access_camera", "access_presence"]) + scopes.sort() + + return {"scope": " ".join(scopes)} async def async_step_user(self, user_input=None): """Handle a flow start.""" diff --git a/tests/components/netatmo/test_config_flow.py b/tests/components/netatmo/test_config_flow.py index 24aac6dc878..d76578d277c 100644 --- a/tests/components/netatmo/test_config_flow.py +++ b/tests/components/netatmo/test_config_flow.py @@ -54,15 +54,15 @@ async def test_full_flow(hass, aiohttp_client, aioclient_mock): scope = "+".join( [ - "read_station", - "read_camera", "access_camera", - "write_camera", - "read_presence", "access_presence", + "read_camera", "read_homecoach", + "read_presence", "read_smokedetector", + "read_station", "read_thermostat", + "write_camera", "write_thermostat", ] ) From 64fc7103bebbdba7f2b215cb8face574466c9735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Thu, 6 Feb 2020 20:54:01 +0200 Subject: [PATCH 06/11] Use min and m as units in Garmin Connect for consistency and correctness (#31543) --- .../components/garmin_connect/const.py | 48 ++++++++----------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/homeassistant/components/garmin_connect/const.py b/homeassistant/components/garmin_connect/const.py index 57cd35e667f..e38bd72c1ee 100644 --- a/homeassistant/components/garmin_connect/const.py +++ b/homeassistant/components/garmin_connect/const.py @@ -27,7 +27,7 @@ GARMIN_ENTITY_LIST = { False, ], "netCalorieGoal": ["Net Calorie Goal", "cal", "mdi:food", None, False], - "totalDistanceMeters": ["Total Distance Mtr", "mtr", "mdi:walk", None, True], + "totalDistanceMeters": ["Total Distance Mtr", "m", "mdi:walk", None, True], "wellnessStartTimeLocal": [ "Wellness Start Time", "", @@ -43,7 +43,7 @@ GARMIN_ENTITY_LIST = { False, ], "wellnessDescription": ["Wellness Description", "", "mdi:clock", None, False], - "wellnessDistanceMeters": ["Wellness Distance Mtr", "mtr", "mdi:walk", None, False], + "wellnessDistanceMeters": ["Wellness Distance Mtr", "m", "mdi:walk", None, False], "wellnessActiveKilocalories": [ "Wellness Active KiloCalories", "kcal", @@ -52,16 +52,16 @@ GARMIN_ENTITY_LIST = { False, ], "wellnessKilocalories": ["Wellness KiloCalories", "kcal", "mdi:food", None, False], - "highlyActiveSeconds": ["Highly Active Time", "minutes", "mdi:fire", None, False], - "activeSeconds": ["Active Time", "minutes", "mdi:fire", None, True], - "sedentarySeconds": ["Sedentary Time", "minutes", "mdi:seat", None, True], - "sleepingSeconds": ["Sleeping Time", "minutes", "mdi:sleep", None, True], - "measurableAwakeDuration": ["Awake Duration", "minutes", "mdi:sleep", None, True], - "measurableAsleepDuration": ["Sleep Duration", "minutes", "mdi:sleep", None, True], - "floorsAscendedInMeters": ["Floors Ascended Mtr", "mtr", "mdi:stairs", None, False], + "highlyActiveSeconds": ["Highly Active Time", "min", "mdi:fire", None, False], + "activeSeconds": ["Active Time", "min", "mdi:fire", None, True], + "sedentarySeconds": ["Sedentary Time", "min", "mdi:seat", None, True], + "sleepingSeconds": ["Sleeping Time", "min", "mdi:sleep", None, True], + "measurableAwakeDuration": ["Awake Duration", "min", "mdi:sleep", None, True], + "measurableAsleepDuration": ["Sleep Duration", "min", "mdi:sleep", None, True], + "floorsAscendedInMeters": ["Floors Ascended Mtr", "m", "mdi:stairs", None, False], "floorsDescendedInMeters": [ "Floors Descended Mtr", - "mtr", + "m", "mdi:stairs", None, False, @@ -97,52 +97,46 @@ GARMIN_ENTITY_LIST = { "averageStressLevel": ["Avg Stress Level", "", "mdi:flash-alert", None, True], "maxStressLevel": ["Max Stress Level", "", "mdi:flash-alert", None, True], "stressQualifier": ["Stress Qualifier", "", "mdi:flash-alert", None, False], - "stressDuration": ["Stress Duration", "minutes", "mdi:flash-alert", None, False], + "stressDuration": ["Stress Duration", "min", "mdi:flash-alert", None, False], "restStressDuration": [ "Rest Stress Duration", - "minutes", + "min", "mdi:flash-alert", None, True, ], "activityStressDuration": [ "Activity Stress Duration", - "minutes", + "min", "mdi:flash-alert", None, True, ], "uncategorizedStressDuration": [ "Uncat. Stress Duration", - "minutes", + "min", "mdi:flash-alert", None, True, ], "totalStressDuration": [ "Total Stress Duration", - "minutes", - "mdi:flash-alert", - None, - True, - ], - "lowStressDuration": [ - "Low Stress Duration", - "minutes", + "min", "mdi:flash-alert", None, True, ], + "lowStressDuration": ["Low Stress Duration", "min", "mdi:flash-alert", None, True], "mediumStressDuration": [ "Medium Stress Duration", - "minutes", + "min", "mdi:flash-alert", None, True, ], "highStressDuration": [ "High Stress Duration", - "minutes", + "min", "mdi:flash-alert", None, True, @@ -192,19 +186,19 @@ GARMIN_ENTITY_LIST = { ], "moderateIntensityMinutes": [ "Moderate Intensity", - "minutes", + "min", "mdi:flash-alert", None, False, ], "vigorousIntensityMinutes": [ "Vigorous Intensity", - "minutes", + "min", "mdi:run-fast", None, False, ], - "intensityMinutesGoal": ["Intensity Goal", "minutes", "mdi:run-fast", None, False], + "intensityMinutesGoal": ["Intensity Goal", "min", "mdi:run-fast", None, False], "bodyBatteryChargedValue": [ "Body Battery Charged", "%", From 774f0f9b675b997c8f8709928d5780cac0e9100d Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 6 Feb 2020 09:26:51 -0800 Subject: [PATCH 07/11] Deprecate old netatmo keys (#31544) --- homeassistant/components/netatmo/__init__.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/netatmo/__init__.py b/homeassistant/components/netatmo/__init__.py index ace12d3838c..bd79f597b5b 100644 --- a/homeassistant/components/netatmo/__init__.py +++ b/homeassistant/components/netatmo/__init__.py @@ -5,7 +5,12 @@ import logging import voluptuous as vol from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET +from homeassistant.const import ( + CONF_CLIENT_ID, + CONF_CLIENT_SECRET, + CONF_DISCOVERY, + CONF_USERNAME, +) from homeassistant.core import HomeAssistant from homeassistant.helpers import config_entry_oauth2_flow, config_validation as cv @@ -14,12 +19,19 @@ from .const import AUTH, DATA_PERSONS, DOMAIN, OAUTH2_AUTHORIZE, OAUTH2_TOKEN _LOGGER = logging.getLogger(__name__) +CONF_SECRET_KEY = "secret_key" +CONF_WEBHOOKS = "webhooks" + CONFIG_SCHEMA = vol.Schema( { DOMAIN: vol.Schema( { vol.Required(CONF_CLIENT_ID): cv.string, vol.Required(CONF_CLIENT_SECRET): cv.string, + cv.deprecated(CONF_SECRET_KEY): cv.match_all, + cv.deprecated(CONF_USERNAME): cv.match_all, + cv.deprecated(CONF_WEBHOOKS): cv.match_all, + cv.deprecated(CONF_DISCOVERY): cv.match_all, } ) }, From bb96584d6ea66c4aebf7d4f35ee9e0feeabc51c9 Mon Sep 17 00:00:00 2001 From: Josh Bendavid Date: Thu, 6 Feb 2020 19:00:54 +0100 Subject: [PATCH 08/11] update aiopylgtv to 0.3.3 (#31545) --- homeassistant/components/webostv/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/webostv/manifest.json b/homeassistant/components/webostv/manifest.json index e55867432cc..acdee1d9ca9 100644 --- a/homeassistant/components/webostv/manifest.json +++ b/homeassistant/components/webostv/manifest.json @@ -2,7 +2,7 @@ "domain": "webostv", "name": "LG webOS Smart TV", "documentation": "https://www.home-assistant.io/integrations/webostv", - "requirements": ["aiopylgtv==0.3.2"], + "requirements": ["aiopylgtv==0.3.3"], "dependencies": ["configurator"], "codeowners": ["@bendavid"] } diff --git a/requirements_all.txt b/requirements_all.txt index 2e32aee8db0..627481a8d40 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -190,7 +190,7 @@ aionotion==1.1.0 aiopvapi==1.6.14 # homeassistant.components.webostv -aiopylgtv==0.3.2 +aiopylgtv==0.3.3 # homeassistant.components.switcher_kis aioswitcher==2019.4.26 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index e2ac2d07cd6..c974743c516 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -69,7 +69,7 @@ aiohue==1.10.1 aionotion==1.1.0 # homeassistant.components.webostv -aiopylgtv==0.3.2 +aiopylgtv==0.3.3 # homeassistant.components.switcher_kis aioswitcher==2019.4.26 From d31eb9f3527c8a0e73ee943fd9683c4c55bed614 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 6 Feb 2020 10:55:12 -0800 Subject: [PATCH 09/11] Guard for reloading with no zone config (#31547) --- homeassistant/components/zone/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/zone/__init__.py b/homeassistant/components/zone/__init__.py index 91a1338b671..33ac15853f4 100644 --- a/homeassistant/components/zone/__init__.py +++ b/homeassistant/components/zone/__init__.py @@ -228,7 +228,7 @@ async def async_setup(hass: HomeAssistant, config: Dict) -> bool: conf = await component.async_prepare_reload(skip_reset=True) if conf is None: return - await yaml_collection.async_load(conf[DOMAIN]) + await yaml_collection.async_load(conf.get(DOMAIN, [])) service.async_register_admin_service( hass, From 4e5c74d29384e379dae1492bb02b5df44f32e406 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 6 Feb 2020 11:08:26 -0800 Subject: [PATCH 10/11] Bumped version to 0.105.2 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index 7d2513f3cae..c2d59eb2833 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -1,7 +1,7 @@ """Constants used by Home Assistant components.""" MAJOR_VERSION = 0 MINOR_VERSION = 105 -PATCH_VERSION = "1" +PATCH_VERSION = "2" __short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}" __version__ = f"{__short_version__}.{PATCH_VERSION}" REQUIRED_PYTHON_VER = (3, 7, 0) From 8ab91eb6bb5f70c51d5e34fdac15ead4d5378e5c Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 6 Feb 2020 11:39:44 -0800 Subject: [PATCH 11/11] Update MQTT service description --- homeassistant/components/mqtt/services.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/mqtt/services.yaml b/homeassistant/components/mqtt/services.yaml index 77b3e3b27a1..2af3c22fe50 100644 --- a/homeassistant/components/mqtt/services.yaml +++ b/homeassistant/components/mqtt/services.yaml @@ -30,7 +30,7 @@ dump: fields: topic: description: topic to listen to - example: "openzwave/#" + example: "OpenZWave/#" duration: description: how long we should listen for messages in seconds example: 5