From 204dd77404b0c301c9124fd79aca36cd564333d2 Mon Sep 17 00:00:00 2001 From: cgtobi Date: Fri, 28 Jun 2019 05:16:46 +0200 Subject: [PATCH 1/7] Fix netatmo weatherstation setup error (#24788) * Check if station data exists and reduce calls * Fix module names list * Add warning * Remove dead code --- homeassistant/components/netatmo/sensor.py | 42 ++++++++++++---------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/homeassistant/components/netatmo/sensor.py b/homeassistant/components/netatmo/sensor.py index 48d82eca2f0..9902fedde8f 100644 --- a/homeassistant/components/netatmo/sensor.py +++ b/homeassistant/components/netatmo/sensor.py @@ -99,6 +99,12 @@ MODULE_TYPE_RAIN = 'NAModule3' MODULE_TYPE_INDOOR = 'NAModule4' +NETATMO_DEVICE_TYPES = { + 'WeatherStationData': 'weather station', + 'HomeCoachData': 'home coach' +} + + def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the available Netatmo weather sensors.""" dev = [] @@ -132,7 +138,14 @@ def setup_platform(hass, config, add_entities, discovery_info=None): import pyatmo for data_class in [pyatmo.WeatherStationData, pyatmo.HomeCoachData]: - data = NetatmoData(auth, data_class, config.get(CONF_STATION)) + try: + data = NetatmoData(auth, data_class, config.get(CONF_STATION)) + except pyatmo.NoDevice: + _LOGGER.warning( + "No %s devices found", + NETATMO_DEVICE_TYPES[data_class.__name__] + ) + continue # Test if manually configured if CONF_MODULES in config: module_items = config[CONF_MODULES].items() @@ -157,18 +170,11 @@ def setup_platform(hass, config, add_entities, discovery_info=None): def find_devices(data): """Find all devices.""" dev = [] - not_handled = [] - for module_name in data.get_module_names(): - if (module_name not in data.get_module_names() - and module_name not in not_handled): - not_handled.append(not_handled) - continue + module_names = data.get_module_names() + for module_name in module_names: for condition in data.station_data.monitoredConditions(module_name): dev.append(NetatmoSensor( data, module_name, condition.lower(), data.station)) - - for module_name in not_handled: - _LOGGER.error('Module name: "%s" not found', module_name) return dev @@ -187,12 +193,11 @@ class NetatmoSensor(Entity): self._device_class = SENSOR_TYPES[self.type][3] self._icon = SENSOR_TYPES[self.type][2] self._unit_of_measurement = SENSOR_TYPES[self.type][1] - self._module_type = self.netatmo_data. \ - station_data.moduleByName(module=module_name)['type'] - module_id = self.netatmo_data. \ - station_data.moduleByName(station=self.station_name, - module=module_name)['_id'] - self._unique_id = '{}-{}'.format(module_id, self.type) + module = self.netatmo_data.station_data.moduleByName( + station=self.station_name, module=module_name + ) + self._module_type = module['type'] + self._unique_id = '{}-{}'.format(module['_id'], self.type) @property def name(self): @@ -515,15 +520,14 @@ class NetatmoData: self.auth = auth self.data_class = data_class self.data = {} - self.station_data = None + self.station_data = self.data_class(self.auth) self.station = station self._next_update = time() self._update_in_progress = threading.Lock() def get_module_names(self): """Return all module available on the API as a list.""" - self.update() - return self.data.keys() + return self.station_data.modulesNamesList() def update(self): """Call the Netatmo API to update the data. From 1f5e2fa3ce50f156fd629b035f23a8dd3352f8e1 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Thu, 27 Jun 2019 18:26:13 +0200 Subject: [PATCH 2/7] Update azure-pipelines-release.yml for Azure Pipelines (#24800) --- azure-pipelines-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines-release.yml b/azure-pipelines-release.yml index d6395dad5ac..af737290143 100644 --- a/azure-pipelines-release.yml +++ b/azure-pipelines-release.yml @@ -8,7 +8,7 @@ trigger: pr: none variables: - name: versionBuilder - value: '4.2' + value: '4.5' - group: docker - group: github - group: twine From e39f0f3e259aa67f9031c4b19b7bd6a67e7216c5 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 27 Jun 2019 12:17:42 -0700 Subject: [PATCH 3/7] Make sure entity config is never none (#24801) --- homeassistant/components/google_assistant/http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/google_assistant/http.py b/homeassistant/components/google_assistant/http.py index 95528eea3ca..8f6d441d498 100644 --- a/homeassistant/components/google_assistant/http.py +++ b/homeassistant/components/google_assistant/http.py @@ -37,7 +37,7 @@ class GoogleConfig(AbstractConfig): @property def entity_config(self): """Return entity config.""" - return self._config.get(CONF_ENTITY_CONFIG, {}) + return self._config.get(CONF_ENTITY_CONFIG) or {} @property def secure_devices_pin(self): From 1990df63aaa249dd3f427ab5ff6b43d488429b5a Mon Sep 17 00:00:00 2001 From: "David F. Mulcahey" Date: Thu, 27 Jun 2019 15:28:56 -0400 Subject: [PATCH 4/7] Bump ZHA quirks module (#24802) * bump quirks version * bump version - mija magnet --- homeassistant/components/zha/manifest.json | 2 +- requirements_all.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/zha/manifest.json b/homeassistant/components/zha/manifest.json index 15fcf38100f..7f067353b37 100644 --- a/homeassistant/components/zha/manifest.json +++ b/homeassistant/components/zha/manifest.json @@ -5,7 +5,7 @@ "documentation": "https://www.home-assistant.io/components/zha", "requirements": [ "bellows-homeassistant==0.8.2", - "zha-quirks==0.0.15", + "zha-quirks==0.0.17", "zigpy-deconz==0.1.6", "zigpy-homeassistant==0.6.1", "zigpy-xbee-homeassistant==0.3.0" diff --git a/requirements_all.txt b/requirements_all.txt index e763a02b754..081f357b52c 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1917,7 +1917,7 @@ zengge==0.2 zeroconf==0.23.0 # homeassistant.components.zha -zha-quirks==0.0.15 +zha-quirks==0.0.17 # homeassistant.components.zhong_hong zhong_hong_hvac==1.0.9 From fafc68673a557d0cb75c47f928048ac99e27c2c3 Mon Sep 17 00:00:00 2001 From: Phil Bruckner Date: Thu, 27 Jun 2019 17:11:32 -0500 Subject: [PATCH 5/7] Fix another Life360 bug (#24805) --- homeassistant/components/life360/device_tracker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/life360/device_tracker.py b/homeassistant/components/life360/device_tracker.py index 4329f2a162b..abf97ffa7b8 100644 --- a/homeassistant/components/life360/device_tracker.py +++ b/homeassistant/components/life360/device_tracker.py @@ -294,7 +294,6 @@ class Life360Scanner: member_id = member['id'] if member_id in members_updated: continue - members_updated.append(member_id) err_key = 'Member data' try: first = member.get('firstName') @@ -318,6 +317,7 @@ class Life360Scanner: self._ok(err_key) if include_member and sharing: + members_updated.append(member_id) self._update_member(member, dev_id) def _update_life360(self, now=None): From 2886b217ab97055edce8aa53185eb65ef66aeb5d Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 28 Jun 2019 08:49:33 -0700 Subject: [PATCH 6/7] Fix calling empty script turn off (#24827) --- homeassistant/components/script/__init__.py | 7 ++++++- tests/components/script/test_init.py | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/script/__init__.py b/homeassistant/components/script/__init__.py index 36cb144fada..495df2c5e17 100644 --- a/homeassistant/components/script/__init__.py +++ b/homeassistant/components/script/__init__.py @@ -79,9 +79,14 @@ async def async_setup(hass, config): async def turn_off_service(service): """Cancel a script.""" # Stopping a script is ok to be done in parallel + scripts = await component.async_extract_from_service(service) + + if not scripts: + return + await asyncio.wait([ script.async_turn_off() for script - in await component.async_extract_from_service(service) + in scripts ]) async def toggle_service(service): diff --git a/tests/components/script/test_init.py b/tests/components/script/test_init.py index c2ff17d9444..9e0b751c430 100644 --- a/tests/components/script/test_init.py +++ b/tests/components/script/test_init.py @@ -322,3 +322,13 @@ async def test_logging_script_error(hass, caplog): assert err.value.domain == 'non' assert err.value.service == 'existing' assert 'Error executing script' in caplog.text + + +async def test_turning_no_scripts_off(hass): + """Test it is possible to turn two scripts off.""" + assert await async_setup_component(hass, 'script', {}) + + # Testing it doesn't raise + await hass.services.async_call( + DOMAIN, SERVICE_TURN_OFF, {'entity_id': []}, blocking=True + ) From 6cbfc63311fb20d628ff32f11c2ce976abdcb50b Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 28 Jun 2019 08:50:23 -0700 Subject: [PATCH 7/7] Bumped version to 0.95.2 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index de5dac85c8f..2345c5fbe63 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 = '1' +PATCH_VERSION = '2' __short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION) __version__ = '{}.{}'.format(__short_version__, PATCH_VERSION) REQUIRED_PYTHON_VER = (3, 5, 3)