From a78361341ebe42e354c5e73d9a36c54ea174f7af Mon Sep 17 00:00:00 2001 From: Phil Bruckner Date: Wed, 26 Jun 2019 18:03:11 -0500 Subject: [PATCH 1/4] Fix life360 exception when no location provided (#24777) --- homeassistant/components/life360/device_tracker.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/life360/device_tracker.py b/homeassistant/components/life360/device_tracker.py index cf69d8b656a..4329f2a162b 100644 --- a/homeassistant/components/life360/device_tracker.py +++ b/homeassistant/components/life360/device_tracker.py @@ -177,8 +177,11 @@ class Life360Scanner: return prev_seen def _update_member(self, member, dev_id): - loc = member.get('location', {}) - last_seen = _utc_from_ts(loc.get('timestamp')) + loc = member.get('location') + try: + last_seen = _utc_from_ts(loc.get('timestamp')) + except AttributeError: + last_seen = None prev_seen = self._prev_seen(dev_id, last_seen) if not loc: From dce667fa0781b96ffc26f626c5055e1c339c30da Mon Sep 17 00:00:00 2001 From: William Scanlon Date: Wed, 26 Jun 2019 19:14:01 -0400 Subject: [PATCH 2/4] Pubnub to 1.0.8 (#24781) --- homeassistant/components/wink/manifest.json | 2 +- requirements_all.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/wink/manifest.json b/homeassistant/components/wink/manifest.json index a878b084169..cddfdc5dc9c 100644 --- a/homeassistant/components/wink/manifest.json +++ b/homeassistant/components/wink/manifest.json @@ -3,7 +3,7 @@ "name": "Wink", "documentation": "https://www.home-assistant.io/components/wink", "requirements": [ - "pubnubsub-handler==1.0.7", + "pubnubsub-handler==1.0.8", "python-wink==1.10.5" ], "dependencies": ["configurator"], diff --git a/requirements_all.txt b/requirements_all.txt index fd6af461a0c..e763a02b754 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -942,7 +942,7 @@ psutil==5.6.2 ptvsd==4.2.8 # homeassistant.components.wink -pubnubsub-handler==1.0.7 +pubnubsub-handler==1.0.8 # homeassistant.components.pushbullet pushbullet.py==0.11.0 From c1d0ac7b9dd6e29576b54be4d97e9d219bc93531 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 26 Jun 2019 20:24:20 -0700 Subject: [PATCH 3/4] Catch uncaught Alexa error (#24785) --- homeassistant/components/cloud/http_api.py | 4 +-- tests/components/cloud/test_http_api.py | 40 +++++++++++++++++++++- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/cloud/http_api.py b/homeassistant/components/cloud/http_api.py index 0cd08dd3d5f..e5f00873aab 100644 --- a/homeassistant/components/cloud/http_api.py +++ b/homeassistant/components/cloud/http_api.py @@ -23,7 +23,7 @@ from homeassistant.components.google_assistant import helpers as google_helpers from .const import ( DOMAIN, REQUEST_TIMEOUT, PREF_ENABLE_ALEXA, PREF_ENABLE_GOOGLE, PREF_GOOGLE_SECURE_DEVICES_PIN, InvalidTrustedNetworks, - InvalidTrustedProxies, PREF_ALEXA_REPORT_STATE) + InvalidTrustedProxies, PREF_ALEXA_REPORT_STATE, RequireRelink) _LOGGER = logging.getLogger(__name__) @@ -388,7 +388,7 @@ async def websocket_update_prefs(hass, connection, msg): connection.send_error(msg['id'], 'alexa_timeout', 'Timeout validating Alexa access token.') return - except alexa_errors.NoTokenAvailable: + except (alexa_errors.NoTokenAvailable, RequireRelink): connection.send_error( msg['id'], 'alexa_relink', 'Please go to the Alexa app and re-link the Home Assistant ' diff --git a/tests/components/cloud/test_http_api.py b/tests/components/cloud/test_http_api.py index bc60568f0d4..442643672eb 100644 --- a/tests/components/cloud/test_http_api.py +++ b/tests/components/cloud/test_http_api.py @@ -12,7 +12,7 @@ from homeassistant.core import State from homeassistant.auth.providers import trusted_networks as tn_auth from homeassistant.components.cloud.const import ( PREF_ENABLE_GOOGLE, PREF_ENABLE_ALEXA, PREF_GOOGLE_SECURE_DEVICES_PIN, - DOMAIN) + DOMAIN, RequireRelink) from homeassistant.components.google_assistant.helpers import ( GoogleEntity) from homeassistant.components.alexa.entities import LightCapabilities @@ -527,6 +527,44 @@ async def test_websocket_update_preferences(hass, hass_ws_client, assert setup_api[PREF_GOOGLE_SECURE_DEVICES_PIN] == '1234' +async def test_websocket_update_preferences_require_relink( + hass, hass_ws_client, aioclient_mock, setup_api, mock_cloud_login): + """Test updating preference requires relink.""" + client = await hass_ws_client(hass) + + with patch('homeassistant.components.cloud.alexa_config.AlexaConfig' + '.async_get_access_token', + side_effect=RequireRelink): + await client.send_json({ + 'id': 5, + 'type': 'cloud/update_prefs', + 'alexa_report_state': True, + }) + response = await client.receive_json() + + assert not response['success'] + assert response['error']['code'] == 'alexa_relink' + + +async def test_websocket_update_preferences_no_token( + hass, hass_ws_client, aioclient_mock, setup_api, mock_cloud_login): + """Test updating preference no token available.""" + client = await hass_ws_client(hass) + + with patch('homeassistant.components.cloud.alexa_config.AlexaConfig' + '.async_get_access_token', + side_effect=alexa_errors.NoTokenAvailable): + await client.send_json({ + 'id': 5, + 'type': 'cloud/update_prefs', + 'alexa_report_state': True, + }) + response = await client.receive_json() + + assert not response['success'] + assert response['error']['code'] == 'alexa_relink' + + async def test_enabling_webhook(hass, hass_ws_client, setup_api, mock_cloud_login): """Test we call right code to enable webhooks.""" From 01b6830fd2e9680807297a02e722ce345bd42bd9 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 26 Jun 2019 21:25:33 -0700 Subject: [PATCH 4/4] Bumped version to 0.95.1 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index 6cf77275f6e..de5dac85c8f 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -2,7 +2,7 @@ """Constants used by Home Assistant components.""" MAJOR_VERSION = 0 MINOR_VERSION = 95 -PATCH_VERSION = '0' +PATCH_VERSION = '1' __short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION) __version__ = '{}.{}'.format(__short_version__, PATCH_VERSION) REQUIRED_PYTHON_VER = (3, 5, 3)