From 6f4302ff7026fec143c2fd6c2cf05dcfcc73896c Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 4 Jun 2021 10:02:42 -0700 Subject: [PATCH 01/10] Hot fix version of Apply modbus interval patch (#51487) --- homeassistant/components/modbus/__init__.py | 20 +++++++++++--------- homeassistant/components/modbus/const.py | 1 - 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/modbus/__init__.py b/homeassistant/components/modbus/__init__.py index d1c3c1a0c8a..e27549df169 100644 --- a/homeassistant/components/modbus/__init__.py +++ b/homeassistant/components/modbus/__init__.py @@ -99,7 +99,6 @@ from .const import ( DEFAULT_SCAN_INTERVAL, DEFAULT_STRUCTURE_PREFIX, DEFAULT_TEMP_UNIT, - MINIMUM_SCAN_INTERVAL, MODBUS_DOMAIN as DOMAIN, PLATFORMS, ) @@ -139,27 +138,30 @@ def control_scan_interval(config: dict) -> dict: for entry in hub[conf_key]: scan_interval = entry.get(CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL) - if scan_interval < MINIMUM_SCAN_INTERVAL: - if scan_interval == 0: - continue + if scan_interval == 0: + continue + if scan_interval < 5: _LOGGER.warning( - "%s %s scan_interval(%d) is adjusted to minimum(%d)", + "%s %s scan_interval(%d) is lower than 5 seconds, " + "which may cause Home Assistant stability issues", component, entry.get(CONF_NAME), scan_interval, - MINIMUM_SCAN_INTERVAL, ) - scan_interval = MINIMUM_SCAN_INTERVAL entry[CONF_SCAN_INTERVAL] = scan_interval minimum_scan_interval = min(scan_interval, minimum_scan_interval) - if CONF_TIMEOUT in hub and hub[CONF_TIMEOUT] > minimum_scan_interval - 1: + if ( + CONF_TIMEOUT in hub + and hub[CONF_TIMEOUT] > minimum_scan_interval - 1 + and minimum_scan_interval > 1 + ): _LOGGER.warning( "Modbus %s timeout(%d) is adjusted(%d) due to scan_interval", hub.get(CONF_NAME, ""), hub[CONF_TIMEOUT], minimum_scan_interval - 1, ) - hub[CONF_TIMEOUT] = minimum_scan_interval - 1 + hub[CONF_TIMEOUT] = minimum_scan_interval - 1 return config diff --git a/homeassistant/components/modbus/const.py b/homeassistant/components/modbus/const.py index dfec0dbb50a..cfda4a3863a 100644 --- a/homeassistant/components/modbus/const.py +++ b/homeassistant/components/modbus/const.py @@ -90,7 +90,6 @@ SERVICE_WRITE_REGISTER = "write_register" # integration names DEFAULT_HUB = "modbus_hub" -MINIMUM_SCAN_INTERVAL = 5 # seconds DEFAULT_SCAN_INTERVAL = 15 # seconds DEFAULT_SLAVE = 1 DEFAULT_STRUCTURE_PREFIX = ">f" From 756a4c2ea6d034525a2285c6ee8720e572ccd3db Mon Sep 17 00:00:00 2001 From: Florent Thoumie Date: Thu, 3 Jun 2021 23:32:01 -0700 Subject: [PATCH 02/10] Update to iaqualink 0.3.90 (#51452) --- homeassistant/components/iaqualink/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/iaqualink/manifest.json b/homeassistant/components/iaqualink/manifest.json index b3aa257a9b2..26c6e0b4bfd 100644 --- a/homeassistant/components/iaqualink/manifest.json +++ b/homeassistant/components/iaqualink/manifest.json @@ -4,6 +4,6 @@ "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/iaqualink/", "codeowners": ["@flz"], - "requirements": ["iaqualink==0.3.4"], + "requirements": ["iaqualink==0.3.90"], "iot_class": "cloud_polling" } diff --git a/requirements_all.txt b/requirements_all.txt index 96fee9fe3a2..01df5ffd38a 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -807,7 +807,7 @@ hyperion-py==0.7.4 iammeter==0.1.7 # homeassistant.components.iaqualink -iaqualink==0.3.4 +iaqualink==0.3.90 # homeassistant.components.watson_tts ibm-watson==5.1.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index d970fb55180..dab75a4f205 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -457,7 +457,7 @@ huisbaasje-client==0.1.0 hyperion-py==0.7.4 # homeassistant.components.iaqualink -iaqualink==0.3.4 +iaqualink==0.3.90 # homeassistant.components.ping icmplib==2.1.1 From 42c74c1e14e21ae4f8ad153495a3ef2a364aac6a Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 3 Jun 2021 20:54:45 -1000 Subject: [PATCH 03/10] Retry isy994 setup later if isy.initialize times out (#51453) Maybe fixes https://forum.universal-devices.com/topic/26633-home-assistant-isy-component/?do=findComment&comment=312147 --- homeassistant/components/isy994/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/isy994/__init__.py b/homeassistant/components/isy994/__init__.py index 27d81a671c8..99905e4d946 100644 --- a/homeassistant/components/isy994/__init__.py +++ b/homeassistant/components/isy994/__init__.py @@ -1,6 +1,7 @@ """Support the ISY-994 controllers.""" from __future__ import annotations +import asyncio from urllib.parse import urlparse from aiohttp import CookieJar @@ -171,8 +172,14 @@ async def async_setup_entry( ) try: - with async_timeout.timeout(30): + async with async_timeout.timeout(30): await isy.initialize() + except asyncio.TimeoutError as err: + _LOGGER.error( + "Timed out initializing the ISY; device may be busy, trying again later: %s", + err, + ) + raise ConfigEntryNotReady from err except ISYInvalidAuthError as err: _LOGGER.error( "Invalid credentials for the ISY, please adjust settings and try again: %s", From c8655c8e374f7b63dcdfe2cd31e76e9261be0228 Mon Sep 17 00:00:00 2001 From: Matthias Alphart Date: Mon, 31 May 2021 09:58:48 +0200 Subject: [PATCH 04/10] xknx 0.18.3 (#51277) --- homeassistant/components/knx/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/knx/manifest.json b/homeassistant/components/knx/manifest.json index 0a722d46162..b1ed504f7ad 100644 --- a/homeassistant/components/knx/manifest.json +++ b/homeassistant/components/knx/manifest.json @@ -2,7 +2,7 @@ "domain": "knx", "name": "KNX", "documentation": "https://www.home-assistant.io/integrations/knx", - "requirements": ["xknx==0.18.2"], + "requirements": ["xknx==0.18.3"], "codeowners": ["@Julius2342", "@farmio", "@marvin-w"], "quality_scale": "silver", "iot_class": "local_push" diff --git a/requirements_all.txt b/requirements_all.txt index 01df5ffd38a..fbd09d8977b 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2375,7 +2375,7 @@ xbox-webapi==2.0.11 xboxapi==2.0.1 # homeassistant.components.knx -xknx==0.18.2 +xknx==0.18.3 # homeassistant.components.bluesound # homeassistant.components.rest diff --git a/requirements_test_all.txt b/requirements_test_all.txt index dab75a4f205..83c02a03269 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1281,7 +1281,7 @@ wolf_smartset==0.1.8 xbox-webapi==2.0.11 # homeassistant.components.knx -xknx==0.18.2 +xknx==0.18.3 # homeassistant.components.bluesound # homeassistant.components.rest From e10a4c2a91211dfbd81e1c39262aa365a1e94b7e Mon Sep 17 00:00:00 2001 From: Matthias Alphart Date: Fri, 4 Jun 2021 08:34:16 +0200 Subject: [PATCH 05/10] Update xknx to version 0.18.4 (#51459) --- homeassistant/components/knx/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/knx/manifest.json b/homeassistant/components/knx/manifest.json index b1ed504f7ad..6b1d4d328ac 100644 --- a/homeassistant/components/knx/manifest.json +++ b/homeassistant/components/knx/manifest.json @@ -2,7 +2,7 @@ "domain": "knx", "name": "KNX", "documentation": "https://www.home-assistant.io/integrations/knx", - "requirements": ["xknx==0.18.3"], + "requirements": ["xknx==0.18.4"], "codeowners": ["@Julius2342", "@farmio", "@marvin-w"], "quality_scale": "silver", "iot_class": "local_push" diff --git a/requirements_all.txt b/requirements_all.txt index fbd09d8977b..a3889f79c14 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2375,7 +2375,7 @@ xbox-webapi==2.0.11 xboxapi==2.0.1 # homeassistant.components.knx -xknx==0.18.3 +xknx==0.18.4 # homeassistant.components.bluesound # homeassistant.components.rest diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 83c02a03269..3e390cddde6 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1281,7 +1281,7 @@ wolf_smartset==0.1.8 xbox-webapi==2.0.11 # homeassistant.components.knx -xknx==0.18.3 +xknx==0.18.4 # homeassistant.components.bluesound # homeassistant.components.rest From d9c6c3719ce8550455e6459a580f45204eee78a5 Mon Sep 17 00:00:00 2001 From: Aidan Timson Date: Fri, 4 Jun 2021 16:26:44 +0100 Subject: [PATCH 06/10] Bump aiolyric to 1.0.7 (#51473) --- homeassistant/components/lyric/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/lyric/manifest.json b/homeassistant/components/lyric/manifest.json index 6317c6c3357..fbcc9567c3a 100644 --- a/homeassistant/components/lyric/manifest.json +++ b/homeassistant/components/lyric/manifest.json @@ -4,7 +4,7 @@ "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/lyric", "dependencies": ["http"], - "requirements": ["aiolyric==1.0.6"], + "requirements": ["aiolyric==1.0.7"], "codeowners": ["@timmo001"], "quality_scale": "silver", "dhcp": [ diff --git a/requirements_all.txt b/requirements_all.txt index a3889f79c14..decf8ff2967 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -203,7 +203,7 @@ aiolifx_effects==0.2.2 aiolip==1.1.4 # homeassistant.components.lyric -aiolyric==1.0.6 +aiolyric==1.0.7 # homeassistant.components.keyboard_remote aionotify==0.2.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 3e390cddde6..009cfd2c790 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -128,7 +128,7 @@ aiokafka==0.6.0 aiolip==1.1.4 # homeassistant.components.lyric -aiolyric==1.0.6 +aiolyric==1.0.7 # homeassistant.components.notion aionotion==1.1.0 From 6dcde1b2a67dd1d81a27f369e59bf5826dd7487b Mon Sep 17 00:00:00 2001 From: Simone Chemelli Date: Fri, 4 Jun 2021 18:02:39 +0200 Subject: [PATCH 07/10] Improve logging for SamsungTV (#51477) --- homeassistant/components/samsungtv/bridge.py | 10 ++++++---- homeassistant/components/samsungtv/config_flow.py | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/samsungtv/bridge.py b/homeassistant/components/samsungtv/bridge.py index 84b518a4633..7e1c24c6d2f 100644 --- a/homeassistant/components/samsungtv/bridge.py +++ b/homeassistant/components/samsungtv/bridge.py @@ -184,7 +184,9 @@ class SamsungTVLegacyBridge(SamsungTVBridge): if self._remote is None: # We need to create a new instance to reconnect. try: - LOGGER.debug("Create SamsungRemote") + LOGGER.debug( + "Create SamsungTVLegacyBridge for %s (%s)", CONF_NAME, self.host + ) self._remote = Remote(self.config.copy()) # This is only happening when the auth was switched to DENY # A removed auth will lead to socket timeout because waiting for auth popup is just an open socket @@ -199,7 +201,7 @@ class SamsungTVLegacyBridge(SamsungTVBridge): def stop(self): """Stop Bridge.""" - LOGGER.debug("Stopping SamsungRemote") + LOGGER.debug("Stopping SamsungTVLegacyBridge") self.close_remote() @@ -272,7 +274,7 @@ class SamsungTVWSBridge(SamsungTVBridge): # We need to create a new instance to reconnect. try: LOGGER.debug( - "Create SamsungTVWS for %s (%s)", VALUE_CONF_NAME, self.host + "Create SamsungTVWSBridge for %s (%s)", CONF_NAME, self.host ) self._remote = SamsungTVWS( host=self.host, @@ -293,5 +295,5 @@ class SamsungTVWSBridge(SamsungTVBridge): def stop(self): """Stop Bridge.""" - LOGGER.debug("Stopping SamsungTVWS") + LOGGER.debug("Stopping SamsungTVWSBridge") self.close_remote() diff --git a/homeassistant/components/samsungtv/config_flow.py b/homeassistant/components/samsungtv/config_flow.py index 46800e1653b..7c6dea56b96 100644 --- a/homeassistant/components/samsungtv/config_flow.py +++ b/homeassistant/components/samsungtv/config_flow.py @@ -224,6 +224,7 @@ class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_ssdp(self, discovery_info: DiscoveryInfoType): """Handle a flow initialized by ssdp discovery.""" + LOGGER.debug("Samsung device found via SSDP: %s", discovery_info) self._udn = _strip_uuid(discovery_info[ATTR_UPNP_UDN]) await self._async_set_unique_id_from_udn() await self._async_start_discovery_for_host( @@ -242,6 +243,7 @@ class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_dhcp(self, discovery_info: DiscoveryInfoType): """Handle a flow initialized by dhcp discovery.""" + LOGGER.debug("Samsung device found via DHCP: %s", discovery_info) self._mac = discovery_info[MAC_ADDRESS] await self._async_start_discovery_for_host(discovery_info[IP_ADDRESS]) await self._async_set_device_unique_id() @@ -250,6 +252,7 @@ class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_zeroconf(self, discovery_info: DiscoveryInfoType): """Handle a flow initialized by zeroconf discovery.""" + LOGGER.debug("Samsung device found via ZEROCONF: %s", discovery_info) self._mac = format_mac(discovery_info[ATTR_PROPERTIES]["deviceid"]) await self._async_start_discovery_for_host(discovery_info[CONF_HOST]) await self._async_set_device_unique_id() From 8f741e0c6f4d036a8b501b13ed1d140ddf2af6ac Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Fri, 4 Jun 2021 18:02:59 +0200 Subject: [PATCH 08/10] Upgrade elgato to 2.1.1 (#51483) --- homeassistant/components/elgato/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/elgato/manifest.json b/homeassistant/components/elgato/manifest.json index dbb83f18995..7a095cb5917 100644 --- a/homeassistant/components/elgato/manifest.json +++ b/homeassistant/components/elgato/manifest.json @@ -3,7 +3,7 @@ "name": "Elgato Light", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/elgato", - "requirements": ["elgato==2.1.0"], + "requirements": ["elgato==2.1.1"], "zeroconf": ["_elg._tcp.local."], "codeowners": ["@frenck"], "quality_scale": "platinum", diff --git a/requirements_all.txt b/requirements_all.txt index decf8ff2967..43f477f9682 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -533,7 +533,7 @@ ebusdpy==0.0.16 ecoaliface==0.4.0 # homeassistant.components.elgato -elgato==2.1.0 +elgato==2.1.1 # homeassistant.components.eliqonline eliqonline==1.2.2 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 009cfd2c790..183124f95f0 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -291,7 +291,7 @@ dsmr_parser==0.29 dynalite_devices==0.1.46 # homeassistant.components.elgato -elgato==2.1.0 +elgato==2.1.1 # homeassistant.components.elkm1 elkm1-lib==0.8.10 From f5dd8384099d5524abf1629804b0f365793ba849 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 4 Jun 2021 09:14:18 -0700 Subject: [PATCH 09/10] Protect our user agent (#51486) * Protect our user agent * Fix expected error --- homeassistant/helpers/aiohttp_client.py | 8 +++++++- tests/helpers/test_aiohttp_client.py | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/homeassistant/helpers/aiohttp_client.py b/homeassistant/helpers/aiohttp_client.py index 0bb9a815c84..696f2d40cb8 100644 --- a/homeassistant/helpers/aiohttp_client.py +++ b/homeassistant/helpers/aiohttp_client.py @@ -6,6 +6,7 @@ from collections.abc import Awaitable from contextlib import suppress from ssl import SSLContext import sys +from types import MappingProxyType from typing import Any, Callable, cast import aiohttp @@ -95,9 +96,14 @@ def _async_create_clientsession( """Create a new ClientSession with kwargs, i.e. for cookies.""" clientsession = aiohttp.ClientSession( connector=_async_get_connector(hass, verify_ssl), - headers={USER_AGENT: SERVER_SOFTWARE}, **kwargs, ) + # Prevent packages accidentally overriding our default headers + # It's important that we identify as Home Assistant + # If a package requires a different user agent, override it by passing a headers + # dictionary to the request method. + # pylint: disable=protected-access + clientsession._default_headers = MappingProxyType({USER_AGENT: SERVER_SOFTWARE}) # type: ignore clientsession.close = warn_use(clientsession.close, WARN_CLOSE_MSG) # type: ignore diff --git a/tests/helpers/test_aiohttp_client.py b/tests/helpers/test_aiohttp_client.py index e6f113c7699..f68c7ba2181 100644 --- a/tests/helpers/test_aiohttp_client.py +++ b/tests/helpers/test_aiohttp_client.py @@ -195,3 +195,14 @@ async def test_async_aiohttp_proxy_stream_client_err(aioclient_mock, camera_clie resp = await camera_client.get("/api/camera_proxy_stream/camera.config_test") assert resp.status == 502 + + +async def test_client_session_immutable_headers(hass): + """Test we can't mutate headers.""" + session = client.async_get_clientsession(hass) + + with pytest.raises(TypeError): + session.headers["user-agent"] = "bla" + + with pytest.raises(AttributeError): + session.headers.update({"user-agent": "bla"}) From eb2f5c28a9a59197de579b232eafef38a9744a9a Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 4 Jun 2021 10:07:09 -0700 Subject: [PATCH 10/10] Bumped version to 2021.6.2 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index 690ea282734..87e53643240 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -5,7 +5,7 @@ from typing import Final MAJOR_VERSION: Final = 2021 MINOR_VERSION: Final = 6 -PATCH_VERSION: Final = "1" +PATCH_VERSION: Final = "2" __short_version__: Final = f"{MAJOR_VERSION}.{MINOR_VERSION}" __version__: Final = f"{__short_version__}.{PATCH_VERSION}" REQUIRED_PYTHON_VER: Final[tuple[int, int, int]] = (3, 8, 0)