diff --git a/homeassistant/components/camera/__init__.py b/homeassistant/components/camera/__init__.py index 9275589f3c9..5a3d730e7d3 100644 --- a/homeassistant/components/camera/__init__.py +++ b/homeassistant/components/camera/__init__.py @@ -422,7 +422,7 @@ class Camera(Entity): return MIN_STREAM_INTERVAL @property - def stream_type(self) -> str | None: + def frontend_stream_type(self) -> str | None: """Return the type of stream supported by this camera. A camera may have a single stream type which is used to inform the @@ -570,8 +570,10 @@ class Camera(Entity): if self.motion_detection_enabled: attrs["motion_detection"] = self.motion_detection_enabled - if self.stream_type: - attrs["stream_type"] = self.stream_type + if self.frontend_stream_type: + attrs["frontend_stream_type"] = self.frontend_stream_type + # Remove after home-assistant/frontend#10298 is merged into nightly + attrs["stream_type"] = self.frontend_stream_type return attrs @@ -746,11 +748,11 @@ async def ws_camera_web_rtc_offer( entity_id = msg["entity_id"] offer = msg["offer"] camera = _get_camera_from_entity_id(hass, entity_id) - if camera.stream_type != STREAM_TYPE_WEB_RTC: + if camera.frontend_stream_type != STREAM_TYPE_WEB_RTC: connection.send_error( msg["id"], "web_rtc_offer_failed", - f"Camera does not support WebRTC, stream_type={camera.stream_type}", + f"Camera does not support WebRTC, frontend_stream_type={camera.frontend_stream_type}", ) return try: diff --git a/homeassistant/components/nest/camera_sdm.py b/homeassistant/components/nest/camera_sdm.py index 9ce485cee56..99234c3de8a 100644 --- a/homeassistant/components/nest/camera_sdm.py +++ b/homeassistant/components/nest/camera_sdm.py @@ -118,7 +118,7 @@ class NestCamera(Camera): return supported_features @property - def stream_type(self) -> str | None: + def frontend_stream_type(self) -> str | None: """Return the type of stream supported by this camera.""" if CameraLiveStreamTrait.NAME not in self._device.traits: return None @@ -131,9 +131,11 @@ class NestCamera(Camera): """Return the source of the stream.""" if not self.supported_features & SUPPORT_STREAM: return None - if self.stream_type != STREAM_TYPE_HLS: + if CameraLiveStreamTrait.NAME not in self._device.traits: return None trait = self._device.traits[CameraLiveStreamTrait.NAME] + if StreamingProtocol.RTSP not in trait.supported_protocols: + return None if not self._stream: _LOGGER.debug("Fetching stream url") try: diff --git a/tests/components/camera/test_init.py b/tests/components/camera/test_init.py index 122fe13e2f1..c37c1b2909a 100644 --- a/tests/components/camera/test_init.py +++ b/tests/components/camera/test_init.py @@ -53,7 +53,7 @@ async def mock_camera_web_rtc_fixture(hass): await hass.async_block_till_done() with patch( - "homeassistant.components.camera.Camera.stream_type", + "homeassistant.components.camera.Camera.frontend_stream_type", new_callable=PropertyMock(return_value=STREAM_TYPE_WEB_RTC), ), patch( "homeassistant.components.camera.Camera.async_handle_web_rtc_offer",