diff --git a/homeassistant/components/google_assistant/trait.py b/homeassistant/components/google_assistant/trait.py index 497234df4ee..5b3a2db0b80 100644 --- a/homeassistant/components/google_assistant/trait.py +++ b/homeassistant/components/google_assistant/trait.py @@ -304,9 +304,7 @@ class CameraStreamTrait(_Trait): async def execute(self, command, data, params, challenge): """Execute a get camera stream command.""" - url = await self.hass.components.camera.async_request_stream( - self.state.entity_id, "hls" - ) + url = await camera.async_request_stream(self.hass, self.state.entity_id, "hls") self.stream_info = { "cameraStreamAccessUrl": f"{get_url(self.hass)}{url}", "cameraStreamReceiverAppId": CAST_APP_ID_HOMEASSISTANT_MEDIA, diff --git a/homeassistant/components/homekit/type_cameras.py b/homeassistant/components/homekit/type_cameras.py index 9d1821ec724..3a09e3a48ff 100644 --- a/homeassistant/components/homekit/type_cameras.py +++ b/homeassistant/components/homekit/type_cameras.py @@ -11,6 +11,7 @@ from pyhap.camera import ( ) from pyhap.const import CATEGORY_CAMERA +from homeassistant.components import camera from homeassistant.components.ffmpeg import get_ffmpeg_manager from homeassistant.const import STATE_ON from homeassistant.core import callback @@ -317,8 +318,8 @@ class Camera(HomeAccessory, PyhapCamera): if stream_source := self.config.get(CONF_STREAM_SOURCE): return stream_source try: - stream_source = await self.hass.components.camera.async_get_stream_source( - self.entity_id + stream_source = await camera.async_get_stream_source( + self.hass, self.entity_id ) except Exception: # pylint: disable=broad-except _LOGGER.exception( @@ -471,7 +472,8 @@ class Camera(HomeAccessory, PyhapCamera): async def async_get_snapshot(self, image_size): """Return a jpeg of a snapshot from the camera.""" - image = await self.hass.components.camera.async_get_image( + image = await camera.async_get_image( + self.hass, self.entity_id, width=image_size["image-width"], height=image_size["image-height"], diff --git a/homeassistant/components/mobile_app/webhook.py b/homeassistant/components/mobile_app/webhook.py index c2bde7d2312..d093fd23406 100644 --- a/homeassistant/components/mobile_app/webhook.py +++ b/homeassistant/components/mobile_app/webhook.py @@ -10,7 +10,7 @@ from aiohttp.web import HTTPBadRequest, Request, Response, json_response from nacl.secret import SecretBox import voluptuous as vol -from homeassistant.components import cloud, notify as hass_notify, tag +from homeassistant.components import camera, cloud, notify as hass_notify, tag from homeassistant.components.binary_sensor import ( DEVICE_CLASSES as BINARY_SENSOR_CLASSES, ) @@ -265,19 +265,19 @@ async def webhook_fire_event(hass, config_entry, data): @validate_schema({vol.Required(ATTR_CAMERA_ENTITY_ID): cv.string}) async def webhook_stream_camera(hass, config_entry, data): """Handle a request to HLS-stream a camera.""" - if (camera := hass.states.get(data[ATTR_CAMERA_ENTITY_ID])) is None: + if (camera_state := hass.states.get(data[ATTR_CAMERA_ENTITY_ID])) is None: return webhook_response( {"success": False}, registration=config_entry.data, status=HTTPStatus.BAD_REQUEST, ) - resp = {"mjpeg_path": f"/api/camera_proxy_stream/{camera.entity_id}"} + resp = {"mjpeg_path": f"/api/camera_proxy_stream/{camera_state.entity_id}"} - if camera.attributes[ATTR_SUPPORTED_FEATURES] & CAMERA_SUPPORT_STREAM: + if camera_state.attributes[ATTR_SUPPORTED_FEATURES] & CAMERA_SUPPORT_STREAM: try: - resp["hls_path"] = await hass.components.camera.async_request_stream( - camera.entity_id, "hls" + resp["hls_path"] = await camera.async_request_stream( + hass, camera_state.entity_id, "hls" ) except HomeAssistantError: resp["hls_path"] = None