1 """Support for Xiaomi Mi WiFi Repeater 2."""
3 from __future__
import annotations
7 from miio
import DeviceException, WifiRepeater
8 import voluptuous
as vol
11 DOMAIN
as DEVICE_TRACKER_DOMAIN,
12 PLATFORM_SCHEMA
as DEVICE_TRACKER_PLATFORM_SCHEMA,
20 _LOGGER = logging.getLogger(__name__)
22 PLATFORM_SCHEMA = DEVICE_TRACKER_PLATFORM_SCHEMA.extend(
24 vol.Required(CONF_HOST): cv.string,
25 vol.Required(CONF_TOKEN): vol.All(cv.string, vol.Length(min=32, max=32)),
31 hass: HomeAssistant, config: ConfigType
32 ) -> XiaomiMiioDeviceScanner |
None:
33 """Return a Xiaomi MiIO device scanner."""
35 config = config[DEVICE_TRACKER_DOMAIN]
37 host = config[CONF_HOST]
38 token = config[CONF_TOKEN]
40 _LOGGER.debug(
"Initializing with host %s (token %s...)", host, token[:5])
43 device = WifiRepeater(host, token)
44 device_info = device.info()
48 device_info.firmware_version,
49 device_info.hardware_version,
52 except DeviceException
as ex:
53 _LOGGER.error(
"Device unavailable or token incorrect: %s", ex)
59 """Class which queries a Xiaomi Mi WiFi Repeater."""
62 """Initialize the scanner."""
66 """Scan for devices and return a list containing found device IDs."""
68 station_info = await self.hass.async_add_executor_job(self.
devicedevice.status)
69 _LOGGER.debug(
"Got new station info: %s", station_info)
70 except DeviceException
as ex:
71 _LOGGER.error(
"Unable to fetch the state: %s", ex)
74 return [device[
"mac"]
for device
in station_info.associated_stations]
79 The repeater doesn't provide the name of the associated device.
def __init__(self, device)
def async_scan_devices(self)
str|None async_get_device_name(self, str device)
XiaomiMiioDeviceScanner|None get_scanner(HomeAssistant hass, ConfigType config)