Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion homeassistant/components/version/sensor.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -59,6 +61,8 @@
}
)

_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."""
Expand Down Expand Up @@ -114,7 +118,14 @@ def __init__(self, api: HaVersion):
@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):
Expand Down