From 74afed3b6d4267f92445029ca6ebde17c77793e6 Mon Sep 17 00:00:00 2001 From: Arjan van Balken Date: Thu, 18 Apr 2024 15:52:03 +0200 Subject: [PATCH] Bump arris-tg2492lg to 2.2.0 (#107905) Bumps arris-tg2492lg from 1.2.1 to 2.2.0 --- .../arris_tg2492lg/device_tracker.py | 29 +++++++++++++------ .../components/arris_tg2492lg/manifest.json | 4 ++- requirements_all.txt | 2 +- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/homeassistant/components/arris_tg2492lg/device_tracker.py b/homeassistant/components/arris_tg2492lg/device_tracker.py index 4f674a13c0e..3975109e07a 100644 --- a/homeassistant/components/arris_tg2492lg/device_tracker.py +++ b/homeassistant/components/arris_tg2492lg/device_tracker.py @@ -2,6 +2,7 @@ from __future__ import annotations +from aiohttp.client_exceptions import ClientResponseError from arris_tg2492lg import ConnectBox, Device import voluptuous as vol @@ -12,6 +13,7 @@ from homeassistant.components.device_tracker import ( ) from homeassistant.const import CONF_HOST, CONF_PASSWORD from homeassistant.core import HomeAssistant +from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv from homeassistant.helpers.typing import ConfigType @@ -25,12 +27,21 @@ PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend( ) -def get_scanner(hass: HomeAssistant, config: ConfigType) -> ArrisDeviceScanner: - """Return the Arris device scanner.""" +async def async_get_scanner( + hass: HomeAssistant, config: ConfigType +) -> ArrisDeviceScanner | None: + """Return the Arris device scanner if successful.""" conf = config[DOMAIN] url = f"http://{conf[CONF_HOST]}" - connect_box = ConnectBox(url, conf[CONF_PASSWORD]) - return ArrisDeviceScanner(connect_box) + websession = async_get_clientsession(hass) + connect_box = ConnectBox(websession, url, conf[CONF_PASSWORD]) + + try: + await connect_box.async_login() + + return ArrisDeviceScanner(connect_box) + except ClientResponseError: + return None class ArrisDeviceScanner(DeviceScanner): @@ -41,22 +52,22 @@ class ArrisDeviceScanner(DeviceScanner): self.connect_box = connect_box self.last_results: list[Device] = [] - def scan_devices(self) -> list[str]: + async def async_scan_devices(self) -> list[str]: """Scan for new devices and return a list with found device IDs.""" - self._update_info() + await self._async_update_info() return [device.mac for device in self.last_results if device.mac] - def get_device_name(self, device: str) -> str | None: + async def async_get_device_name(self, device: str) -> str | None: """Return the name of the given device or None if we don't know.""" return next( (result.hostname for result in self.last_results if result.mac == device), None, ) - def _update_info(self) -> None: + async def _async_update_info(self) -> None: """Ensure the information from the Arris TG2492LG router is up to date.""" - result = self.connect_box.get_connected_devices() + result = await self.connect_box.async_get_connected_devices() last_results: list[Device] = [] mac_addresses: set[str | None] = set() diff --git a/homeassistant/components/arris_tg2492lg/manifest.json b/homeassistant/components/arris_tg2492lg/manifest.json index 0134ea9077d..fa7673b4276 100644 --- a/homeassistant/components/arris_tg2492lg/manifest.json +++ b/homeassistant/components/arris_tg2492lg/manifest.json @@ -2,8 +2,10 @@ "domain": "arris_tg2492lg", "name": "Arris TG2492LG", "codeowners": ["@vanbalken"], + "dependencies": [], "documentation": "https://www.home-assistant.io/integrations/arris_tg2492lg", + "integration_type": "hub", "iot_class": "local_polling", "loggers": ["arris_tg2492lg"], - "requirements": ["arris-tg2492lg==1.2.1"] + "requirements": ["arris-tg2492lg==2.2.0"] } diff --git a/requirements_all.txt b/requirements_all.txt index edb4c8919d9..0e11345c278 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -464,7 +464,7 @@ aranet4==2.3.3 arcam-fmj==1.4.0 # homeassistant.components.arris_tg2492lg -arris-tg2492lg==1.2.1 +arris-tg2492lg==2.2.0 # homeassistant.components.ampio asmog==0.0.6