Revert "Remove @bind_hass from camera functions" (#111703)

Revert "Remove `@bind_hass` from `camera` functions (#111494)"

This reverts commit c890c1aeee.
This commit is contained in:
Jan-Philipp Benecke 2024-02-28 10:51:04 +01:00 committed by GitHub
parent dbeb93b260
commit 259171eda9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View file

@ -64,6 +64,7 @@ from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.network import get_url
from homeassistant.helpers.template import Template
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from .const import ( # noqa: F401
_DEPRECATED_STREAM_TYPE_HLS,
@ -159,6 +160,7 @@ class Image:
content: bytes = attr.ib()
@bind_hass
async def async_request_stream(hass: HomeAssistant, entity_id: str, fmt: str) -> str:
"""Request a stream for a camera entity."""
camera = _get_camera_from_entity_id(hass, entity_id)
@ -207,6 +209,7 @@ async def _async_get_image(
raise HomeAssistantError("Unable to get image")
@bind_hass
async def async_get_image(
hass: HomeAssistant,
entity_id: str,
@ -237,12 +240,14 @@ async def _async_get_stream_image(
return None
@bind_hass
async def async_get_stream_source(hass: HomeAssistant, entity_id: str) -> str | None:
"""Fetch the stream source for a camera entity."""
camera = _get_camera_from_entity_id(hass, entity_id)
return await camera.stream_source()
@bind_hass
async def async_get_mjpeg_stream(
hass: HomeAssistant, request: web.Request, entity_id: str
) -> web.StreamResponse | None:

View file

@ -179,7 +179,7 @@ class ImageProcessingEntity(Entity):
try:
image: Image = await camera.async_get_image(
self.hass, self.camera_entity, timeout=self.timeout
self.camera_entity, timeout=self.timeout
)
except HomeAssistantError as err: