From ff32c1c3e9241e8659c3e7134f1853984cce30d5 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Sun, 22 Mar 2020 12:17:48 +0100 Subject: [PATCH 01/19] Update azure-pipelines-wheels.yml --- azure-pipelines-wheels.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azure-pipelines-wheels.yml b/azure-pipelines-wheels.yml index cd04feb4638..dafae49d89c 100644 --- a/azure-pipelines-wheels.yml +++ b/azure-pipelines-wheels.yml @@ -18,7 +18,7 @@ schedules: always: true variables: - name: versionWheels - value: '1.4-3.7-alpine3.10' + value: '1.7.0-3.7-alpine3.11' resources: repositories: - repository: azure @@ -32,6 +32,7 @@ jobs: builderVersion: '$(versionWheels)' builderApk: 'build-base;cmake;git;linux-headers;bluez-dev;libffi-dev;openssl-dev;glib-dev;eudev-dev;libxml2-dev;libxslt-dev;libpng-dev;libjpeg-turbo-dev;tiff-dev;autoconf;automake;cups-dev;gmp-dev;mpfr-dev;mpc1-dev;ffmpeg-dev;gammu-dev' builderPip: 'Cython;numpy' + skipBinary: 'aiohttp' wheelsRequirement: 'requirements_wheels.txt' wheelsRequirementDiff: 'requirements_diff.txt' preBuild: From 4c31829832275ce9e86d7a98276d8ce97482564f Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Sun, 22 Mar 2020 12:31:14 +0100 Subject: [PATCH 02/19] [skip ci] update wheels builder version --- azure-pipelines-wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines-wheels.yml b/azure-pipelines-wheels.yml index dafae49d89c..81d76708edc 100644 --- a/azure-pipelines-wheels.yml +++ b/azure-pipelines-wheels.yml @@ -18,7 +18,7 @@ schedules: always: true variables: - name: versionWheels - value: '1.7.0-3.7-alpine3.11' + value: '1.8.0-3.7-alpine3.11' resources: repositories: - repository: azure From f4cc64d289902cce1c3696ac513f19708f6d40cc Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Sun, 22 Mar 2020 16:37:33 +0100 Subject: [PATCH 03/19] [skip ci] add rc into build --- azure-pipelines-wheels.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines-wheels.yml b/azure-pipelines-wheels.yml index 81d76708edc..816e64d29bf 100644 --- a/azure-pipelines-wheels.yml +++ b/azure-pipelines-wheels.yml @@ -5,6 +5,7 @@ trigger: branches: include: - dev + - rc paths: include: - requirements_all.txt From fa43a218d254fdcd513cc65c4f6fe4464f1de304 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Sun, 22 Mar 2020 19:40:25 +0100 Subject: [PATCH 04/19] Update azure-pipelines-wheels.yml for Azure Pipelines --- azure-pipelines-wheels.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/azure-pipelines-wheels.yml b/azure-pipelines-wheels.yml index 816e64d29bf..a01e81789ab 100644 --- a/azure-pipelines-wheels.yml +++ b/azure-pipelines-wheels.yml @@ -71,9 +71,5 @@ jobs: sed -i "s|# py_noaa|py_noaa|g" ${requirement_file} sed -i "s|# bme680|bme680|g" ${requirement_file} sed -i "s|# python-gammu|python-gammu|g" ${requirement_file} - - if [[ "$(buildArch)" =~ arm ]]; then - sed -i "s|# VL53L1X|VL53L1X|g" ${requirement_file} - fi done displayName: 'Prepare requirements files for Hass.io' From c218ff5a757563945604cd71fa91e614bfeb6d30 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Mon, 23 Mar 2020 00:39:37 +0100 Subject: [PATCH 05/19] Integrate dockerbuild (#33168) * Integrate dockerbuild * cleanup --- .dockerignore | 6 ++++++ Dockerfile | 17 +++++++++++++++++ azure-pipelines-release.yml | 8 +++----- build.json | 14 ++++++++++++++ rootfs/etc/services.d/home-assistant/finish | 5 +++++ rootfs/etc/services.d/home-assistant/run | 7 +++++++ 6 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 Dockerfile create mode 100644 build.json create mode 100644 rootfs/etc/services.d/home-assistant/finish create mode 100644 rootfs/etc/services.d/home-assistant/run diff --git a/.dockerignore b/.dockerignore index 3d8c32cfb92..8144367ede1 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,9 +2,15 @@ .git .github config +docs + +# Development +.devcontainer +.vscode # Test related files .tox +tests # Other virtualization methods venv diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000000..8853314ae80 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +ARG BUILD_FROM +FROM ${BUILD_FROM}:6.1.0 + +WORKDIR /usr/src + +## Setup Home Assistant +COPY . homeassistant/ +RUN pip3 install --no-cache-dir --no-index --only-binary=:all: --find-links "${WHEELS_LINKS}" \ + -r homeassistant/requirements_all.txt -c homeassistant/homeassistant/package_constraints.txt \ + && pip3 install --no-cache-dir --no-index --only-binary=:all: --find-links "${WHEELS_LINKS}" \ + -e ./homeassistant \ + && python3 -m compileall homeassistant/homeassistant + +# Home Assistant S6-Overlay +COPY rootfs / + +WORKDIR /config diff --git a/azure-pipelines-release.yml b/azure-pipelines-release.yml index 34827897749..7bf8e3ddfb2 100644 --- a/azure-pipelines-release.yml +++ b/azure-pipelines-release.yml @@ -14,7 +14,7 @@ schedules: always: true variables: - name: versionBuilder - value: '6.9' + value: '7.2.0' - group: docker - group: github - group: twine @@ -108,11 +108,9 @@ stages: docker run --rm --privileged \ -v ~/.docker:/root/.docker:rw \ -v /run/docker.sock:/run/docker.sock:rw \ - -v $(pwd):/homeassistant:ro \ + -v $(pwd):/data:ro \ homeassistant/amd64-builder:$(versionBuilder) \ - --homeassistant $(homeassistantRelease) "--$(buildArch)" \ - -r https://github.com/home-assistant/hassio-homeassistant \ - -t generic --docker-hub homeassistant + --generic $(homeassistantRelease) "--$(buildArch)" -t /data \ docker run --rm --privileged \ -v ~/.docker:/root/.docker \ diff --git a/build.json b/build.json new file mode 100644 index 00000000000..c61a693af1c --- /dev/null +++ b/build.json @@ -0,0 +1,14 @@ +{ + "image": "homeassistant/{arch}-homeassistant", + "build_from": { + "aarch64": "homeassistant/aarch64-homeassistant-base:7.0.1", + "armhf": "homeassistant/armhf-homeassistant-base:7.0.1", + "armv7": "homeassistant/armv7-homeassistant-base:7.0.1", + "amd64": "homeassistant/amd64-homeassistant-base:7.0.1", + "i386": "homeassistant/i386-homeassistant-base:7.0.1" + }, + "labels": { + "io.hass.type": "core" + }, + "version_tag": true +} diff --git a/rootfs/etc/services.d/home-assistant/finish b/rootfs/etc/services.d/home-assistant/finish new file mode 100644 index 00000000000..84b7abcab8b --- /dev/null +++ b/rootfs/etc/services.d/home-assistant/finish @@ -0,0 +1,5 @@ +#!/usr/bin/execlineb -S0 +# ============================================================================== +# Take down the S6 supervision tree when Home Assistant fails +# ============================================================================== +s6-svscanctl -t /var/run/s6/services \ No newline at end of file diff --git a/rootfs/etc/services.d/home-assistant/run b/rootfs/etc/services.d/home-assistant/run new file mode 100644 index 00000000000..a153db56b61 --- /dev/null +++ b/rootfs/etc/services.d/home-assistant/run @@ -0,0 +1,7 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Start Home Assistant service +# ============================================================================== +cd /config || bashio::exit.nok "Can't find config folder!" + +exec python3 -m homeassistant --config /config From 884c346bdf63a24d5a61eb4adc3c1b4c62e5b921 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Mon, 23 Mar 2020 01:00:00 +0100 Subject: [PATCH 06/19] Fix dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8853314ae80..647c2b8ac07 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ ARG BUILD_FROM -FROM ${BUILD_FROM}:6.1.0 +FROM ${BUILD_FROM} WORKDIR /usr/src From e0f2fa33df49f3d4d1eca769a4ccd99f26448dec Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Mon, 23 Mar 2020 13:14:50 +0100 Subject: [PATCH 07/19] [skip ci] Update azure-pipelines-wheels.yml for Azure Pipelines --- azure-pipelines-wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines-wheels.yml b/azure-pipelines-wheels.yml index a01e81789ab..2fc0ee39018 100644 --- a/azure-pipelines-wheels.yml +++ b/azure-pipelines-wheels.yml @@ -19,7 +19,7 @@ schedules: always: true variables: - name: versionWheels - value: '1.8.0-3.7-alpine3.11' + value: '1.9.0-3.7-alpine3.11' resources: repositories: - repository: azure From 181b2803cd25cb28a79510546437f881e652e2e8 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Mon, 23 Mar 2020 16:54:06 +0100 Subject: [PATCH 08/19] Update azure-pipelines-wheels.yml for Azure Pipelines --- azure-pipelines-wheels.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azure-pipelines-wheels.yml b/azure-pipelines-wheels.yml index 2fc0ee39018..3ed413f4678 100644 --- a/azure-pipelines-wheels.yml +++ b/azure-pipelines-wheels.yml @@ -19,7 +19,7 @@ schedules: always: true variables: - name: versionWheels - value: '1.9.0-3.7-alpine3.11' + value: '1.10.0-3.7-alpine3.11' resources: repositories: - repository: azure @@ -36,6 +36,7 @@ jobs: skipBinary: 'aiohttp' wheelsRequirement: 'requirements_wheels.txt' wheelsRequirementDiff: 'requirements_diff.txt' + wheelsConstraint: 'homeassistant/package_constraints.txt' preBuild: - script: | cp requirements_all.txt requirements_wheels.txt From 95de94e53ff1f9a3b82a602109a2c66ceea30939 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Mon, 23 Mar 2020 17:47:43 +0100 Subject: [PATCH 09/19] Update azure-pipelines-wheels.yml for Azure Pipelines --- azure-pipelines-wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines-wheels.yml b/azure-pipelines-wheels.yml index 3ed413f4678..b4ad0a556b2 100644 --- a/azure-pipelines-wheels.yml +++ b/azure-pipelines-wheels.yml @@ -19,7 +19,7 @@ schedules: always: true variables: - name: versionWheels - value: '1.10.0-3.7-alpine3.11' + value: '1.10.1-3.7-alpine3.11' resources: repositories: - repository: azure From 7a6ac578b41292c7a36d72bc259fa48456d22410 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sun, 22 Mar 2020 05:29:50 -0700 Subject: [PATCH 10/19] Fix script logging with name (#33120) --- homeassistant/helpers/script.py | 4 +++- tests/helpers/test_script.py | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/homeassistant/helpers/script.py b/homeassistant/helpers/script.py index 937a675aada..4fe6d062bd5 100644 --- a/homeassistant/helpers/script.py +++ b/homeassistant/helpers/script.py @@ -701,7 +701,9 @@ class Script: def _log(self, msg, *args, level=logging.INFO): if self.name: - msg = f"{self.name}: {msg}" + msg = f"%s: {msg}" + args = [self.name, *args] + if level == _LOG_EXCEPTION: self._logger.exception(msg, *args) else: diff --git a/tests/helpers/test_script.py b/tests/helpers/test_script.py index 443b131b2aa..5f0281d3f95 100644 --- a/tests/helpers/test_script.py +++ b/tests/helpers/test_script.py @@ -1743,3 +1743,15 @@ async def test_if_running_parallel(hass): assert len(events) == 4 assert events[2].data["value"] == 2 assert events[3].data["value"] == 2 + + +async def test_script_logging(caplog): + """Test script logging.""" + script_obj = script.Script(None, [], "Script with % Name") + script_obj._log("Test message with name %s", 1) + + assert "Script with % Name: Test message with name 1" in caplog.text + + script_obj = script.Script(None, []) + script_obj._log("Test message without name %s", 2) + assert "Test message without name 2" in caplog.text From 253c848692fd6bc4008abf42f97fa970d5dfa600 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Tue, 24 Mar 2020 01:20:39 +0100 Subject: [PATCH 11/19] Fix minut point updating frozen config entry data (#33148) * Fix minut point updating frozen config entry data * Update webhooks handling for configuration entry --- homeassistant/components/point/__init__.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/point/__init__.py b/homeassistant/components/point/__init__.py index 9abae9ab025..2817871cd7c 100644 --- a/homeassistant/components/point/__init__.py +++ b/homeassistant/components/point/__init__.py @@ -75,8 +75,9 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry): def token_saver(token): _LOGGER.debug("Saving updated token") - entry.data[CONF_TOKEN] = token - hass.config_entries.async_update_entry(entry, data={**entry.data}) + hass.config_entries.async_update_entry( + entry, data={**entry.data, CONF_TOKEN: token} + ) # Force token update. entry.data[CONF_TOKEN]["expires_in"] = -1 @@ -105,12 +106,18 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry): async def async_setup_webhook(hass: HomeAssistantType, entry: ConfigEntry, session): """Set up a webhook to handle binary sensor events.""" if CONF_WEBHOOK_ID not in entry.data: - entry.data[CONF_WEBHOOK_ID] = hass.components.webhook.async_generate_id() - entry.data[CONF_WEBHOOK_URL] = hass.components.webhook.async_generate_url( - entry.data[CONF_WEBHOOK_ID] + webhook_id = hass.components.webhook.async_generate_id() + webhook_url = hass.components.webhook.async_generate_url(webhook_id) + _LOGGER.info("Registering new webhook at: %s", webhook_url) + + hass.config_entries.async_update_entry( + entry, + data={ + **entry.data, + CONF_WEBHOOK_ID: webhook_id, + CONF_WEBHOOK_URL: webhook_url, + }, ) - _LOGGER.info("Registering new webhook at: %s", entry.data[CONF_WEBHOOK_URL]) - hass.config_entries.async_update_entry(entry, data={**entry.data}) await hass.async_add_executor_job( session.update_webhook, entry.data[CONF_WEBHOOK_URL], From b36b1dbc70d150d0abb4432eb55c54544d6a2157 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Tue, 24 Mar 2020 12:04:33 +0100 Subject: [PATCH 12/19] Bump OZW fork to 0.1.10 (#33205) --- homeassistant/components/zwave/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/zwave/manifest.json b/homeassistant/components/zwave/manifest.json index 81978aa96cd..72d61b278dd 100644 --- a/homeassistant/components/zwave/manifest.json +++ b/homeassistant/components/zwave/manifest.json @@ -3,7 +3,7 @@ "name": "Z-Wave", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/zwave", - "requirements": ["homeassistant-pyozw==0.1.9", "pydispatcher==2.0.5"], + "requirements": ["homeassistant-pyozw==0.1.10", "pydispatcher==2.0.5"], "dependencies": [], "codeowners": ["@home-assistant/z-wave"] } diff --git a/requirements_all.txt b/requirements_all.txt index 79e8a1154fa..8f27c68655f 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -699,7 +699,7 @@ holidays==0.10.1 home-assistant-frontend==20200318.1 # homeassistant.components.zwave -homeassistant-pyozw==0.1.9 +homeassistant-pyozw==0.1.10 # homeassistant.components.homematicip_cloud homematicip==0.10.17 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index b7500916925..eaeca47589d 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -266,7 +266,7 @@ holidays==0.10.1 home-assistant-frontend==20200318.1 # homeassistant.components.zwave -homeassistant-pyozw==0.1.9 +homeassistant-pyozw==0.1.10 # homeassistant.components.homematicip_cloud homematicip==0.10.17 From edfe8e15834f09cd2daad05901f81d91e594c200 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Tue, 24 Mar 2020 11:50:25 +0000 Subject: [PATCH 13/19] Bump version to 0.107.6 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index c758ad4dd5f..781eae6d836 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -1,7 +1,7 @@ """Constants used by Home Assistant components.""" MAJOR_VERSION = 0 MINOR_VERSION = 107 -PATCH_VERSION = "5" +PATCH_VERSION = "6" __short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}" __version__ = f"{__short_version__}.{PATCH_VERSION}" REQUIRED_PYTHON_VER = (3, 7, 0) From 9365ba3fcfbe3d7d24b76491d9296060429d8813 Mon Sep 17 00:00:00 2001 From: brefra Date: Tue, 24 Mar 2020 21:58:50 +0100 Subject: [PATCH 14/19] Fix velbus dimming control (#33139) * Fix light control * Optimize conversion logic --- homeassistant/components/velbus/light.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/velbus/light.py b/homeassistant/components/velbus/light.py index d428b766edc..d7654feab2d 100644 --- a/homeassistant/components/velbus/light.py +++ b/homeassistant/components/velbus/light.py @@ -64,7 +64,7 @@ class VelbusLight(VelbusEntity, Light): @property def brightness(self): """Return the brightness of the light.""" - return self._module.get_dimmer_state(self._channel) + return int((self._module.get_dimmer_state(self._channel) * 255) / 100) def turn_on(self, **kwargs): """Instruct the Velbus light to turn on.""" @@ -80,10 +80,15 @@ class VelbusLight(VelbusEntity, Light): attr, *args = "set_led_state", self._channel, "on" else: if ATTR_BRIGHTNESS in kwargs: + # Make sure a low but non-zero value is not rounded down to zero + if kwargs[ATTR_BRIGHTNESS] == 0: + brightness = 0 + else: + brightness = max(int((kwargs[ATTR_BRIGHTNESS] * 100) / 255), 1) attr, *args = ( "set_dimmer_state", self._channel, - kwargs[ATTR_BRIGHTNESS], + brightness, kwargs.get(ATTR_TRANSITION, 0), ) else: From d54d7c695888977489e80cf79a9fe1c3c12fca0c Mon Sep 17 00:00:00 2001 From: Diogo Gomes Date: Tue, 24 Mar 2020 12:17:31 +0000 Subject: [PATCH 15/19] Increase timeout setting up IPMA (#33194) --- homeassistant/components/ipma/weather.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/ipma/weather.py b/homeassistant/components/ipma/weather.py index 1fce3922b58..62f1b0b39af 100644 --- a/homeassistant/components/ipma/weather.py +++ b/homeassistant/components/ipma/weather.py @@ -104,7 +104,7 @@ async def async_get_api(hass): async def async_get_location(hass, api, latitude, longitude): """Retrieve pyipma location, location name to be used as the entity name.""" - with async_timeout.timeout(10): + with async_timeout.timeout(30): location = await Location.get(api, float(latitude), float(longitude)) _LOGGER.debug( From 1236c2b91e33c4771fe5b0d4dbddebeeb62f6cf6 Mon Sep 17 00:00:00 2001 From: Alexei Chetroi Date: Tue, 24 Mar 2020 20:32:46 -0400 Subject: [PATCH 16/19] Refactor ZHA platform setup (#33226) Setup ZHA platforms only after successful gateway startup. --- homeassistant/components/zha/__init__.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/homeassistant/components/zha/__init__.py b/homeassistant/components/zha/__init__.py index 63659a47e0d..5fef586d5cf 100644 --- a/homeassistant/components/zha/__init__.py +++ b/homeassistant/components/zha/__init__.py @@ -93,14 +93,10 @@ async def async_setup_entry(hass, config_entry): """ zha_data = hass.data.setdefault(DATA_ZHA, {}) - zha_data[DATA_ZHA_PLATFORM_LOADED] = {} config = zha_data.get(DATA_ZHA_CONFIG, {}) - zha_data[DATA_ZHA_DISPATCHERS] = [] for component in COMPONENTS: - zha_data[component] = [] - coro = hass.config_entries.async_forward_entry_setup(config_entry, component) - zha_data[DATA_ZHA_PLATFORM_LOADED][component] = hass.async_create_task(coro) + zha_data.setdefault(component, []) if config.get(CONF_ENABLE_QUIRKS, True): # needs to be done here so that the ZHA module is finished loading @@ -110,6 +106,12 @@ async def async_setup_entry(hass, config_entry): zha_gateway = ZHAGateway(hass, config, config_entry) await zha_gateway.async_initialize() + zha_data[DATA_ZHA_DISPATCHERS] = [] + zha_data[DATA_ZHA_PLATFORM_LOADED] = [] + for component in COMPONENTS: + coro = hass.config_entries.async_forward_entry_setup(config_entry, component) + zha_data[DATA_ZHA_PLATFORM_LOADED].append(hass.async_create_task(coro)) + device_registry = await hass.helpers.device_registry.async_get_registry() device_registry.async_get_or_create( config_entry_id=config_entry.entry_id, @@ -128,7 +130,7 @@ async def async_setup_entry(hass, config_entry): await zha_data[DATA_ZHA_GATEWAY].async_update_device_storage() hass.bus.async_listen_once(ha_const.EVENT_HOMEASSISTANT_STOP, async_zha_shutdown) - hass.async_create_task(async_load_entities(hass, config_entry)) + asyncio.create_task(async_load_entities(hass, config_entry)) return True @@ -153,11 +155,7 @@ async def async_load_entities( ) -> None: """Load entities after integration was setup.""" await hass.data[DATA_ZHA][DATA_ZHA_GATEWAY].async_prepare_entities() - to_setup = [ - hass.data[DATA_ZHA][DATA_ZHA_PLATFORM_LOADED][comp] - for comp in COMPONENTS - if hass.data[DATA_ZHA][comp] - ] + to_setup = hass.data[DATA_ZHA][DATA_ZHA_PLATFORM_LOADED] results = await asyncio.gather(*to_setup, return_exceptions=True) for res in results: if isinstance(res, Exception): From cced74740f6bed4565cfef933d4a2f3d0e52f2fc Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 25 Mar 2020 15:08:20 -0500 Subject: [PATCH 17/19] =?UTF-8?q?Ensure=20recorder=20event=20loop=20recove?= =?UTF-8?q?rs=20if=20the=20database=20server=20dis=E2=80=A6=20(#33253)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the database server disconnects there were exceptions that were not trapped which would cause the recorder event loop to collapse. As we never want the loop to end we trap exceptions broadly. Fix a bug in the new commit interval setting which caused it to always commit after 1s --- homeassistant/components/recorder/__init__.py | 47 +++++++++++++------ 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/homeassistant/components/recorder/__init__.py b/homeassistant/components/recorder/__init__.py index a662a457add..ffd37720053 100644 --- a/homeassistant/components/recorder/__init__.py +++ b/homeassistant/components/recorder/__init__.py @@ -342,7 +342,6 @@ class Recorder(threading.Thread): # has changed. This reduces the disk io. while True: event = self.queue.get() - if event is None: self._close_run() self._close_connection() @@ -356,7 +355,7 @@ class Recorder(threading.Thread): self.queue.task_done() if self.commit_interval: self._timechanges_seen += 1 - if self.commit_interval >= self._timechanges_seen: + if self._timechanges_seen >= self.commit_interval: self._timechanges_seen = 0 self._commit_event_session_or_retry() continue @@ -376,6 +375,9 @@ class Recorder(threading.Thread): self.event_session.flush() except (TypeError, ValueError): _LOGGER.warning("Event is not JSON serializable: %s", event) + except Exception as err: # pylint: disable=broad-except + # Must catch the exception to prevent the loop from collapsing + _LOGGER.exception("Error adding event: %s", err) if dbevent and event.event_type == EVENT_STATE_CHANGED: try: @@ -387,6 +389,9 @@ class Recorder(threading.Thread): "State is not JSON serializable: %s", event.data.get("new_state"), ) + except Exception as err: # pylint: disable=broad-except + # Must catch the exception to prevent the loop from collapsing + _LOGGER.exception("Error adding state change: %s", err) # If they do not have a commit interval # than we commit right away @@ -404,17 +409,26 @@ class Recorder(threading.Thread): try: self._commit_event_session() return - - except exc.OperationalError as err: - _LOGGER.error( - "Error in database connectivity: %s. " "(retrying in %s seconds)", - err, - self.db_retry_wait, - ) + except (exc.InternalError, exc.OperationalError) as err: + if err.connection_invalidated: + _LOGGER.error( + "Database connection invalidated: %s. " + "(retrying in %s seconds)", + err, + self.db_retry_wait, + ) + else: + _LOGGER.error( + "Error in database connectivity: %s. " + "(retrying in %s seconds)", + err, + self.db_retry_wait, + ) tries += 1 - except exc.SQLAlchemyError: - _LOGGER.exception("Error saving events") + except Exception as err: # pylint: disable=broad-except + # Must catch the exception to prevent the loop from collapsing + _LOGGER.exception("Error saving events: %s", err) return _LOGGER.error( @@ -423,10 +437,15 @@ class Recorder(threading.Thread): ) try: self.event_session.close() - except exc.SQLAlchemyError: - _LOGGER.exception("Failed to close event session.") + except Exception as err: # pylint: disable=broad-except + # Must catch the exception to prevent the loop from collapsing + _LOGGER.exception("Error while closing event session: %s", err) - self.event_session = self.get_session() + try: + self.event_session = self.get_session() + except Exception as err: # pylint: disable=broad-except + # Must catch the exception to prevent the loop from collapsing + _LOGGER.exception("Error while creating new event session: %s", err) def _commit_event_session(self): try: From a38e075bda2debd7cae359ba494e70a8c32cfbdd Mon Sep 17 00:00:00 2001 From: jjlawren Date: Wed, 25 Mar 2020 18:03:26 -0500 Subject: [PATCH 18/19] Schedule Unifi shutdown callback earlier (#33257) --- homeassistant/components/unifi/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/unifi/__init__.py b/homeassistant/components/unifi/__init__.py index a21ae4ed508..fc69eca3022 100644 --- a/homeassistant/components/unifi/__init__.py +++ b/homeassistant/components/unifi/__init__.py @@ -83,6 +83,8 @@ async def async_setup_entry(hass, config_entry): controller_id = get_controller_id_from_config_entry(config_entry) hass.data[DOMAIN][controller_id] = controller + hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, controller.shutdown) + if controller.mac is None: return True @@ -96,8 +98,6 @@ async def async_setup_entry(hass, config_entry): # sw_version=config.raw['swversion'], ) - hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, controller.shutdown) - return True From eac03ef4be2d5135e95cc55da38a0c0f889630c1 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 25 Mar 2020 16:04:19 -0700 Subject: [PATCH 19/19] Bumped version to 0.107.7 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index 781eae6d836..968c98e073b 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -1,7 +1,7 @@ """Constants used by Home Assistant components.""" MAJOR_VERSION = 0 MINOR_VERSION = 107 -PATCH_VERSION = "6" +PATCH_VERSION = "7" __short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}" __version__ = f"{__short_version__}.{PATCH_VERSION}" REQUIRED_PYTHON_VER = (3, 7, 0)