Improve nest SDM integration error handling (#43271)

This commit is contained in:
Allen Porter 2020-11-19 03:26:49 -08:00 committed by GitHub
parent a3061ebd8d
commit 2d14f07396
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 142 additions and 112 deletions

View file

@ -1,9 +1,11 @@
"""Support for Google Nest SDM sensors."""
import logging
from typing import Optional
from google_nest_sdm.device import Device
from google_nest_sdm.device_traits import HumidityTrait, TemperatureTrait
from google_nest_sdm.exceptions import GoogleNestException
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
@ -12,6 +14,7 @@ from homeassistant.const import (
PERCENTAGE,
TEMP_CELSIUS,
)
from homeassistant.exceptions import PlatformNotReady
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import HomeAssistantType
@ -19,6 +22,9 @@ from homeassistant.helpers.typing import HomeAssistantType
from .const import DOMAIN, SIGNAL_NEST_UPDATE
from .device_info import DeviceInfo
_LOGGER = logging.getLogger(__name__)
DEVICE_TYPE_MAP = {
"sdm.devices.types.CAMERA": "Camera",
"sdm.devices.types.DISPLAY": "Display",
@ -33,7 +39,11 @@ async def async_setup_sdm_entry(
"""Set up the sensors."""
subscriber = hass.data[DOMAIN][entry.entry_id]
device_manager = await subscriber.async_get_device_manager()
try:
device_manager = await subscriber.async_get_device_manager()
except GoogleNestException as err:
_LOGGER.warning("Failed to get devices: %s", err)
raise PlatformNotReady from err
# Fetch initial data so we have data when entities subscribe.