1 """Support for Arris TG2492LG router."""
3 from __future__
import annotations
5 from aiohttp.client_exceptions
import ClientResponseError
6 from arris_tg2492lg
import ConnectBox, Device
7 import voluptuous
as vol
10 DOMAIN
as DEVICE_TRACKER_DOMAIN,
11 PLATFORM_SCHEMA
as DEVICE_TRACKER_PLATFORM_SCHEMA,
20 DEFAULT_HOST =
"192.168.178.1"
22 PLATFORM_SCHEMA = DEVICE_TRACKER_PLATFORM_SCHEMA.extend(
24 vol.Required(CONF_PASSWORD): cv.string,
25 vol.Optional(CONF_HOST, default=DEFAULT_HOST): cv.string,
31 hass: HomeAssistant, config: ConfigType
32 ) -> ArrisDeviceScanner |
None:
33 """Return the Arris device scanner if successful."""
34 conf = config[DEVICE_TRACKER_DOMAIN]
35 url = f
"http://{conf[CONF_HOST]}"
37 connect_box = ConnectBox(websession, url, conf[CONF_PASSWORD])
40 await connect_box.async_login()
43 except ClientResponseError:
48 """Class which queries a Arris TG2492LG router for connected devices."""
50 def __init__(self, connect_box: ConnectBox) ->
None:
51 """Initialize the scanner."""
56 """Scan for new devices and return a list with found device IDs."""
59 return [device.mac
for device
in self.
last_resultslast_results
if device.mac]
62 """Return the name of the given device or None if we don't know."""
64 (result.hostname
for result
in self.
last_resultslast_results
if result.mac == device),
69 """Ensure the information from the Arris TG2492LG router is up to date."""
70 result = await self.
connect_boxconnect_box.async_get_connected_devices()
72 last_results: list[Device] = []
73 mac_addresses: set[str |
None] = set()
76 if device.online
and device.mac
not in mac_addresses:
77 last_results.append(device)
78 mac_addresses.add(device.mac)
None _async_update_info(self)
None __init__(self, ConnectBox connect_box)
list[str] async_scan_devices(self)
str|None async_get_device_name(self, str device)
ArrisDeviceScanner|None async_get_scanner(HomeAssistant hass, ConfigType config)
aiohttp.ClientSession async_get_clientsession(HomeAssistant hass, bool verify_ssl=True, socket.AddressFamily family=socket.AF_UNSPEC, ssl_util.SSLCipherList ssl_cipher=ssl_util.SSLCipherList.PYTHON_DEFAULT)