mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Fix asuswrt spamming logs with exceptions (#37063)
This commit is contained in:
parent
4a65bed0eb
commit
d9a3b04e30
@ -24,6 +24,7 @@ class AsusWrtDeviceScanner(DeviceScanner):
|
|||||||
self.last_results = {}
|
self.last_results = {}
|
||||||
self.success_init = False
|
self.success_init = False
|
||||||
self.connection = api
|
self.connection = api
|
||||||
|
self._connect_error = False
|
||||||
|
|
||||||
async def async_connect(self):
|
async def async_connect(self):
|
||||||
"""Initialize connection to the router."""
|
"""Initialize connection to the router."""
|
||||||
@ -49,4 +50,15 @@ class AsusWrtDeviceScanner(DeviceScanner):
|
|||||||
"""
|
"""
|
||||||
_LOGGER.debug("Checking Devices")
|
_LOGGER.debug("Checking Devices")
|
||||||
|
|
||||||
self.last_results = await self.connection.async_get_connected_devices()
|
try:
|
||||||
|
self.last_results = await self.connection.async_get_connected_devices()
|
||||||
|
if self._connect_error:
|
||||||
|
self._connect_error = False
|
||||||
|
_LOGGER.error("Reconnected to ASUS router for device update")
|
||||||
|
|
||||||
|
except OSError as err:
|
||||||
|
if not self._connect_error:
|
||||||
|
self._connect_error = True
|
||||||
|
_LOGGER.error(
|
||||||
|
"Error connecting to ASUS router for device update: %s", err
|
||||||
|
)
|
||||||
|
@ -49,6 +49,7 @@ class AsuswrtSensor(Entity):
|
|||||||
self._devices = None
|
self._devices = None
|
||||||
self._rates = None
|
self._rates = None
|
||||||
self._speed = None
|
self._speed = None
|
||||||
|
self._connect_error = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@ -62,9 +63,23 @@ class AsuswrtSensor(Entity):
|
|||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self):
|
||||||
"""Fetch status from asuswrt."""
|
"""Fetch status from asuswrt."""
|
||||||
self._devices = await self._api.async_get_connected_devices()
|
try:
|
||||||
self._rates = await self._api.async_get_bytes_total()
|
self._devices = await self._api.async_get_connected_devices()
|
||||||
self._speed = await self._api.async_get_current_transfer_rates()
|
self._rates = await self._api.async_get_bytes_total()
|
||||||
|
self._speed = await self._api.async_get_current_transfer_rates()
|
||||||
|
if self._connect_error:
|
||||||
|
self._connect_error = False
|
||||||
|
_LOGGER.error(
|
||||||
|
"Reconnected to ASUS router for %s update", self.entity_id
|
||||||
|
)
|
||||||
|
except OSError as err:
|
||||||
|
if not self._connect_error:
|
||||||
|
self._connect_error = True
|
||||||
|
_LOGGER.error(
|
||||||
|
"Error connecting to ASUS router for %s update: %s",
|
||||||
|
self.entity_id,
|
||||||
|
err,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class AsuswrtDevicesSensor(AsuswrtSensor):
|
class AsuswrtDevicesSensor(AsuswrtSensor):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user