From c58fb00f03a05f0ceda2ee17c5cddf2ca62d0727 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 7 May 2016 22:24:04 -0700 Subject: [PATCH 01/13] Improve config validation error message --- homeassistant/bootstrap.py | 14 ++++++++------ homeassistant/helpers/config_validation.py | 9 +++++++-- homeassistant/util/yaml.py | 8 +++++++- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/homeassistant/bootstrap.py b/homeassistant/bootstrap.py index 6b68f46d4ca..a8e85ca3bd3 100644 --- a/homeassistant/bootstrap.py +++ b/homeassistant/bootstrap.py @@ -104,7 +104,7 @@ def _setup_component(hass, domain, config): try: config = component.CONFIG_SCHEMA(config) except vol.MultipleInvalid as ex: - cv.log_exception(_LOGGER, ex, domain) + cv.log_exception(_LOGGER, ex, domain, config) return False elif hasattr(component, 'PLATFORM_SCHEMA'): @@ -114,11 +114,11 @@ def _setup_component(hass, domain, config): try: p_validated = component.PLATFORM_SCHEMA(p_config) except vol.MultipleInvalid as ex: - cv.log_exception(_LOGGER, ex, domain) + cv.log_exception(_LOGGER, ex, domain, p_config) return False # Not all platform components follow same pattern for platforms - # Sof if p_name is None we are not going to validate platform + # So if p_name is None we are not going to validate platform # (the automation component is one of them) if p_name is None: platforms.append(p_validated) @@ -136,7 +136,7 @@ def _setup_component(hass, domain, config): p_validated = platform.PLATFORM_SCHEMA(p_validated) except vol.MultipleInvalid as ex: cv.log_exception(_LOGGER, ex, '{}.{}' - .format(domain, p_name)) + .format(domain, p_name), p_validated) return False platforms.append(p_validated) @@ -228,11 +228,13 @@ def from_config_dict(config, hass=None, config_dir=None, enable_log=True, hass.config.config_dir = config_dir mount_local_lib_path(config_dir) + core_config = config.get(core.DOMAIN, {}) + try: process_ha_core_config(hass, config_util.CORE_CONFIG_SCHEMA( - config.get(core.DOMAIN, {}))) + core_config)) except vol.MultipleInvalid as ex: - cv.log_exception(_LOGGER, ex, 'homeassistant') + cv.log_exception(_LOGGER, ex, 'homeassistant', core_config) return None process_ha_config_upgrade(hass) diff --git a/homeassistant/helpers/config_validation.py b/homeassistant/helpers/config_validation.py index 0bab2674ca6..cea7e95ac5a 100644 --- a/homeassistant/helpers/config_validation.py +++ b/homeassistant/helpers/config_validation.py @@ -146,7 +146,7 @@ def time_period_str(value): time_period = vol.Any(time_period_str, timedelta, time_period_dict) -def log_exception(logger, ex, domain): +def log_exception(logger, ex, domain, config): """Generate log exception for config validation.""" message = 'Invalid config for [{}]: '.format(domain) if 'extra keys not allowed' in ex.error_message: @@ -154,7 +154,12 @@ def log_exception(logger, ex, domain): .format(ex.path[-1], domain, domain, '->'.join('%s' % m for m in ex.path)) else: - message += ex.error_message + message += str(ex) + + if hasattr(config, '__line__'): + message += " (See {}:{})".format(config.__config_file__, + config.__line__ or '?') + logger.error(message) diff --git a/homeassistant/util/yaml.py b/homeassistant/util/yaml.py index 8768de5d2f7..bdf0c6d5c41 100644 --- a/homeassistant/util/yaml.py +++ b/homeassistant/util/yaml.py @@ -50,8 +50,11 @@ def _ordered_dict(loader, node): nodes = loader.construct_pairs(node) seen = {} + min_line = None for (key, _), (node, _) in zip(nodes, node.value): line = getattr(node, '__line__', 'unknown') + if line != 'unknown' and (min_line is None or line < min_line): + min_line = line if key in seen: fname = getattr(loader.stream, 'name', '') first_mark = yaml.Mark(fname, 0, seen[key], -1, None, None) @@ -62,7 +65,10 @@ def _ordered_dict(loader, node): ) seen[key] = line - return OrderedDict(nodes) + processed = OrderedDict(nodes) + processed.__config_file__ = loader.name + processed.__line__ = min_line + return processed def _env_var_yaml(loader, node): From 0f6c9d2f7561f6e354897b1daacc5bededcf7ae1 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 7 May 2016 22:24:13 -0700 Subject: [PATCH 02/13] Fix automation deprecation warning --- homeassistant/components/automation/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/automation/__init__.py b/homeassistant/components/automation/__init__.py index ef3a9b4a41d..d99043f0c75 100644 --- a/homeassistant/components/automation/__init__.py +++ b/homeassistant/components/automation/__init__.py @@ -143,7 +143,7 @@ def _process_if(hass, config, p_config, action): # Deprecated since 0.19 - 5/5/2016 if cond_type != DEFAULT_CONDITION_TYPE: - _LOGGER.warning('Using condition_type: %s is deprecated. Please use ' + _LOGGER.warning('Using condition_type: "or" is deprecated. Please use ' '"condition: or" instead.') if_configs = p_config.get(CONF_CONDITION) From 69ecedefada272e6974629b5ff7aec7c8a05857c Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 7 May 2016 22:24:20 -0700 Subject: [PATCH 03/13] Version bump to 0.19.1 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index bbd9de7585b..70491b170b8 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -1,7 +1,7 @@ # coding: utf-8 """Constants used by Home Assistant components.""" -__version__ = "0.19" +__version__ = "0.19.1" REQUIRED_PYTHON_VER = (3, 4) PLATFORM_FORMAT = '{}.{}' From 92d71a6612864cdd2df3f1b6daa102df45604814 Mon Sep 17 00:00:00 2001 From: John Arild Berentsen Date: Sun, 8 May 2016 18:52:16 +0200 Subject: [PATCH 04/13] Fix for not recognizing Z-Wave thermostats (#2006) * Fix for not recognizing thermostats * Properly ignore zxt-120 * fix --- homeassistant/components/thermostat/zwave.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/thermostat/zwave.py b/homeassistant/components/thermostat/zwave.py index ef72fc55c10..a8632cde128 100644 --- a/homeassistant/components/thermostat/zwave.py +++ b/homeassistant/components/thermostat/zwave.py @@ -17,7 +17,7 @@ DEFAULT_NAME = 'ZWave Thermostat' REMOTEC = 0x5254 REMOTEC_ZXT_120 = 0x8377 -REMOTEC_ZXT_120_THERMOSTAT = (REMOTEC, REMOTEC_ZXT_120, 0) +REMOTEC_ZXT_120_THERMOSTAT = (REMOTEC, REMOTEC_ZXT_120) WORKAROUND_IGNORE = 'ignore' @@ -40,16 +40,15 @@ def setup_platform(hass, config, add_devices, discovery_info=None): if (value.node.manufacturer_id.strip() and value.node.product_id.strip()): specific_sensor_key = (int(value.node.manufacturer_id, 16), - int(value.node.product_id, 16), - value.index) + int(value.node.product_id, 16)) if specific_sensor_key in DEVICE_MAPPINGS: if DEVICE_MAPPINGS[specific_sensor_key] == WORKAROUND_IGNORE: _LOGGER.debug("Remotec ZXT-120 Zwave Thermostat, ignoring") return - else: - add_devices([ZWaveThermostat(value)]) - _LOGGER.debug("discovery_info=%s and zwave.NETWORK=%s", - discovery_info, zwave.NETWORK) + + add_devices([ZWaveThermostat(value)]) + _LOGGER.debug("discovery_info=%s and zwave.NETWORK=%s", + discovery_info, zwave.NETWORK) # pylint: disable=too-many-arguments From 1e42f85a9cc388b1d2f5931ec29032cc9af8349e Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sun, 8 May 2016 09:53:22 -0700 Subject: [PATCH 05/13] Version bump to 0.19.2 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index 70491b170b8..de7200bd9be 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -1,7 +1,7 @@ # coding: utf-8 """Constants used by Home Assistant components.""" -__version__ = "0.19.1" +__version__ = "0.19.2" REQUIRED_PYTHON_VER = (3, 4) PLATFORM_FORMAT = '{}.{}' From 8d2dc4826186dbcc68a136af6bc7022e839928b8 Mon Sep 17 00:00:00 2001 From: Robbie Trencheny Date: Mon, 9 May 2016 15:14:30 -0700 Subject: [PATCH 06/13] en_UK->en_GB. Closes #2019. --- homeassistant/components/sensor/fitbit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/sensor/fitbit.py b/homeassistant/components/sensor/fitbit.py index f928b9a78e9..37281058e02 100644 --- a/homeassistant/components/sensor/fitbit.py +++ b/homeassistant/components/sensor/fitbit.py @@ -85,7 +85,7 @@ FITBIT_MEASUREMENTS = { "liquids": "fl. oz.", "blood glucose": "mg/dL", }, - "en_UK": { + "en_GB": { "duration": "milliseconds", "distance": "kilometers", "elevation": "meters", From faf5ffe610b347743ab23210b13f3785c06c7453 Mon Sep 17 00:00:00 2001 From: Robbie Trencheny Date: Mon, 9 May 2016 15:31:47 -0700 Subject: [PATCH 07/13] Minor Fitbit tweaks. Correct the copy, dont require auth on the routes, get the client_id/client_secret from fitbit.conf instead of the YAML --- homeassistant/components/sensor/fitbit.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/sensor/fitbit.py b/homeassistant/components/sensor/fitbit.py index 37281058e02..57e0ba093ab 100644 --- a/homeassistant/components/sensor/fitbit.py +++ b/homeassistant/components/sensor/fitbit.py @@ -153,7 +153,7 @@ def request_app_setup(hass, config, add_devices, config_path, else: setup_platform(hass, config, add_devices, discovery_info) - start_url = "{}{}".format(hass.config.api.base_url, FITBIT_AUTH_START) + start_url = "{}{}".format(hass.config.api.base_url, FITBIT_AUTH_CALLBACK_PATH) description = """Please create a Fitbit developer app at https://dev.fitbit.com/apps/new. @@ -222,8 +222,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None): access_token = config_file.get("access_token") refresh_token = config_file.get("refresh_token") if None not in (access_token, refresh_token): - authd_client = fitbit.Fitbit(config.get("client_id"), - config.get("client_secret"), + authd_client = fitbit.Fitbit(config_file.get("client_id"), + config_file.get("client_secret"), access_token=access_token, refresh_token=refresh_token) @@ -239,8 +239,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None): add_devices(dev) else: - oauth = fitbit.api.FitbitOauth2Client(config.get("client_id"), - config.get("client_secret")) + oauth = fitbit.api.FitbitOauth2Client(config_file.get("client_id"), + config_file.get("client_secret")) redirect_uri = "{}{}".format(hass.config.api.base_url, FITBIT_AUTH_CALLBACK_PATH) @@ -301,9 +301,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None): setup_platform(hass, config, add_devices, discovery_info=None) - hass.http.register_path("GET", FITBIT_AUTH_START, _start_fitbit_auth) + hass.http.register_path("GET", FITBIT_AUTH_START, _start_fitbit_auth, require_auth=False) hass.http.register_path("GET", FITBIT_AUTH_CALLBACK_PATH, - _finish_fitbit_auth) + _finish_fitbit_auth, require_auth=False) request_oauth_completion(hass) From 39e7942dcea6d86eb2b26f38f8c22ecbcbba2543 Mon Sep 17 00:00:00 2001 From: Robbie Trencheny Date: Mon, 9 May 2016 15:33:04 -0700 Subject: [PATCH 08/13] Fitbit flake8 and pylint fixes. Forgot to do it before pushing :( --- homeassistant/components/sensor/fitbit.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/sensor/fitbit.py b/homeassistant/components/sensor/fitbit.py index 57e0ba093ab..7e53f986515 100644 --- a/homeassistant/components/sensor/fitbit.py +++ b/homeassistant/components/sensor/fitbit.py @@ -153,7 +153,8 @@ def request_app_setup(hass, config, add_devices, config_path, else: setup_platform(hass, config, add_devices, discovery_info) - start_url = "{}{}".format(hass.config.api.base_url, FITBIT_AUTH_CALLBACK_PATH) + start_url = "{}{}".format(hass.config.api.base_url, + FITBIT_AUTH_CALLBACK_PATH) description = """Please create a Fitbit developer app at https://dev.fitbit.com/apps/new. @@ -301,7 +302,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None): setup_platform(hass, config, add_devices, discovery_info=None) - hass.http.register_path("GET", FITBIT_AUTH_START, _start_fitbit_auth, require_auth=False) + hass.http.register_path("GET", FITBIT_AUTH_START, _start_fitbit_auth, + require_auth=False) hass.http.register_path("GET", FITBIT_AUTH_CALLBACK_PATH, _finish_fitbit_auth, require_auth=False) From e77a7f43851c1f72efcdde131551e8261e4014d9 Mon Sep 17 00:00:00 2001 From: Landrash Date: Tue, 10 May 2016 08:48:48 +0200 Subject: [PATCH 09/13] Fixed minor miss-spelling (#2028) Changed millileters to milliliters. Changed case of mmol/l to mmol/L. --- homeassistant/components/sensor/fitbit.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/sensor/fitbit.py b/homeassistant/components/sensor/fitbit.py index 7e53f986515..7d122f857d7 100644 --- a/homeassistant/components/sensor/fitbit.py +++ b/homeassistant/components/sensor/fitbit.py @@ -92,8 +92,8 @@ FITBIT_MEASUREMENTS = { "height": "centimeters", "weight": "stone", "body": "centimeters", - "liquids": "millileters", - "blood glucose": "mmol/l" + "liquids": "milliliters", + "blood glucose": "mmol/L" }, "metric": { "duration": "milliseconds", @@ -102,8 +102,8 @@ FITBIT_MEASUREMENTS = { "height": "centimeters", "weight": "kilograms", "body": "centimeters", - "liquids": "millileters", - "blood glucose": "mmol/l" + "liquids": "milliliters", + "blood glucose": "mmol/L" } } From 0893ddcab74231a342880d964f59dcacd06d7ded Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Tue, 10 May 2016 13:36:03 -0700 Subject: [PATCH 10/13] Update README.rst --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 5cea28f5dca..b63377dbaf0 100644 --- a/README.rst +++ b/README.rst @@ -1,5 +1,5 @@ Home Assistant |Build Status| |Coverage Status| |Join the chat at https://gitter.im/home-assistant/home-assistant| |Join the dev chat at https://gitter.im/home-assistant/home-assistant/devs| -================================================================================================================== +============================================================================================================================================================================================== Home Assistant is a home automation platform running on Python 3. The goal of Home Assistant is to be able to track and control all devices at From 01eb2d5c84e7a5a306b701006c6a06c2d7f4c37a Mon Sep 17 00:00:00 2001 From: Robbie Trencheny Date: Tue, 10 May 2016 13:42:23 -0700 Subject: [PATCH 11/13] Increment version --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index de7200bd9be..1808ffbada1 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -1,7 +1,7 @@ # coding: utf-8 """Constants used by Home Assistant components.""" -__version__ = "0.19.2" +__version__ = "0.19.3" REQUIRED_PYTHON_VER = (3, 4) PLATFORM_FORMAT = '{}.{}' From dd6ab79e35ea43ccd6edc812ea9647336636792d Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Tue, 10 May 2016 21:41:53 -0700 Subject: [PATCH 12/13] Make AND and OR conditions valid --- homeassistant/helpers/config_validation.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/homeassistant/helpers/config_validation.py b/homeassistant/helpers/config_validation.py index cea7e95ac5a..031ab5227dc 100644 --- a/homeassistant/helpers/config_validation.py +++ b/homeassistant/helpers/config_validation.py @@ -369,6 +369,8 @@ CONDITION_SCHEMA = vol.Any( TEMPLATE_CONDITION_SCHEMA, TIME_CONDITION_SCHEMA, ZONE_CONDITION_SCHEMA, + AND_CONDITION_SCHEMA, + OR_CONDITION_SCHEMA, ) _SCRIPT_DELAY_SCHEMA = vol.Schema({ From 786a0154b198157ef6705a57bb7f56f712c137ee Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Tue, 10 May 2016 21:48:05 -0700 Subject: [PATCH 13/13] Version bump to 0.19.4 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index 1808ffbada1..e69b44786a9 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -1,7 +1,7 @@ # coding: utf-8 """Constants used by Home Assistant components.""" -__version__ = "0.19.3" +__version__ = "0.19.4" REQUIRED_PYTHON_VER = (3, 4) PLATFORM_FORMAT = '{}.{}'