From a30cc4e8e614c92db74b25f0da8194d60af561a0 Mon Sep 17 00:00:00 2001 From: Erik Date: Thu, 31 Oct 2024 12:14:22 +0100 Subject: [PATCH 1/3] Bump aiohasupervisor to version 0.2.1 --- homeassistant/components/hassio/manifest.json | 2 +- homeassistant/package_constraints.txt | 2 +- pyproject.toml | 2 +- requirements.txt | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/hassio/manifest.json b/homeassistant/components/hassio/manifest.json index fb9ad8fdb314e..31fa27a92c435 100644 --- a/homeassistant/components/hassio/manifest.json +++ b/homeassistant/components/hassio/manifest.json @@ -6,6 +6,6 @@ "documentation": "https://www.home-assistant.io/integrations/hassio", "iot_class": "local_polling", "quality_scale": "internal", - "requirements": ["aiohasupervisor==0.2.0"], + "requirements": ["aiohasupervisor==0.2.1"], "single_config_entry": true } diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index acdae25ccdc34..1ae2c062a18c9 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -3,7 +3,7 @@ aiodhcpwatcher==1.0.2 aiodiscover==2.1.0 aiodns==3.2.0 -aiohasupervisor==0.2.0 +aiohasupervisor==0.2.1 aiohttp-fast-zlib==0.1.1 aiohttp==3.10.10 aiohttp_cors==0.7.0 diff --git a/pyproject.toml b/pyproject.toml index a745d7732aca0..2d5b0da46cc75 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,7 @@ dependencies = [ # Integrations may depend on hassio integration without listing it to # change behavior based on presence of supervisor. Deprecated with #127228 # Lib can be removed with 2025.11 - "aiohasupervisor==0.2.0", + "aiohasupervisor==0.2.1", "aiohttp==3.10.10", "aiohttp_cors==0.7.0", "aiohttp-fast-zlib==0.1.1", diff --git a/requirements.txt b/requirements.txt index ce6fad44332f4..ecca136e1a748 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,7 @@ # Home Assistant Core aiodns==3.2.0 -aiohasupervisor==0.2.0 +aiohasupervisor==0.2.1 aiohttp==3.10.10 aiohttp_cors==0.7.0 aiohttp-fast-zlib==0.1.1 diff --git a/requirements_all.txt b/requirements_all.txt index 44b25bf802f0d..985df22c5f6d2 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -259,7 +259,7 @@ aioguardian==2022.07.0 aioharmony==0.2.10 # homeassistant.components.hassio -aiohasupervisor==0.2.0 +aiohasupervisor==0.2.1 # homeassistant.components.homekit_controller aiohomekit==3.2.5 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 15330d225e1dc..937f096dbf6c0 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -244,7 +244,7 @@ aioguardian==2022.07.0 aioharmony==0.2.10 # homeassistant.components.hassio -aiohasupervisor==0.2.0 +aiohasupervisor==0.2.1 # homeassistant.components.homekit_controller aiohomekit==3.2.5 From f88cd254c99bc8ca029d52fad38f513af870898b Mon Sep 17 00:00:00 2001 From: Erik Date: Thu, 31 Oct 2024 13:57:16 +0100 Subject: [PATCH 2/3] Fix type violations --- homeassistant/components/hassio/discovery.py | 7 ++++--- homeassistant/components/hassio/handler.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/hassio/discovery.py b/homeassistant/components/hassio/discovery.py index 8166b0f2c7ef5..6181fe4624ca4 100644 --- a/homeassistant/components/hassio/discovery.py +++ b/homeassistant/components/hassio/discovery.py @@ -5,6 +5,7 @@ import asyncio import logging from typing import Any +from uuid import UUID from aiohasupervisor import SupervisorError from aiohasupervisor.models import Discovery @@ -86,7 +87,7 @@ async def post(self, request: web.Request, uuid: str) -> web.Response: """Handle new discovery requests.""" # Fetch discovery data and prevent injections try: - data = await self._supervisor_client.discovery.get(uuid) + data = await self._supervisor_client.discovery.get(UUID(uuid)) except SupervisorError as err: _LOGGER.error("Can't read discovery data: %s", err) raise HTTPServiceUnavailable from None @@ -104,7 +105,7 @@ async def delete(self, request: web.Request, uuid: str) -> web.Response: async def async_rediscover(self, uuid: str) -> None: """Rediscover add-on when config entry is removed.""" try: - data = await self._supervisor_client.discovery.get(uuid) + data = await self._supervisor_client.discovery.get(UUID(uuid)) except SupervisorError as err: _LOGGER.debug("Can't read discovery data: %s", err) else: @@ -146,7 +147,7 @@ async def async_process_del(self, data: dict[str, Any]) -> None: # Check if really deletet / prevent injections try: - data = await self._supervisor_client.discovery.get(uuid) + await self._supervisor_client.discovery.get(UUID(uuid)) except SupervisorError: pass else: diff --git a/homeassistant/components/hassio/handler.py b/homeassistant/components/hassio/handler.py index d96c3f49e95be..f69ee40293b87 100644 --- a/homeassistant/components/hassio/handler.py +++ b/homeassistant/components/hassio/handler.py @@ -382,7 +382,7 @@ def get_supervisor_client(hass: HomeAssistant) -> SupervisorClient: """Return supervisor client.""" hassio: HassIO = hass.data[DOMAIN] return SupervisorClient( - hassio.base_url, + str(hassio.base_url), os.environ.get("SUPERVISOR_TOKEN", ""), session=hassio.websession, ) From 885b09883237ff586c363847d716d8997889e6cb Mon Sep 17 00:00:00 2001 From: Erik Date: Thu, 31 Oct 2024 17:11:22 +0100 Subject: [PATCH 3/3] Adjust tests --- tests/components/hassio/test_discovery.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/components/hassio/test_discovery.py b/tests/components/hassio/test_discovery.py index 09bcc251e6f50..bb3a101d1f97b 100644 --- a/tests/components/hassio/test_discovery.py +++ b/tests/components/hassio/test_discovery.py @@ -181,8 +181,8 @@ async def test_hassio_discovery_webhook( addon_installed.return_value.name = "Mosquitto Test" resp = await hassio_client.post( - "/api/hassio_push/discovery/testuuid", - json={"addon": "mosquitto", "service": "mqtt", "uuid": "testuuid"}, + f"/api/hassio_push/discovery/{uuid!s}", + json={"addon": "mosquitto", "service": "mqtt", "uuid": str(uuid)}, ) await hass.async_block_till_done() hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED) @@ -208,6 +208,9 @@ async def test_hassio_discovery_webhook( ) +TEST_UUID = str(uuid4()) + + @pytest.mark.parametrize( ( "entry_domain", @@ -217,13 +220,13 @@ async def test_hassio_discovery_webhook( # Matching discovery key ( "mock-domain", - {"hassio": (DiscoveryKey(domain="hassio", key="test", version=1),)}, + {"hassio": (DiscoveryKey(domain="hassio", key=TEST_UUID, version=1),)}, ), # Matching discovery key ( "mock-domain", { - "hassio": (DiscoveryKey(domain="hassio", key="test", version=1),), + "hassio": (DiscoveryKey(domain="hassio", key=TEST_UUID, version=1),), "other": (DiscoveryKey(domain="other", key="blah", version=1),), }, ), @@ -232,7 +235,7 @@ async def test_hassio_discovery_webhook( # entry. Such a check can be added if needed. ( "comp", - {"hassio": (DiscoveryKey(domain="hassio", key="test", version=1),)}, + {"hassio": (DiscoveryKey(domain="hassio", key=TEST_UUID, version=1),)}, ), ], )