mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 15:47:12 +00:00
Bump aiocomelit to 0.12.0 to use async_create_clientsession in Comelit integration (#143528)
* Use async_create_clientsession in Comelit integration * bump library and rename method
This commit is contained in:
parent
290bbcfa3e
commit
55de91530d
@ -12,6 +12,7 @@ from .coordinator import (
|
|||||||
ComelitSerialBridge,
|
ComelitSerialBridge,
|
||||||
ComelitVedoSystem,
|
ComelitVedoSystem,
|
||||||
)
|
)
|
||||||
|
from .utils import async_client_session
|
||||||
|
|
||||||
BRIDGE_PLATFORMS = [
|
BRIDGE_PLATFORMS = [
|
||||||
Platform.CLIMATE,
|
Platform.CLIMATE,
|
||||||
@ -32,6 +33,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ComelitConfigEntry) -> b
|
|||||||
"""Set up Comelit platform."""
|
"""Set up Comelit platform."""
|
||||||
|
|
||||||
coordinator: ComelitBaseCoordinator
|
coordinator: ComelitBaseCoordinator
|
||||||
|
|
||||||
|
session = await async_client_session(hass)
|
||||||
|
|
||||||
if entry.data.get(CONF_TYPE, BRIDGE) == BRIDGE:
|
if entry.data.get(CONF_TYPE, BRIDGE) == BRIDGE:
|
||||||
coordinator = ComelitSerialBridge(
|
coordinator = ComelitSerialBridge(
|
||||||
hass,
|
hass,
|
||||||
@ -39,6 +43,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ComelitConfigEntry) -> b
|
|||||||
entry.data[CONF_HOST],
|
entry.data[CONF_HOST],
|
||||||
entry.data.get(CONF_PORT, DEFAULT_PORT),
|
entry.data.get(CONF_PORT, DEFAULT_PORT),
|
||||||
entry.data[CONF_PIN],
|
entry.data[CONF_PIN],
|
||||||
|
session,
|
||||||
)
|
)
|
||||||
platforms = BRIDGE_PLATFORMS
|
platforms = BRIDGE_PLATFORMS
|
||||||
else:
|
else:
|
||||||
@ -48,6 +53,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ComelitConfigEntry) -> b
|
|||||||
entry.data[CONF_HOST],
|
entry.data[CONF_HOST],
|
||||||
entry.data.get(CONF_PORT, DEFAULT_PORT),
|
entry.data.get(CONF_PORT, DEFAULT_PORT),
|
||||||
entry.data[CONF_PIN],
|
entry.data[CONF_PIN],
|
||||||
|
session,
|
||||||
)
|
)
|
||||||
platforms = VEDO_PLATFORMS
|
platforms = VEDO_PLATFORMS
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ from homeassistant.exceptions import HomeAssistantError
|
|||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
|
|
||||||
from .const import _LOGGER, DEFAULT_PORT, DEVICE_TYPE_LIST, DOMAIN
|
from .const import _LOGGER, DEFAULT_PORT, DEVICE_TYPE_LIST, DOMAIN
|
||||||
|
from .utils import async_client_session
|
||||||
|
|
||||||
DEFAULT_HOST = "192.168.1.252"
|
DEFAULT_HOST = "192.168.1.252"
|
||||||
DEFAULT_PIN = 111111
|
DEFAULT_PIN = 111111
|
||||||
@ -47,10 +48,14 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str,
|
|||||||
"""Validate the user input allows us to connect."""
|
"""Validate the user input allows us to connect."""
|
||||||
|
|
||||||
api: ComelitCommonApi
|
api: ComelitCommonApi
|
||||||
|
|
||||||
|
session = await async_client_session(hass)
|
||||||
if data.get(CONF_TYPE, BRIDGE) == BRIDGE:
|
if data.get(CONF_TYPE, BRIDGE) == BRIDGE:
|
||||||
api = ComeliteSerialBridgeApi(data[CONF_HOST], data[CONF_PORT], data[CONF_PIN])
|
api = ComeliteSerialBridgeApi(
|
||||||
|
data[CONF_HOST], data[CONF_PORT], data[CONF_PIN], session
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
api = ComelitVedoApi(data[CONF_HOST], data[CONF_PORT], data[CONF_PIN])
|
api = ComelitVedoApi(data[CONF_HOST], data[CONF_PORT], data[CONF_PIN], session)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await api.login()
|
await api.login()
|
||||||
|
@ -15,6 +15,7 @@ from aiocomelit.api import (
|
|||||||
)
|
)
|
||||||
from aiocomelit.const import BRIDGE, VEDO
|
from aiocomelit.const import BRIDGE, VEDO
|
||||||
from aiocomelit.exceptions import CannotAuthenticate, CannotConnect, CannotRetrieveData
|
from aiocomelit.exceptions import CannotAuthenticate, CannotConnect, CannotRetrieveData
|
||||||
|
from aiohttp import ClientSession
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -119,9 +120,10 @@ class ComelitSerialBridge(
|
|||||||
host: str,
|
host: str,
|
||||||
port: int,
|
port: int,
|
||||||
pin: int,
|
pin: int,
|
||||||
|
session: ClientSession,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the scanner."""
|
"""Initialize the scanner."""
|
||||||
self.api = ComeliteSerialBridgeApi(host, port, pin)
|
self.api = ComeliteSerialBridgeApi(host, port, pin, session)
|
||||||
super().__init__(hass, entry, BRIDGE, host)
|
super().__init__(hass, entry, BRIDGE, host)
|
||||||
|
|
||||||
async def _async_update_system_data(
|
async def _async_update_system_data(
|
||||||
@ -144,9 +146,10 @@ class ComelitVedoSystem(ComelitBaseCoordinator[AlarmDataObject]):
|
|||||||
host: str,
|
host: str,
|
||||||
port: int,
|
port: int,
|
||||||
pin: int,
|
pin: int,
|
||||||
|
session: ClientSession,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the scanner."""
|
"""Initialize the scanner."""
|
||||||
self.api = ComelitVedoApi(host, port, pin)
|
self.api = ComelitVedoApi(host, port, pin, session)
|
||||||
super().__init__(hass, entry, VEDO, host)
|
super().__init__(hass, entry, VEDO, host)
|
||||||
|
|
||||||
async def _async_update_system_data(
|
async def _async_update_system_data(
|
||||||
|
@ -8,5 +8,5 @@
|
|||||||
"iot_class": "local_polling",
|
"iot_class": "local_polling",
|
||||||
"loggers": ["aiocomelit"],
|
"loggers": ["aiocomelit"],
|
||||||
"quality_scale": "bronze",
|
"quality_scale": "bronze",
|
||||||
"requirements": ["aiocomelit==0.11.3"]
|
"requirements": ["aiocomelit==0.12.0"]
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,5 @@ rules:
|
|||||||
|
|
||||||
# Platinum
|
# Platinum
|
||||||
async-dependency: done
|
async-dependency: done
|
||||||
inject-websession:
|
inject-websession: done
|
||||||
status: todo
|
|
||||||
comment: implement aiohttp_client.async_create_clientsession
|
|
||||||
strict-typing: done
|
strict-typing: done
|
||||||
|
13
homeassistant/components/comelit/utils.py
Normal file
13
homeassistant/components/comelit/utils.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
"""Utils for Comelit."""
|
||||||
|
|
||||||
|
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
@ -213,7 +213,7 @@ aiobafi6==0.9.0
|
|||||||
aiobotocore==2.21.1
|
aiobotocore==2.21.1
|
||||||
|
|
||||||
# homeassistant.components.comelit
|
# homeassistant.components.comelit
|
||||||
aiocomelit==0.11.3
|
aiocomelit==0.12.0
|
||||||
|
|
||||||
# homeassistant.components.dhcp
|
# homeassistant.components.dhcp
|
||||||
aiodhcpwatcher==1.1.1
|
aiodhcpwatcher==1.1.1
|
||||||
|
2
requirements_test_all.txt
generated
2
requirements_test_all.txt
generated
@ -201,7 +201,7 @@ aiobafi6==0.9.0
|
|||||||
aiobotocore==2.21.1
|
aiobotocore==2.21.1
|
||||||
|
|
||||||
# homeassistant.components.comelit
|
# homeassistant.components.comelit
|
||||||
aiocomelit==0.11.3
|
aiocomelit==0.12.0
|
||||||
|
|
||||||
# homeassistant.components.dhcp
|
# homeassistant.components.dhcp
|
||||||
aiodhcpwatcher==1.1.1
|
aiodhcpwatcher==1.1.1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user