mirror of
https://github.com/home-assistant/core.git
synced 2025-08-30 09:51:37 +02:00
Move get_dynamic_camera_stream_settings to prefs
This commit is contained in:
@@ -79,9 +79,13 @@ from .const import (
|
|||||||
CameraState,
|
CameraState,
|
||||||
StreamType,
|
StreamType,
|
||||||
)
|
)
|
||||||
from .helper import get_camera_from_entity_id, get_dynamic_camera_stream_settings
|
from .helper import get_camera_from_entity_id
|
||||||
from .img_util import scale_jpeg_camera_image
|
from .img_util import scale_jpeg_camera_image
|
||||||
from .prefs import CameraPreferences, DynamicStreamSettings # noqa: F401
|
from .prefs import (
|
||||||
|
CameraPreferences,
|
||||||
|
DynamicStreamSettings, # noqa: F401
|
||||||
|
get_dynamic_camera_stream_settings,
|
||||||
|
)
|
||||||
from .webrtc import (
|
from .webrtc import (
|
||||||
DATA_ICE_SERVERS,
|
DATA_ICE_SERVERS,
|
||||||
CameraWebRTCProvider,
|
CameraWebRTCProvider,
|
||||||
|
@@ -7,11 +7,10 @@ from typing import TYPE_CHECKING
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
|
|
||||||
from .const import DATA_CAMERA_PREFS, DATA_COMPONENT
|
from .const import DATA_COMPONENT
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from . import Camera
|
from . import Camera
|
||||||
from .prefs import DynamicStreamSettings
|
|
||||||
|
|
||||||
|
|
||||||
def get_camera_from_entity_id(hass: HomeAssistant, entity_id: str) -> Camera:
|
def get_camera_from_entity_id(hass: HomeAssistant, entity_id: str) -> Camera:
|
||||||
@@ -27,12 +26,3 @@ def get_camera_from_entity_id(hass: HomeAssistant, entity_id: str) -> Camera:
|
|||||||
raise HomeAssistantError("Camera is off")
|
raise HomeAssistantError("Camera is off")
|
||||||
|
|
||||||
return camera
|
return camera
|
||||||
|
|
||||||
|
|
||||||
async def get_dynamic_camera_stream_settings(
|
|
||||||
hass: HomeAssistant, entity_id: str
|
|
||||||
) -> DynamicStreamSettings:
|
|
||||||
"""Get dynamic stream settings for a camera entity."""
|
|
||||||
if DATA_CAMERA_PREFS not in hass.data:
|
|
||||||
raise HomeAssistantError("Camera integration not set up")
|
|
||||||
return await hass.data[DATA_CAMERA_PREFS].get_dynamic_stream_settings(entity_id)
|
|
||||||
|
@@ -13,7 +13,7 @@ from homeassistant.helpers import entity_registry as er
|
|||||||
from homeassistant.helpers.storage import Store
|
from homeassistant.helpers.storage import Store
|
||||||
from homeassistant.helpers.typing import UNDEFINED, UndefinedType
|
from homeassistant.helpers.typing import UNDEFINED, UndefinedType
|
||||||
|
|
||||||
from .const import DOMAIN, PREF_ORIENTATION, PREF_PRELOAD_STREAM
|
from .const import DATA_CAMERA_PREFS, DOMAIN, PREF_ORIENTATION, PREF_PRELOAD_STREAM
|
||||||
|
|
||||||
STORAGE_KEY: Final = DOMAIN
|
STORAGE_KEY: Final = DOMAIN
|
||||||
STORAGE_VERSION: Final = 1
|
STORAGE_VERSION: Final = 1
|
||||||
@@ -106,3 +106,12 @@ class CameraPreferences:
|
|||||||
)
|
)
|
||||||
self._dynamic_stream_settings_by_entity_id[entity_id] = settings
|
self._dynamic_stream_settings_by_entity_id[entity_id] = settings
|
||||||
return settings
|
return settings
|
||||||
|
|
||||||
|
|
||||||
|
async def get_dynamic_camera_stream_settings(
|
||||||
|
hass: HomeAssistant, entity_id: str
|
||||||
|
) -> DynamicStreamSettings:
|
||||||
|
"""Get dynamic stream settings for a camera entity."""
|
||||||
|
if DATA_CAMERA_PREFS not in hass.data:
|
||||||
|
raise HomeAssistantError("Camera integration not set up")
|
||||||
|
return await hass.data[DATA_CAMERA_PREFS].get_dynamic_stream_settings(entity_id)
|
||||||
|
@@ -31,7 +31,7 @@ from homeassistant.components.camera import (
|
|||||||
WebRTCSendMessage,
|
WebRTCSendMessage,
|
||||||
async_register_webrtc_provider,
|
async_register_webrtc_provider,
|
||||||
)
|
)
|
||||||
from homeassistant.components.camera.helper import get_dynamic_camera_stream_settings
|
from homeassistant.components.camera.prefs import get_dynamic_camera_stream_settings
|
||||||
from homeassistant.components.default_config import DOMAIN as DEFAULT_CONFIG_DOMAIN
|
from homeassistant.components.default_config import DOMAIN as DEFAULT_CONFIG_DOMAIN
|
||||||
from homeassistant.components.stream import Orientation
|
from homeassistant.components.stream import Orientation
|
||||||
from homeassistant.config_entries import SOURCE_SYSTEM, ConfigEntry
|
from homeassistant.config_entries import SOURCE_SYSTEM, ConfigEntry
|
||||||
|
@@ -3,10 +3,10 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.camera.const import DATA_CAMERA_PREFS
|
from homeassistant.components.camera.const import DATA_CAMERA_PREFS
|
||||||
from homeassistant.components.camera.helper import get_dynamic_camera_stream_settings
|
|
||||||
from homeassistant.components.camera.prefs import (
|
from homeassistant.components.camera.prefs import (
|
||||||
CameraPreferences,
|
CameraPreferences,
|
||||||
DynamicStreamSettings,
|
DynamicStreamSettings,
|
||||||
|
get_dynamic_camera_stream_settings,
|
||||||
)
|
)
|
||||||
from homeassistant.components.stream import Orientation
|
from homeassistant.components.stream import Orientation
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
Reference in New Issue
Block a user