Skip to content

Commit

Permalink
Add support multiple go2rtc servers #542
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Aug 24, 2023
1 parent 06dce6e commit 6777802
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 6 additions & 1 deletion custom_components/webrtc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry):


async def ws_connect(hass: HomeAssistantType, params: dict) -> str:
server: Union[str, Server] = hass.data[DOMAIN]
# 1. Server URL from card param
server: str = params.get("server")
# 2. Server URL from integration settings
if not server:
server: Union[str, Server] = hass.data[DOMAIN]
# 3. Server is manual binary
if isinstance(server, Server):
assert server.available, "WebRTC server not available"
server = "http://localhost:1984/"
Expand Down
5 changes: 4 additions & 1 deletion custom_components/webrtc/www/webrtc-camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class WebRTCCamera extends VideoRTC {
/**
* @type {{
* url:string, entity:string, muted:boolean, poster:string, title:string,
* intersection:number, ui:boolean, style:string,
* intersection:number, ui:boolean, style:string, server:string,
* digital_ptz:{
* mouse_drag_pan:boolean,
* mouse_wheel_zoom:boolean,
Expand Down Expand Up @@ -100,6 +100,9 @@ class WebRTCCamera extends VideoRTC {
if (this.config.url) {
this.wsURL += '&url=' + encodeURIComponent(this.config.url);
}
if (this.config.server) {
this.wsURL += '&server=' + encodeURIComponent(this.config.server);
}
if (this.config.entity) {
this.wsURL += '&entity=' + this.config.entity;
}
Expand Down

0 comments on commit 6777802

Please sign in to comment.