Tone down huawei_lte logging (#26020)

* Tone down huawei_lte logging

Refs https://github.com/home-assistant/home-assistant/pull/23809

* Fix import order
This commit is contained in:
Ville Skyttä 2019-08-17 21:50:41 +03:00 committed by GitHub
parent ca74a23cf1
commit 9dff2e188b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 9 deletions

View File

@ -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))

View File

@ -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]:

View File

@ -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")