From 9dff2e188b43ade7f7677ae5767e9e962073b051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sat, 17 Aug 2019 21:50:41 +0300 Subject: [PATCH] Tone down huawei_lte logging (#26020) * Tone down huawei_lte logging Refs https://github.com/home-assistant/home-assistant/pull/23809 * Fix import order --- homeassistant/components/huawei_lte/__init__.py | 4 ++-- .../components/huawei_lte/device_tracker.py | 17 +++++++++++------ homeassistant/components/huawei_lte/sensor.py | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/huawei_lte/__init__.py b/homeassistant/components/huawei_lte/__init__.py index 51d0dc5d3a2..2cbc271219b 100644 --- a/homeassistant/components/huawei_lte/__init__.py +++ b/homeassistant/components/huawei_lte/__init__.py @@ -101,8 +101,8 @@ class RouterData: if debugging or path in self._subscriptions: try: setattr(self, path, func()) - except ResponseErrorNotSupportedException as ex: - _LOGGER.warning("%s not supported by device", path, exc_info=ex) + except ResponseErrorNotSupportedException: + _LOGGER.warning("%s not supported by device", path) self._subscriptions.discard(path) finally: _LOGGER.debug("%s=%s", path, getattr(self, path)) diff --git a/homeassistant/components/huawei_lte/device_tracker.py b/homeassistant/components/huawei_lte/device_tracker.py index 878a819aaae..697b2a3ed3c 100644 --- a/homeassistant/components/huawei_lte/device_tracker.py +++ b/homeassistant/components/huawei_lte/device_tracker.py @@ -1,4 +1,5 @@ """Support for device tracking of Huawei LTE routers.""" +import logging from typing import Any, Dict, List, Optional import attr @@ -9,9 +10,12 @@ from homeassistant.components.device_tracker import PLATFORM_SCHEMA, DeviceScann from homeassistant.const import CONF_URL from . import DATA_KEY, RouterData + +_LOGGER = logging.getLogger(__name__) + PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Optional(CONF_URL): cv.url}) -HOSTS_PATH = "wlan_host_list.Hosts" +HOSTS_PATH = "wlan_host_list.Hosts.Host" def get_scanner(hass, config): @@ -32,11 +36,12 @@ class HuaweiLteScanner(DeviceScanner): def scan_devices(self) -> List[str]: """Scan for devices.""" self.data.update() - self._hosts = { - x["MacAddress"]: x - for x in self.data[HOSTS_PATH + ".Host"] - if x.get("MacAddress") - } + try: + self._hosts = { + x["MacAddress"]: x for x in self.data[HOSTS_PATH] if x.get("MacAddress") + } + except KeyError: + _LOGGER.debug("%s not in data", HOSTS_PATH) return list(self._hosts) def get_device_name(self, device: str) -> Optional[str]: diff --git a/homeassistant/components/huawei_lte/sensor.py b/homeassistant/components/huawei_lte/sensor.py index e72bd3aa438..4ef88eb783e 100644 --- a/homeassistant/components/huawei_lte/sensor.py +++ b/homeassistant/components/huawei_lte/sensor.py @@ -203,7 +203,7 @@ class HuaweiLteSensor(Entity): try: value = self.data[self.path] except KeyError: - _LOGGER.warning("%s not in data", self.path) + _LOGGER.debug("%s not in data", self.path) value = None formatter = self.meta.get("formatter")