Skip to content

Commit

Permalink
Add hass_url param to dash_cast service
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Apr 7, 2024
1 parent b85b3eb commit 89899e6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions custom_components/webrtc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@
vol.Required(ATTR_ENTITY_ID): cv.entity_ids,
vol.Exclusive("url", "url"): cv.string,
vol.Exclusive("entity", "url"): cv.entity_id,
vol.Optional("force", default=False): bool,
vol.Optional("extra"): dict,
vol.Optional("force", default=False): bool,
vol.Optional("hass_url"): str,
},
required=True,
)
Expand Down Expand Up @@ -93,20 +94,24 @@ async def create_link(call: ServiceCallType):
async def dash_cast(call: ServiceCallType):
link_id = uuid.uuid4().hex
LINKS[link_id] = {
"url": call.data.get("url"),
"entity": call.data.get("entity"),
"url": call.data.get("url"), # camera URL (rtsp...)
"entity": call.data.get("entity"), # camera entity id
"limit": 1, # 1 attempt
"ts": time.time() + 30, # for 30 seconds
}

hass_url = call.data.get("hass_url") or get_url(hass)
query = call.data.get("extra", {})
query["url"] = link_id
cast_url = hass_url + "/webrtc/embed?" + urlencode(query)

_LOGGER.debug(f"dash_cast: {cast_url}")

await hass.async_add_executor_job(
utils.dash_cast,
hass,
call.data[ATTR_ENTITY_ID],
f"{get_url(hass)}/webrtc/embed?" + urlencode(query),
cast_url,
call.data.get("force", False),
)

Expand Down

0 comments on commit 89899e6

Please sign in to comment.