mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Update logic for nest media source can_play
for events (#61537)
This commit is contained in:
parent
cbe58913ea
commit
c3e72bec0a
@ -24,7 +24,7 @@ import logging
|
|||||||
|
|
||||||
from google_nest_sdm.camera_traits import CameraClipPreviewTrait, CameraEventImageTrait
|
from google_nest_sdm.camera_traits import CameraClipPreviewTrait, CameraEventImageTrait
|
||||||
from google_nest_sdm.device import Device
|
from google_nest_sdm.device import Device
|
||||||
from google_nest_sdm.event import ImageEventBase
|
from google_nest_sdm.event import EventImageType, ImageEventBase
|
||||||
|
|
||||||
from homeassistant.components.media_player.const import (
|
from homeassistant.components.media_player.const import (
|
||||||
MEDIA_CLASS_DIRECTORY,
|
MEDIA_CLASS_DIRECTORY,
|
||||||
@ -254,7 +254,7 @@ def _browse_event(
|
|||||||
event_name=MEDIA_SOURCE_EVENT_TITLE_MAP.get(event.event_type, "Event"),
|
event_name=MEDIA_SOURCE_EVENT_TITLE_MAP.get(event.event_type, "Event"),
|
||||||
event_time=dt_util.as_local(event.timestamp).strftime(DATE_STR_FORMAT),
|
event_time=dt_util.as_local(event.timestamp).strftime(DATE_STR_FORMAT),
|
||||||
),
|
),
|
||||||
can_play=True,
|
can_play=(event.event_image_type == EventImageType.CLIP_PREVIEW),
|
||||||
can_expand=False,
|
can_expand=False,
|
||||||
thumbnail=None,
|
thumbnail=None,
|
||||||
children=[],
|
children=[],
|
||||||
|
@ -231,6 +231,7 @@ async def test_camera_event(hass, auth, hass_client):
|
|||||||
assert "Person" in browse.title
|
assert "Person" in browse.title
|
||||||
assert not browse.can_expand
|
assert not browse.can_expand
|
||||||
assert not browse.children
|
assert not browse.children
|
||||||
|
assert not browse.can_play
|
||||||
|
|
||||||
# Resolving the event links to the media
|
# Resolving the event links to the media
|
||||||
media = await media_source.async_resolve_media(
|
media = await media_source.async_resolve_media(
|
||||||
@ -302,6 +303,7 @@ async def test_event_order(hass, auth):
|
|||||||
event_timestamp_string = event_timestamp2.strftime(DATE_STR_FORMAT)
|
event_timestamp_string = event_timestamp2.strftime(DATE_STR_FORMAT)
|
||||||
assert browse.children[0].title == f"Motion @ {event_timestamp_string}"
|
assert browse.children[0].title == f"Motion @ {event_timestamp_string}"
|
||||||
assert not browse.children[0].can_expand
|
assert not browse.children[0].can_expand
|
||||||
|
assert not browse.can_play
|
||||||
|
|
||||||
# Person event is next
|
# Person event is next
|
||||||
assert browse.children[1].domain == DOMAIN
|
assert browse.children[1].domain == DOMAIN
|
||||||
@ -310,6 +312,7 @@ async def test_event_order(hass, auth):
|
|||||||
event_timestamp_string = event_timestamp1.strftime(DATE_STR_FORMAT)
|
event_timestamp_string = event_timestamp1.strftime(DATE_STR_FORMAT)
|
||||||
assert browse.children[1].title == f"Person @ {event_timestamp_string}"
|
assert browse.children[1].title == f"Person @ {event_timestamp_string}"
|
||||||
assert not browse.children[1].can_expand
|
assert not browse.children[1].can_expand
|
||||||
|
assert not browse.can_play
|
||||||
|
|
||||||
|
|
||||||
async def test_browse_invalid_device_id(hass, auth):
|
async def test_browse_invalid_device_id(hass, auth):
|
||||||
@ -449,6 +452,7 @@ async def test_camera_event_clip_preview(hass, auth, hass_client):
|
|||||||
assert browse.children[0].title == f"Motion @ {event_timestamp_string}"
|
assert browse.children[0].title == f"Motion @ {event_timestamp_string}"
|
||||||
assert not browse.children[0].can_expand
|
assert not browse.children[0].can_expand
|
||||||
assert len(browse.children[0].children) == 0
|
assert len(browse.children[0].children) == 0
|
||||||
|
assert browse.children[0].can_play
|
||||||
|
|
||||||
# Resolving the event links to the media
|
# Resolving the event links to the media
|
||||||
media = await media_source.async_resolve_media(
|
media = await media_source.async_resolve_media(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user