Set `nest` camera always on STATE_STREAMING (#57882)

pull/57920/head
Allen Porter 2021-10-17 10:45:31 -07:00 committed by GitHub
parent fe0291012c
commit 95b07c138c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 9 deletions

View File

@ -76,6 +76,7 @@ class NestCamera(Camera):
self._event_id: str | None = None self._event_id: str | None = None
self._event_image_bytes: bytes | None = None self._event_image_bytes: bytes | None = None
self._event_image_cleanup_unsub: Callable[[], None] | None = None self._event_image_cleanup_unsub: Callable[[], None] | None = None
self.is_streaming = CameraLiveStreamTrait.NAME in self._device.traits
@property @property
def should_poll(self) -> bool: def should_poll(self) -> bool:

View File

@ -14,7 +14,7 @@ from google_nest_sdm.event import EventMessage
import pytest import pytest
from homeassistant.components import camera from homeassistant.components import camera
from homeassistant.components.camera import STATE_IDLE from homeassistant.components.camera import STATE_IDLE, STATE_STREAMING
from homeassistant.components.websocket_api.const import TYPE_RESULT from homeassistant.components.websocket_api.const import TYPE_RESULT
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import device_registry as dr, entity_registry as er from homeassistant.helpers import device_registry as dr, entity_registry as er
@ -168,7 +168,7 @@ async def test_camera_device(hass):
assert len(hass.states.async_all()) == 1 assert len(hass.states.async_all()) == 1
camera = hass.states.get("camera.my_camera") camera = hass.states.get("camera.my_camera")
assert camera is not None assert camera is not None
assert camera.state == STATE_IDLE assert camera.state == STATE_STREAMING
registry = er.async_get(hass) registry = er.async_get(hass)
entry = registry.async_get("camera.my_camera") entry = registry.async_get("camera.my_camera")
@ -191,7 +191,7 @@ async def test_camera_stream(hass, auth):
assert len(hass.states.async_all()) == 1 assert len(hass.states.async_all()) == 1
cam = hass.states.get("camera.my_camera") cam = hass.states.get("camera.my_camera")
assert cam is not None assert cam is not None
assert cam.state == STATE_IDLE assert cam.state == STATE_STREAMING
stream_source = await camera.async_get_stream_source(hass, "camera.my_camera") stream_source = await camera.async_get_stream_source(hass, "camera.my_camera")
assert stream_source == "rtsp://some/url?auth=g.0.streamingToken" assert stream_source == "rtsp://some/url?auth=g.0.streamingToken"
@ -253,7 +253,7 @@ async def test_refresh_expired_stream_token(hass, auth):
assert len(hass.states.async_all()) == 1 assert len(hass.states.async_all()) == 1
cam = hass.states.get("camera.my_camera") cam = hass.states.get("camera.my_camera")
assert cam is not None assert cam is not None
assert cam.state == STATE_IDLE assert cam.state == STATE_STREAMING
# Request a stream for the camera entity to exercise nest cam + camera interaction # Request a stream for the camera entity to exercise nest cam + camera interaction
# and shutdown on url expiration # and shutdown on url expiration
@ -318,7 +318,7 @@ async def test_stream_response_already_expired(hass, auth):
assert len(hass.states.async_all()) == 1 assert len(hass.states.async_all()) == 1
cam = hass.states.get("camera.my_camera") cam = hass.states.get("camera.my_camera")
assert cam is not None assert cam is not None
assert cam.state == STATE_IDLE assert cam.state == STATE_STREAMING
# The stream is expired, but we return it anyway # The stream is expired, but we return it anyway
stream_source = await camera.async_get_stream_source(hass, "camera.my_camera") stream_source = await camera.async_get_stream_source(hass, "camera.my_camera")
@ -342,7 +342,7 @@ async def test_camera_removed(hass, auth):
assert len(hass.states.async_all()) == 1 assert len(hass.states.async_all()) == 1
cam = hass.states.get("camera.my_camera") cam = hass.states.get("camera.my_camera")
assert cam is not None assert cam is not None
assert cam.state == STATE_IDLE assert cam.state == STATE_STREAMING
# Start a stream, exercising cleanup on remove # Start a stream, exercising cleanup on remove
auth.responses = [ auth.responses = [
@ -386,7 +386,7 @@ async def test_refresh_expired_stream_failure(hass, auth):
assert len(hass.states.async_all()) == 1 assert len(hass.states.async_all()) == 1
cam = hass.states.get("camera.my_camera") cam = hass.states.get("camera.my_camera")
assert cam is not None assert cam is not None
assert cam.state == STATE_IDLE assert cam.state == STATE_STREAMING
# Request an HLS stream # Request an HLS stream
with patch("homeassistant.components.camera.create_stream") as create_stream: with patch("homeassistant.components.camera.create_stream") as create_stream:
@ -639,7 +639,7 @@ async def test_camera_web_rtc(hass, auth, hass_ws_client):
assert len(hass.states.async_all()) == 1 assert len(hass.states.async_all()) == 1
cam = hass.states.get("camera.my_camera") cam = hass.states.get("camera.my_camera")
assert cam is not None assert cam is not None
assert cam.state == STATE_IDLE assert cam.state == STATE_STREAMING
client = await hass_ws_client(hass) client = await hass_ws_client(hass)
await client.send_json( await client.send_json(
@ -669,7 +669,7 @@ async def test_camera_web_rtc_unsupported(hass, auth, hass_ws_client):
assert len(hass.states.async_all()) == 1 assert len(hass.states.async_all()) == 1
cam = hass.states.get("camera.my_camera") cam = hass.states.get("camera.my_camera")
assert cam is not None assert cam is not None
assert cam.state == STATE_IDLE assert cam.state == STATE_STREAMING
client = await hass_ws_client(hass) client = await hass_ws_client(hass)
await client.send_json( await client.send_json(