Bump arris-tg2492lg to 2.2.0 (#107905)
Bumps arris-tg2492lg from 1.2.1 to 2.2.0
This commit is contained in:
parent
90575bc496
commit
74afed3b6d
3 changed files with 24 additions and 11 deletions
|
@ -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()
|
||||
|
|
|
@ -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"]
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue