mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 16:17:20 +00: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:
parent
55de91530d
commit
f3ea11bbc1
@ -4,18 +4,21 @@ from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME, Platfor
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from .coordinator import VodafoneConfigEntry, VodafoneStationRouter
|
from .coordinator import VodafoneConfigEntry, VodafoneStationRouter
|
||||||
|
from .utils import async_client_session
|
||||||
|
|
||||||
PLATFORMS = [Platform.BUTTON, Platform.DEVICE_TRACKER, Platform.SENSOR]
|
PLATFORMS = [Platform.BUTTON, Platform.DEVICE_TRACKER, Platform.SENSOR]
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: VodafoneConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: VodafoneConfigEntry) -> bool:
|
||||||
"""Set up Vodafone Station platform."""
|
"""Set up Vodafone Station platform."""
|
||||||
|
session = await async_client_session(hass)
|
||||||
coordinator = VodafoneStationRouter(
|
coordinator = VodafoneStationRouter(
|
||||||
hass,
|
hass,
|
||||||
entry.data[CONF_HOST],
|
entry.data[CONF_HOST],
|
||||||
entry.data[CONF_USERNAME],
|
entry.data[CONF_USERNAME],
|
||||||
entry.data[CONF_PASSWORD],
|
entry.data[CONF_PASSWORD],
|
||||||
entry,
|
entry,
|
||||||
|
session,
|
||||||
)
|
)
|
||||||
|
|
||||||
await coordinator.async_config_entry_first_refresh()
|
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 .const import _LOGGER, DEFAULT_HOST, DEFAULT_USERNAME, DOMAIN
|
||||||
from .coordinator import VodafoneConfigEntry
|
from .coordinator import VodafoneConfigEntry
|
||||||
|
from .utils import async_client_session
|
||||||
|
|
||||||
|
|
||||||
def user_form_schema(user_input: dict[str, Any] | None) -> vol.Schema:
|
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]:
|
async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str, str]:
|
||||||
"""Validate the user input allows us to connect."""
|
"""Validate the user input allows us to connect."""
|
||||||
|
|
||||||
|
session = await async_client_session(hass)
|
||||||
api = VodafoneStationSercommApi(
|
api = VodafoneStationSercommApi(
|
||||||
data[CONF_HOST], data[CONF_USERNAME], data[CONF_PASSWORD]
|
data[CONF_HOST], data[CONF_USERNAME], data[CONF_PASSWORD], session
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -5,6 +5,7 @@ from datetime import datetime, timedelta
|
|||||||
from json.decoder import JSONDecodeError
|
from json.decoder import JSONDecodeError
|
||||||
from typing import Any, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
|
from aiohttp import ClientSession
|
||||||
from aiovodafone import VodafoneStationDevice, VodafoneStationSercommApi, exceptions
|
from aiovodafone import VodafoneStationDevice, VodafoneStationSercommApi, exceptions
|
||||||
|
|
||||||
from homeassistant.components.device_tracker import DEFAULT_CONSIDER_HOME
|
from homeassistant.components.device_tracker import DEFAULT_CONSIDER_HOME
|
||||||
@ -53,11 +54,12 @@ class VodafoneStationRouter(DataUpdateCoordinator[UpdateCoordinatorDataType]):
|
|||||||
username: str,
|
username: str,
|
||||||
password: str,
|
password: str,
|
||||||
config_entry: VodafoneConfigEntry,
|
config_entry: VodafoneConfigEntry,
|
||||||
|
session: ClientSession,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the scanner."""
|
"""Initialize the scanner."""
|
||||||
|
|
||||||
self._host = host
|
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
|
# Last resort as no MAC or S/N can be retrieved via API
|
||||||
self._id = config_entry.unique_id
|
self._id = config_entry.unique_id
|
||||||
|
@ -8,5 +8,5 @@
|
|||||||
"iot_class": "local_polling",
|
"iot_class": "local_polling",
|
||||||
"loggers": ["aiovodafone"],
|
"loggers": ["aiovodafone"],
|
||||||
"quality_scale": "platinum",
|
"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
|
aiovlc==0.5.1
|
||||||
|
|
||||||
# homeassistant.components.vodafone_station
|
# homeassistant.components.vodafone_station
|
||||||
aiovodafone==0.6.1
|
aiovodafone==0.10.0
|
||||||
|
|
||||||
# homeassistant.components.waqi
|
# homeassistant.components.waqi
|
||||||
aiowaqi==3.1.0
|
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
|
aiovlc==0.5.1
|
||||||
|
|
||||||
# homeassistant.components.vodafone_station
|
# homeassistant.components.vodafone_station
|
||||||
aiovodafone==0.6.1
|
aiovodafone==0.10.0
|
||||||
|
|
||||||
# homeassistant.components.waqi
|
# homeassistant.components.waqi
|
||||||
aiowaqi==3.1.0
|
aiowaqi==3.1.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user