Add log message on timeout and update less often for upnp devices (#32740)
* Catch asyncio.TimeoutError, show a proper message instead * Throttle updates to max once per 30s * Change code owner * Fix CODEOWNERS + linting * Warn on connection timeout
This commit is contained in:
1 parent
f9634f0232
commit
b6e69cd370
4 files changed
+23
-6
No files matched your search
@@ -1,4 +1,5 @@
|
||||
"""Support for UPnP/IGD Sensors."""
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
from homeassistant.const import DATA_BYTES, DATA_KIBIBYTES, TIME_SECONDS
|
||||
@@ -7,6 +8,7 @@ from homeassistant.helpers import device_registry as dr
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.typing import HomeAssistantType
|
||||
from homeassistant.util import Throttle
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from .const import DOMAIN as DOMAIN_UPNP, SIGNAL_REMOVE_SENSOR
|
||||
@@ -29,6 +31,8 @@ IN = "received"
|
||||
OUT = "sent"
|
||||
KIBIBYTE = 1024
|
||||
|
||||
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=30)
|
||||
|
||||
|
||||
async def async_setup_platform(
|
||||
hass: HomeAssistantType, config, async_add_entities, discovery_info=None
|
||||
@@ -142,6 +146,7 @@ class RawUPnPIGDSensor(UpnpSensor):
|
||||
"""Return the unit of measurement of this entity, if any."""
|
||||
return self._type["unit"]
|
||||
|
||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||
async def async_update(self):
|
||||
"""Get the latest information from the IGD."""
|
||||
if self._type_name == BYTES_RECEIVED:
|
||||
|
||||
Reference in new issue
Block a user