Handle exceptions when looking for new version (#48922)
This commit is contained in:
parent
f2f0331309
commit
af3b18c40a
1 changed files with 12 additions and 1 deletions
|
@ -1,7 +1,9 @@
|
|||
"""Sensor that can display the current Home Assistant versions."""
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
from pyhaversion import HaVersion, HaVersionChannel, HaVersionSource
|
||||
from pyhaversion.exceptions import HaVersionFetchException, HaVersionParseException
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||
|
@ -59,6 +61,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||
}
|
||||
)
|
||||
|
||||
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
||||
"""Set up the Version sensor platform."""
|
||||
|
@ -114,7 +118,14 @@ class VersionData:
|
|||
@Throttle(TIME_BETWEEN_UPDATES)
|
||||
async def async_update(self):
|
||||
"""Get the latest version information."""
|
||||
await self.api.get_version()
|
||||
try:
|
||||
await self.api.get_version()
|
||||
except HaVersionFetchException as exception:
|
||||
_LOGGER.warning(exception)
|
||||
except HaVersionParseException as exception:
|
||||
_LOGGER.warning(
|
||||
"Could not parse data received for %s - %s", self.api.source, exception
|
||||
)
|
||||
|
||||
|
||||
class VersionSensor(SensorEntity):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue