diff --git a/homeassistant/components/vodafone_station/__init__.py b/homeassistant/components/vodafone_station/__init__.py index ded8b2ec3b8..f070464800c 100644 --- a/homeassistant/components/vodafone_station/__init__.py +++ b/homeassistant/components/vodafone_station/__init__.py @@ -1,7 +1,7 @@ """Vodafone Station integration.""" from aiohttp import ClientSession, CookieJar -from aiovodafone.api import VodafoneStationCommonApi +from aiovodafone.models import get_device_type from homeassistant.const import CONF_HOST, Platform from homeassistant.core import HomeAssistant @@ -42,7 +42,7 @@ async def async_migrate_entry(hass: HomeAssistant, entry: VodafoneConfigEntry) - session = ClientSession(cookie_jar=jar) try: - device_type, url = await VodafoneStationCommonApi.get_device_type( + device_type, url = await get_device_type( entry.data[CONF_HOST], session, ) @@ -54,7 +54,7 @@ async def async_migrate_entry(hass: HomeAssistant, entry: VodafoneConfigEntry) - new_data.update( { CONF_DEVICE_DETAILS: { - DEVICE_TYPE: device_type, + DEVICE_TYPE: device_type.value, DEVICE_URL: str(url), } }, diff --git a/homeassistant/components/vodafone_station/config_flow.py b/homeassistant/components/vodafone_station/config_flow.py index ab2335e7669..2c4db8c48ab 100644 --- a/homeassistant/components/vodafone_station/config_flow.py +++ b/homeassistant/components/vodafone_station/config_flow.py @@ -6,7 +6,7 @@ from collections.abc import Mapping from typing import Any from aiovodafone import exceptions as aiovodafone_exceptions -from aiovodafone.api import VodafoneStationCommonApi, init_api_class +from aiovodafone.models import get_device_type, init_device_class import voluptuous as vol from homeassistant.components.device_tracker import ( @@ -54,12 +54,12 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str, session = await async_client_session(hass) - device_type, url = await VodafoneStationCommonApi.get_device_type( + device_type, url = await get_device_type( data[CONF_HOST], session, ) - api = init_api_class(url, device_type, data, session) + api = init_device_class(url, device_type, data, session) try: await api.login() @@ -69,7 +69,7 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str, return { "title": data[CONF_HOST], CONF_DEVICE_DETAILS: { - DEVICE_TYPE: device_type, + DEVICE_TYPE: device_type.value, DEVICE_URL: str(url), }, } diff --git a/homeassistant/components/vodafone_station/coordinator.py b/homeassistant/components/vodafone_station/coordinator.py index 3648dee7795..e03f6ebde54 100644 --- a/homeassistant/components/vodafone_station/coordinator.py +++ b/homeassistant/components/vodafone_station/coordinator.py @@ -7,7 +7,8 @@ from typing import Any, cast from aiohttp import ClientSession from aiovodafone import exceptions -from aiovodafone.api import VodafoneStationDevice, init_api_class +from aiovodafone.api import VodafoneStationDevice +from aiovodafone.models import init_device_class from yarl import URL from homeassistant.components.device_tracker import ( @@ -70,7 +71,7 @@ class VodafoneStationRouter(DataUpdateCoordinator[UpdateCoordinatorDataType]): data = config_entry.data - self.api = init_api_class( + self.api = init_device_class( URL(data[CONF_DEVICE_DETAILS][DEVICE_URL]), data[CONF_DEVICE_DETAILS][DEVICE_TYPE], data, diff --git a/homeassistant/components/vodafone_station/manifest.json b/homeassistant/components/vodafone_station/manifest.json index 001bfa4d5b7..6c827945da7 100644 --- a/homeassistant/components/vodafone_station/manifest.json +++ b/homeassistant/components/vodafone_station/manifest.json @@ -8,5 +8,5 @@ "iot_class": "local_polling", "loggers": ["aiovodafone"], "quality_scale": "platinum", - "requirements": ["aiovodafone==2.0.1"] + "requirements": ["aiovodafone==3.0.0"] } diff --git a/requirements_all.txt b/requirements_all.txt index 07c685d4186..6fdbf0c5a31 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -432,7 +432,7 @@ aiousbwatcher==1.1.1 aiovlc==0.5.1 # homeassistant.components.vodafone_station -aiovodafone==2.0.1 +aiovodafone==3.0.0 # homeassistant.components.waqi aiowaqi==3.1.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 13a5532b4f3..874ba905275 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -414,7 +414,7 @@ aiousbwatcher==1.1.1 aiovlc==0.5.1 # homeassistant.components.vodafone_station -aiovodafone==2.0.1 +aiovodafone==3.0.0 # homeassistant.components.waqi aiowaqi==3.1.0 diff --git a/tests/components/vodafone_station/conftest.py b/tests/components/vodafone_station/conftest.py index 4790ddbe0b8..a3ffdf9f14e 100644 --- a/tests/components/vodafone_station/conftest.py +++ b/tests/components/vodafone_station/conftest.py @@ -2,7 +2,7 @@ from datetime import UTC, datetime -from aiovodafone.api import VodafoneStationCommonApi, VodafoneStationDevice +from aiovodafone.api import VodafoneStationDevice import pytest from yarl import URL @@ -49,16 +49,19 @@ def mock_vodafone_station_router() -> Generator[AsyncMock]: """Mock a Vodafone Station router.""" with ( patch( - "homeassistant.components.vodafone_station.coordinator.init_api_class", + "homeassistant.components.vodafone_station.coordinator.init_device_class", autospec=True, ) as mock_router, patch( - "homeassistant.components.vodafone_station.config_flow.init_api_class", + "homeassistant.components.vodafone_station.config_flow.init_device_class", new=mock_router, ), - patch.object( - VodafoneStationCommonApi, - "get_device_type", + patch( + "homeassistant.components.vodafone_station.config_flow.get_device_type", + new=AsyncMock(return_value=(TEST_TYPE, URL(TEST_URL))), + ), + patch( + "homeassistant.components.vodafone_station.get_device_type", new=AsyncMock(return_value=(TEST_TYPE, URL(TEST_URL))), ), ): diff --git a/tests/components/vodafone_station/const.py b/tests/components/vodafone_station/const.py index 744430e06f8..071ef7b5094 100644 --- a/tests/components/vodafone_station/const.py +++ b/tests/components/vodafone_station/const.py @@ -1,5 +1,7 @@ """Common stuff for Vodafone Station tests.""" +from aiovodafone.models import DeviceType + DEVICE_1_HOST = "WifiDevice0" DEVICE_1_MAC = "xx:xx:xx:xx:xx:xx" DEVICE_2_HOST = "LanDevice1" @@ -7,6 +9,6 @@ DEVICE_2_MAC = "yy:yy:yy:yy:yy:yy" TEST_HOST = "fake_host" TEST_PASSWORD = "fake_password" -TEST_TYPE = "Sercomm" +TEST_TYPE = DeviceType.SERCOMM TEST_URL = f"https://{TEST_HOST}" TEST_USERNAME = "fake_username" diff --git a/tests/components/vodafone_station/test_config_flow.py b/tests/components/vodafone_station/test_config_flow.py index 9d9ed2fda85..748201db089 100644 --- a/tests/components/vodafone_station/test_config_flow.py +++ b/tests/components/vodafone_station/test_config_flow.py @@ -2,7 +2,7 @@ from unittest.mock import AsyncMock -from aiovodafone import ( +from aiovodafone.exceptions import ( AlreadyLogged, CannotAuthenticate, CannotConnect, diff --git a/tests/components/vodafone_station/test_coordinator.py b/tests/components/vodafone_station/test_coordinator.py index 5f75b538803..cd78c4d5bd6 100644 --- a/tests/components/vodafone_station/test_coordinator.py +++ b/tests/components/vodafone_station/test_coordinator.py @@ -3,7 +3,7 @@ import logging from unittest.mock import AsyncMock -from aiovodafone import VodafoneStationDevice +from aiovodafone.api import VodafoneStationDevice from freezegun.api import FrozenDateTimeFactory import pytest diff --git a/tests/components/vodafone_station/test_sensor.py b/tests/components/vodafone_station/test_sensor.py index 35c486a359f..b005f8eba44 100644 --- a/tests/components/vodafone_station/test_sensor.py +++ b/tests/components/vodafone_station/test_sensor.py @@ -2,8 +2,7 @@ from unittest.mock import AsyncMock, patch -from aiovodafone import CannotAuthenticate -from aiovodafone.exceptions import AlreadyLogged, CannotConnect +from aiovodafone.exceptions import AlreadyLogged, CannotAuthenticate, CannotConnect from freezegun.api import FrozenDateTimeFactory import pytest from syrupy.assertion import SnapshotAssertion