From f4e7c9d6c39ba68fa970c8557581abeb6604aa2f Mon Sep 17 00:00:00 2001 From: jesperraemaekers <146726232+jesperraemaekers@users.noreply.github.com> Date: Tue, 14 Jan 2025 11:36:26 +0100 Subject: [PATCH] Bump Weheat to 2025.1.14 (#135578) --- homeassistant/components/weheat/__init__.py | 4 +++- homeassistant/components/weheat/config_flow.py | 4 ++-- homeassistant/components/weheat/coordinator.py | 16 +++++++--------- homeassistant/components/weheat/manifest.json | 2 +- .../components/weheat/quality_scale.yaml | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- tests/components/weheat/conftest.py | 4 ++-- tests/components/weheat/test_config_flow.py | 4 ++-- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/homeassistant/components/weheat/__init__.py b/homeassistant/components/weheat/__init__.py index 37c1f721078..c14bbbcb028 100644 --- a/homeassistant/components/weheat/__init__.py +++ b/homeassistant/components/weheat/__init__.py @@ -48,7 +48,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: WeheatConfigEntry) -> bo # fetch a list of the heat pumps the entry can access try: - discovered_heat_pumps = await HeatPumpDiscovery.discover_active(API_URL, token) + discovered_heat_pumps = await HeatPumpDiscovery.async_discover_active( + API_URL, token + ) except UnauthorizedException as error: raise ConfigEntryAuthFailed from error diff --git a/homeassistant/components/weheat/config_flow.py b/homeassistant/components/weheat/config_flow.py index b1a0b5dd4ea..318a02ee47f 100644 --- a/homeassistant/components/weheat/config_flow.py +++ b/homeassistant/components/weheat/config_flow.py @@ -4,7 +4,7 @@ from collections.abc import Mapping import logging from typing import Any -from weheat.abstractions.user import get_user_id_from_token +from weheat.abstractions.user import async_get_user_id_from_token from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlowResult from homeassistant.const import CONF_ACCESS_TOKEN, CONF_TOKEN @@ -33,7 +33,7 @@ class OAuth2FlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN): async def async_oauth_create_entry(self, data: dict) -> ConfigFlowResult: """Override the create entry method to change to the step to find the heat pumps.""" # get the user id and use that as unique id for this entry - user_id = await get_user_id_from_token( + user_id = await async_get_user_id_from_token( API_URL, data[CONF_TOKEN][CONF_ACCESS_TOKEN] ) await self.async_set_unique_id(user_id) diff --git a/homeassistant/components/weheat/coordinator.py b/homeassistant/components/weheat/coordinator.py index a50e9daec18..94d897351eb 100644 --- a/homeassistant/components/weheat/coordinator.py +++ b/homeassistant/components/weheat/coordinator.py @@ -68,19 +68,17 @@ class WeheatDataUpdateCoordinator(DataUpdateCoordinator[HeatPump]): """Return the model of the heat pump.""" return self.heat_pump_info.model - def fetch_data(self) -> HeatPump: - """Get the data from the API.""" + async def _async_update_data(self) -> HeatPump: + """Fetch data from the API.""" + await self.session.async_ensure_token_valid() + try: - self._heat_pump_data.get_status(self.session.token[CONF_ACCESS_TOKEN]) + await self._heat_pump_data.async_get_status( + self.session.token[CONF_ACCESS_TOKEN] + ) except UnauthorizedException as error: raise ConfigEntryAuthFailed from error except EXCEPTIONS as error: raise UpdateFailed(error) from error return self._heat_pump_data - - async def _async_update_data(self) -> HeatPump: - """Fetch data from the API.""" - await self.session.async_ensure_token_valid() - - return await self.hass.async_add_executor_job(self.fetch_data) diff --git a/homeassistant/components/weheat/manifest.json b/homeassistant/components/weheat/manifest.json index 1c6242de29c..c81fe570691 100644 --- a/homeassistant/components/weheat/manifest.json +++ b/homeassistant/components/weheat/manifest.json @@ -6,5 +6,5 @@ "dependencies": ["application_credentials"], "documentation": "https://www.home-assistant.io/integrations/weheat", "iot_class": "cloud_polling", - "requirements": ["weheat==2024.12.22"] + "requirements": ["weheat==2025.1.14"] } diff --git a/homeassistant/components/weheat/quality_scale.yaml b/homeassistant/components/weheat/quality_scale.yaml index a8431ad3aad..f924c0c3582 100644 --- a/homeassistant/components/weheat/quality_scale.yaml +++ b/homeassistant/components/weheat/quality_scale.yaml @@ -88,6 +88,6 @@ rules: While unlikely to happen. Check if it is easily integrated. # Platinum - async-dependency: todo + async-dependency: done inject-websession: todo strict-typing: todo diff --git a/requirements_all.txt b/requirements_all.txt index 91fb812e0eb..0086bb8a3b6 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -3033,7 +3033,7 @@ webio-api==0.1.11 webmin-xmlrpc==0.0.2 # homeassistant.components.weheat -weheat==2024.12.22 +weheat==2025.1.14 # homeassistant.components.whirlpool whirlpool-sixth-sense==0.18.11 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 8602ae394b0..66a7a289438 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -2437,7 +2437,7 @@ webio-api==0.1.11 webmin-xmlrpc==0.0.2 # homeassistant.components.weheat -weheat==2024.12.22 +weheat==2025.1.14 # homeassistant.components.whirlpool whirlpool-sixth-sense==0.18.11 diff --git a/tests/components/weheat/conftest.py b/tests/components/weheat/conftest.py index 1bbe91fc573..dbdeb0726dd 100644 --- a/tests/components/weheat/conftest.py +++ b/tests/components/weheat/conftest.py @@ -81,7 +81,7 @@ def mock_user_id() -> Generator[AsyncMock]: """Mock the user API call.""" with ( patch( - "homeassistant.components.weheat.config_flow.get_user_id_from_token", + "homeassistant.components.weheat.config_flow.async_get_user_id_from_token", return_value=USER_UUID_1, ) as user_mock, ): @@ -93,7 +93,7 @@ def mock_weheat_discover(mock_heat_pump_info) -> Generator[AsyncMock]: """Mock an Weheat discovery.""" with ( patch( - "homeassistant.components.weheat.HeatPumpDiscovery.discover_active", + "homeassistant.components.weheat.HeatPumpDiscovery.async_discover_active", autospec=True, ) as mock_discover, ): diff --git a/tests/components/weheat/test_config_flow.py b/tests/components/weheat/test_config_flow.py index b33dd0a8db8..45f2285fd03 100644 --- a/tests/components/weheat/test_config_flow.py +++ b/tests/components/weheat/test_config_flow.py @@ -47,7 +47,7 @@ async def test_full_flow( with ( patch( - "homeassistant.components.weheat.config_flow.get_user_id_from_token", + "homeassistant.components.weheat.config_flow.async_get_user_id_from_token", return_value=USER_UUID_1, ) as mock_weheat, ): @@ -89,7 +89,7 @@ async def test_duplicate_unique_id( with ( patch( - "homeassistant.components.weheat.config_flow.get_user_id_from_token", + "homeassistant.components.weheat.config_flow.async_get_user_id_from_token", return_value=USER_UUID_1, ), ):