mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
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
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from aiohttp.client_exceptions import ClientResponseError
|
||||||
from arris_tg2492lg import ConnectBox, Device
|
from arris_tg2492lg import ConnectBox, Device
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
@ -12,6 +13,7 @@ from homeassistant.components.device_tracker import (
|
|||||||
)
|
)
|
||||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD
|
from homeassistant.const import CONF_HOST, CONF_PASSWORD
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
@ -25,12 +27,21 @@ PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_scanner(hass: HomeAssistant, config: ConfigType) -> ArrisDeviceScanner:
|
async def async_get_scanner(
|
||||||
"""Return the Arris device scanner."""
|
hass: HomeAssistant, config: ConfigType
|
||||||
|
) -> ArrisDeviceScanner | None:
|
||||||
|
"""Return the Arris device scanner if successful."""
|
||||||
conf = config[DOMAIN]
|
conf = config[DOMAIN]
|
||||||
url = f"http://{conf[CONF_HOST]}"
|
url = f"http://{conf[CONF_HOST]}"
|
||||||
connect_box = ConnectBox(url, conf[CONF_PASSWORD])
|
websession = async_get_clientsession(hass)
|
||||||
|
connect_box = ConnectBox(websession, url, conf[CONF_PASSWORD])
|
||||||
|
|
||||||
|
try:
|
||||||
|
await connect_box.async_login()
|
||||||
|
|
||||||
return ArrisDeviceScanner(connect_box)
|
return ArrisDeviceScanner(connect_box)
|
||||||
|
except ClientResponseError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
class ArrisDeviceScanner(DeviceScanner):
|
class ArrisDeviceScanner(DeviceScanner):
|
||||||
@ -41,22 +52,22 @@ class ArrisDeviceScanner(DeviceScanner):
|
|||||||
self.connect_box = connect_box
|
self.connect_box = connect_box
|
||||||
self.last_results: list[Device] = []
|
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."""
|
"""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]
|
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 the name of the given device or None if we don't know."""
|
||||||
return next(
|
return next(
|
||||||
(result.hostname for result in self.last_results if result.mac == device),
|
(result.hostname for result in self.last_results if result.mac == device),
|
||||||
None,
|
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."""
|
"""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] = []
|
last_results: list[Device] = []
|
||||||
mac_addresses: set[str | None] = set()
|
mac_addresses: set[str | None] = set()
|
||||||
|
@ -2,8 +2,10 @@
|
|||||||
"domain": "arris_tg2492lg",
|
"domain": "arris_tg2492lg",
|
||||||
"name": "Arris TG2492LG",
|
"name": "Arris TG2492LG",
|
||||||
"codeowners": ["@vanbalken"],
|
"codeowners": ["@vanbalken"],
|
||||||
|
"dependencies": [],
|
||||||
"documentation": "https://www.home-assistant.io/integrations/arris_tg2492lg",
|
"documentation": "https://www.home-assistant.io/integrations/arris_tg2492lg",
|
||||||
|
"integration_type": "hub",
|
||||||
"iot_class": "local_polling",
|
"iot_class": "local_polling",
|
||||||
"loggers": ["arris_tg2492lg"],
|
"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
|
arcam-fmj==1.4.0
|
||||||
|
|
||||||
# homeassistant.components.arris_tg2492lg
|
# homeassistant.components.arris_tg2492lg
|
||||||
arris-tg2492lg==1.2.1
|
arris-tg2492lg==2.2.0
|
||||||
|
|
||||||
# homeassistant.components.ampio
|
# homeassistant.components.ampio
|
||||||
asmog==0.0.6
|
asmog==0.0.6
|
||||||
|
Loading…
x
Reference in New Issue
Block a user