mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Suppress errors for legacy nest api when using media source (#61629)
This commit is contained in:
parent
3cfc349e99
commit
efbec55818
@ -64,6 +64,9 @@ async def async_get_media_source(hass: HomeAssistant) -> MediaSource:
|
|||||||
|
|
||||||
async def get_media_source_devices(hass: HomeAssistant) -> Mapping[str, Device]:
|
async def get_media_source_devices(hass: HomeAssistant) -> Mapping[str, Device]:
|
||||||
"""Return a mapping of device id to eligible Nest event media devices."""
|
"""Return a mapping of device id to eligible Nest event media devices."""
|
||||||
|
if DATA_SUBSCRIBER not in hass.data[DOMAIN]:
|
||||||
|
# Integration unloaded, or is legacy nest integration
|
||||||
|
return {}
|
||||||
subscriber = hass.data[DOMAIN][DATA_SUBSCRIBER]
|
subscriber = hass.data[DOMAIN][DATA_SUBSCRIBER]
|
||||||
device_manager = await subscriber.async_get_device_manager()
|
device_manager = await subscriber.async_get_device_manager()
|
||||||
device_registry = await hass.helpers.device_registry.async_get_registry()
|
device_registry = await hass.helpers.device_registry.async_get_registry()
|
||||||
|
@ -16,6 +16,7 @@ from homeassistant.components import media_source
|
|||||||
from homeassistant.components.media_player.errors import BrowseError
|
from homeassistant.components.media_player.errors import BrowseError
|
||||||
from homeassistant.components.media_source import const
|
from homeassistant.components.media_source import const
|
||||||
from homeassistant.components.media_source.error import Unresolvable
|
from homeassistant.components.media_source.error import Unresolvable
|
||||||
|
from homeassistant.config_entries import ConfigEntryState
|
||||||
from homeassistant.helpers import device_registry as dr
|
from homeassistant.helpers import device_registry as dr
|
||||||
from homeassistant.helpers.template import DATE_STR_FORMAT
|
from homeassistant.helpers.template import DATE_STR_FORMAT
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
@ -164,6 +165,37 @@ async def test_supported_device(hass, auth):
|
|||||||
assert len(browse.children) == 0
|
assert len(browse.children) == 0
|
||||||
|
|
||||||
|
|
||||||
|
async def test_integration_unloaded(hass, auth):
|
||||||
|
"""Test the media player loads, but has no devices, when config unloaded."""
|
||||||
|
await async_setup_devices(
|
||||||
|
hass,
|
||||||
|
auth,
|
||||||
|
CAMERA_DEVICE_TYPE,
|
||||||
|
CAMERA_TRAITS,
|
||||||
|
)
|
||||||
|
|
||||||
|
browse = await media_source.async_browse_media(hass, f"{const.URI_SCHEME}{DOMAIN}")
|
||||||
|
assert browse.domain == DOMAIN
|
||||||
|
assert browse.identifier == ""
|
||||||
|
assert browse.title == "Nest"
|
||||||
|
assert len(browse.children) == 1
|
||||||
|
|
||||||
|
entries = hass.config_entries.async_entries(DOMAIN)
|
||||||
|
assert len(entries) == 1
|
||||||
|
entry = entries[0]
|
||||||
|
assert entry.state is ConfigEntryState.LOADED
|
||||||
|
|
||||||
|
assert await hass.config_entries.async_unload(entry.entry_id)
|
||||||
|
assert entry.state == ConfigEntryState.NOT_LOADED
|
||||||
|
|
||||||
|
# No devices returned
|
||||||
|
browse = await media_source.async_browse_media(hass, f"{const.URI_SCHEME}{DOMAIN}")
|
||||||
|
assert browse.domain == DOMAIN
|
||||||
|
assert browse.identifier == ""
|
||||||
|
assert browse.title == "Nest"
|
||||||
|
assert len(browse.children) == 0
|
||||||
|
|
||||||
|
|
||||||
async def test_camera_event(hass, auth, hass_client):
|
async def test_camera_event(hass, auth, hass_client):
|
||||||
"""Test a media source and image created for an event."""
|
"""Test a media source and image created for an event."""
|
||||||
event_timestamp = dt_util.now()
|
event_timestamp = dt_util.now()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user