mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 23:07:09 +00:00
Remove @bind_hass
from camera
functions (#111494)
* Remove `@bind_hass` from camera functions * Pass hass to async_get_image in image_processing
This commit is contained in:
parent
6c00d02d0b
commit
c890c1aeee
@ -64,7 +64,6 @@ from homeassistant.helpers.event import async_track_time_interval
|
|||||||
from homeassistant.helpers.network import get_url
|
from homeassistant.helpers.network import get_url
|
||||||
from homeassistant.helpers.template import Template
|
from homeassistant.helpers.template import Template
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
from homeassistant.loader import bind_hass
|
|
||||||
|
|
||||||
from .const import ( # noqa: F401
|
from .const import ( # noqa: F401
|
||||||
_DEPRECATED_STREAM_TYPE_HLS,
|
_DEPRECATED_STREAM_TYPE_HLS,
|
||||||
@ -160,7 +159,6 @@ class Image:
|
|||||||
content: bytes = attr.ib()
|
content: bytes = attr.ib()
|
||||||
|
|
||||||
|
|
||||||
@bind_hass
|
|
||||||
async def async_request_stream(hass: HomeAssistant, entity_id: str, fmt: str) -> str:
|
async def async_request_stream(hass: HomeAssistant, entity_id: str, fmt: str) -> str:
|
||||||
"""Request a stream for a camera entity."""
|
"""Request a stream for a camera entity."""
|
||||||
camera = _get_camera_from_entity_id(hass, entity_id)
|
camera = _get_camera_from_entity_id(hass, entity_id)
|
||||||
@ -209,7 +207,6 @@ async def _async_get_image(
|
|||||||
raise HomeAssistantError("Unable to get image")
|
raise HomeAssistantError("Unable to get image")
|
||||||
|
|
||||||
|
|
||||||
@bind_hass
|
|
||||||
async def async_get_image(
|
async def async_get_image(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entity_id: str,
|
entity_id: str,
|
||||||
@ -240,14 +237,12 @@ async def _async_get_stream_image(
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@bind_hass
|
|
||||||
async def async_get_stream_source(hass: HomeAssistant, entity_id: str) -> str | None:
|
async def async_get_stream_source(hass: HomeAssistant, entity_id: str) -> str | None:
|
||||||
"""Fetch the stream source for a camera entity."""
|
"""Fetch the stream source for a camera entity."""
|
||||||
camera = _get_camera_from_entity_id(hass, entity_id)
|
camera = _get_camera_from_entity_id(hass, entity_id)
|
||||||
return await camera.stream_source()
|
return await camera.stream_source()
|
||||||
|
|
||||||
|
|
||||||
@bind_hass
|
|
||||||
async def async_get_mjpeg_stream(
|
async def async_get_mjpeg_stream(
|
||||||
hass: HomeAssistant, request: web.Request, entity_id: str
|
hass: HomeAssistant, request: web.Request, entity_id: str
|
||||||
) -> web.StreamResponse | None:
|
) -> web.StreamResponse | None:
|
||||||
|
@ -179,7 +179,7 @@ class ImageProcessingEntity(Entity):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
image: Image = await camera.async_get_image(
|
image: Image = await camera.async_get_image(
|
||||||
self.camera_entity, timeout=self.timeout
|
self.hass, self.camera_entity, timeout=self.timeout
|
||||||
)
|
)
|
||||||
|
|
||||||
except HomeAssistantError as err:
|
except HomeAssistantError as err:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user