-
-
Notifications
You must be signed in to change notification settings - Fork 30.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add go2rtc and extend camera integration for better WebRTC support (#…
- Loading branch information
Showing
35 changed files
with
1,476 additions
and
225 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Camera helper functions.""" | ||
|
||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from homeassistant.core import HomeAssistant | ||
from homeassistant.exceptions import HomeAssistantError | ||
|
||
from .const import DATA_COMPONENT | ||
|
||
if TYPE_CHECKING: | ||
from . import Camera | ||
|
||
|
||
def get_camera_from_entity_id(hass: HomeAssistant, entity_id: str) -> Camera: | ||
"""Get camera component from entity_id.""" | ||
component = hass.data.get(DATA_COMPONENT) | ||
if component is None: | ||
raise HomeAssistantError("Camera integration not set up") | ||
|
||
if (camera := component.get_entity(entity_id)) is None: | ||
raise HomeAssistantError("Camera not found") | ||
|
||
if not camera.is_on: | ||
raise HomeAssistantError("Camera is off") | ||
|
||
return camera |
Oops, something went wrong.