mirror of
https://github.com/home-assistant/core.git
synced 2025-06-25 01:21:51 +02:00
Bump aiovodafone to 0.10.0 to use async_create_clientsession in Vodafone Station integration (#143537)
* Use async_create_clientsession in Vodafone Station integration * bump library and rename method
This commit is contained in:
@ -4,18 +4,21 @@ from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME, Platfor
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .coordinator import VodafoneConfigEntry, VodafoneStationRouter
|
||||
from .utils import async_client_session
|
||||
|
||||
PLATFORMS = [Platform.BUTTON, Platform.DEVICE_TRACKER, Platform.SENSOR]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: VodafoneConfigEntry) -> bool:
|
||||
"""Set up Vodafone Station platform."""
|
||||
session = await async_client_session(hass)
|
||||
coordinator = VodafoneStationRouter(
|
||||
hass,
|
||||
entry.data[CONF_HOST],
|
||||
entry.data[CONF_USERNAME],
|
||||
entry.data[CONF_PASSWORD],
|
||||
entry,
|
||||
session,
|
||||
)
|
||||
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
|
@ -18,6 +18,7 @@ from homeassistant.core import HomeAssistant, callback
|
||||
|
||||
from .const import _LOGGER, DEFAULT_HOST, DEFAULT_USERNAME, DOMAIN
|
||||
from .coordinator import VodafoneConfigEntry
|
||||
from .utils import async_client_session
|
||||
|
||||
|
||||
def user_form_schema(user_input: dict[str, Any] | None) -> vol.Schema:
|
||||
@ -38,8 +39,9 @@ STEP_REAUTH_DATA_SCHEMA = vol.Schema({vol.Required(CONF_PASSWORD): str})
|
||||
async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str, str]:
|
||||
"""Validate the user input allows us to connect."""
|
||||
|
||||
session = await async_client_session(hass)
|
||||
api = VodafoneStationSercommApi(
|
||||
data[CONF_HOST], data[CONF_USERNAME], data[CONF_PASSWORD]
|
||||
data[CONF_HOST], data[CONF_USERNAME], data[CONF_PASSWORD], session
|
||||
)
|
||||
|
||||
try:
|
||||
|
@ -5,6 +5,7 @@ from datetime import datetime, timedelta
|
||||
from json.decoder import JSONDecodeError
|
||||
from typing import Any, cast
|
||||
|
||||
from aiohttp import ClientSession
|
||||
from aiovodafone import VodafoneStationDevice, VodafoneStationSercommApi, exceptions
|
||||
|
||||
from homeassistant.components.device_tracker import DEFAULT_CONSIDER_HOME
|
||||
@ -53,11 +54,12 @@ class VodafoneStationRouter(DataUpdateCoordinator[UpdateCoordinatorDataType]):
|
||||
username: str,
|
||||
password: str,
|
||||
config_entry: VodafoneConfigEntry,
|
||||
session: ClientSession,
|
||||
) -> None:
|
||||
"""Initialize the scanner."""
|
||||
|
||||
self._host = host
|
||||
self.api = VodafoneStationSercommApi(host, username, password)
|
||||
self.api = VodafoneStationSercommApi(host, username, password, session)
|
||||
|
||||
# Last resort as no MAC or S/N can be retrieved via API
|
||||
self._id = config_entry.unique_id
|
||||
|
@ -8,5 +8,5 @@
|
||||
"iot_class": "local_polling",
|
||||
"loggers": ["aiovodafone"],
|
||||
"quality_scale": "platinum",
|
||||
"requirements": ["aiovodafone==0.6.1"]
|
||||
"requirements": ["aiovodafone==0.10.0"]
|
||||
}
|
||||
|
13
homeassistant/components/vodafone_station/utils.py
Normal file
13
homeassistant/components/vodafone_station/utils.py
Normal file
@ -0,0 +1,13 @@
|
||||
"""Utils for Vodafone Station."""
|
||||
|
||||
from aiohttp import ClientSession, CookieJar
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import aiohttp_client
|
||||
|
||||
|
||||
async def async_client_session(hass: HomeAssistant) -> ClientSession:
|
||||
"""Return a new aiohttp session."""
|
||||
return aiohttp_client.async_create_clientsession(
|
||||
hass, verify_ssl=False, cookie_jar=CookieJar(unsafe=True)
|
||||
)
|
2
requirements_all.txt
generated
2
requirements_all.txt
generated
@ -416,7 +416,7 @@ aiousbwatcher==1.1.1
|
||||
aiovlc==0.5.1
|
||||
|
||||
# homeassistant.components.vodafone_station
|
||||
aiovodafone==0.6.1
|
||||
aiovodafone==0.10.0
|
||||
|
||||
# homeassistant.components.waqi
|
||||
aiowaqi==3.1.0
|
||||
|
2
requirements_test_all.txt
generated
2
requirements_test_all.txt
generated
@ -398,7 +398,7 @@ aiousbwatcher==1.1.1
|
||||
aiovlc==0.5.1
|
||||
|
||||
# homeassistant.components.vodafone_station
|
||||
aiovodafone==0.6.1
|
||||
aiovodafone==0.10.0
|
||||
|
||||
# homeassistant.components.waqi
|
||||
aiowaqi==3.1.0
|
||||
|
Reference in New Issue
Block a user