Skip to content

Commit

Permalink
Fix URL as direct camera source #522
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Jul 11, 2023
1 parent 8836726 commit e51aac0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions custom_components/webrtc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,21 @@ async def ws_connect(hass: HomeAssistantType, params) -> str:
params={"name": entity, "src": src},
timeout=3,
)
if r.ok:
src = entity
assert r.ok, f"Can't update URL for {entity}"
src = entity

elif src := params.get("url"):
if "{{" in src or "{%" in src:
src = Template(src, hass).async_render()

session = async_get_clientsession(hass)
r = await session.patch(
urljoin(go_url, "api/streams"),
params={"name": src, "src": src},
timeout=3,
)
assert r.ok, f"Can't update URL for {src}"

else:
raise Exception("Missing url or entity")

Expand Down

0 comments on commit e51aac0

Please sign in to comment.