def get_scanner(hass, config): """Return a Xiaomi MiIO device scanner.""" from miio import WifiRepeater, DeviceException scanner = None host = config[DOMAIN].get(CONF_HOST) token = config[DOMAIN].get(CONF_TOKEN) _LOGGER.info("Initializing with host %s (token %s...)", host, token[:5]) try: device = WifiRepeater(host, token) device_info = device.info() _LOGGER.info("%s %s %s detected", device_info.model, device_info.firmware_version, device_info.hardware_version) scanner = XiaomiMiioDeviceScanner(device) except DeviceException as ex: _LOGGER.error("Device unavailable or token incorrect: %s", ex) return scanner
def get_scanner(hass: HomeAssistant, config: ConfigType) -> DeviceScanner | None: """Return a Xiaomi MiIO device scanner.""" scanner = None host = config[DOMAIN][CONF_HOST] token = config[DOMAIN][CONF_TOKEN] _LOGGER.info("Initializing with host %s (token %s...)", host, token[:5]) try: device = WifiRepeater(host, token) device_info = device.info() _LOGGER.info( "%s %s %s detected", device_info.model, device_info.firmware_version, device_info.hardware_version, ) scanner = XiaomiMiioDeviceScanner(device) except DeviceException as ex: _LOGGER.error("Device unavailable or token incorrect: %s", ex) return scanner
def get_scanner(hass, config): """Return a Xiaomi MiIO device scanner.""" from miio import WifiRepeater, DeviceException scanner = None host = config[DOMAIN].get(CONF_HOST) token = config[DOMAIN].get(CONF_TOKEN) _LOGGER.info( "Initializing with host %s (token %s...)", host, token[:5]) try: device = WifiRepeater(host, token) device_info = device.info() _LOGGER.info("%s %s %s detected", device_info.model, device_info.firmware_version, device_info.hardware_version) scanner = XiaomiMiioDeviceScanner(device) except DeviceException as ex: _LOGGER.error("Device unavailable or token incorrect: %s", ex) return scanner