### Full Configuration Example Source: https://github.com/alexxit/webrtc/blob/master/README.md A comprehensive example showcasing all available settings, including URL, entity, mode, media, server, UI controls, digital PTZ, title, poster, mute, intersection, background, and shortcuts. All settings are optional. ```yaml type: 'custom:webrtc-camera' url: 'rtsp://rtsp:12345678@192.168.1.123:554/av_stream/ch0' entity: camera.generic_stream mode: webrtc,webrtc/tcp,mse,hls,mjpeg # stream technology, default all of them media: video,audio # select only video or audio track, default both server: http://192.168.1.123:1984/ # custom go2rtc server address, default empty ui: true # custom video controls, default false digital_ptz: # digital zoom and pan via mouse/touch, defaults: mouse_drag_pan: true mouse_wheel_zoom: true mouse_double_click_zoom: true touch_drag_pan: true touch_pinch_zoom: true touch_tap_drag_zoom: true persist: true # zoom factor and viewport position survive page reloads # digital_ptz: false # to disable all mouse/touch digital zoom and pan title: My super camera # optional card title poster: https://home-assistant.io/images/cast/splash.png # still image when stream is loading muted: true # initial mute toggle state, default is false (unmuted) intersection: 0.75 # auto stop stream when less than 75% of video element is in the screen, 50% by default background: true # run stream when not displayed (ex. for quick video loading), default false shortcuts: - name: Record icon: mdi:record-circle-outline service: switch.toggle service_data: entity_id: switch.camera_record ``` -------------------------------- ### Coturn Configuration File Example Source: https://github.com/alexxit/webrtc/wiki/Coturn-Example A sample coturn.conf file. Customize realm, external-ip, and user credentials for your TURN server setup. This configuration enables fingerprinting, specifies listening IPs and ports, and sets up user authentication with long-term credentials. ```plaintext # TURN server name and realm realm=123.123.123.123 server-name=turnserver # Use fingerprint in TURN message fingerprint # IPs the TURN server listens to listening-ip=0.0.0.0 # External IP-Address of the TURN server external-ip=123.123.123.123 # Main listening port listening-port=3478 # Further ports that are open for communication min-port=10000 max-port=20000 # Log file path # log-file=/var/log/turnserver.log # Enable verbose logging # verbose # Specify the user for the TURN authentification user=test:test123 # Enable long-term credential mechanism lt-cred-mech ``` -------------------------------- ### HLS Proxy API Example Requests Source: https://context7.com/alexxit/webrtc/llms.txt Examples of GET requests to the HLS Proxy API for fetching playlist and segment files. These are automatically used by the card when HLS mode is active. ```bash # Automatically used by the card when HLS mode is active GET /api/webrtc/hls/playlist.m3u8?src=front_door GET /api/webrtc/hls/init.mp4?src=front_door GET /api/webrtc/hls/segment.m4s?src=front_door GET /api/webrtc/hls/segment.ts?src=front_door ``` -------------------------------- ### Install ESLint and ESLint Plugin HTML Source: https://github.com/alexxit/webrtc/wiki/Developer-Guide Installs ESLint and the ESLint HTML plugin globally using npm. Ensure Node.js is installed and the NODE_PATH environment variable is set. ```bash npm install -g eslint npm install -g eslint-plugin-html ``` -------------------------------- ### Install WebRTC Camera via HACS or Manually Source: https://context7.com/alexxit/webrtc/llms.txt Instructions for installing the WebRTC Camera custom component using HACS or by manually copying files. ```bash # Method 1: HACS (recommended) HACS > Integrations > + > Search "WebRTC" > Install # Method 2: Manual # Copy the webrtc/ folder from the latest GitHub release to: /config/custom_components/webrtc/ # Then add the integration: # Settings > Devices & Services > Add Integration > WebRTC Camera ``` -------------------------------- ### Template Example for PTZ Controls Source: https://github.com/alexxit/webrtc/blob/master/README.md Use JavaScript templates in the `ptz` configuration to dynamically display information about the stream when PTZ controls are interacted with. This example shows messages indicating which direction was clicked and for which stream. ```yaml ptz: service: notify.persistent_notification data_left: message: Left for ${ this.streamName } clicked data_right: message: Rigth for ${ this.streamID } clicked ``` -------------------------------- ### Docker Compose for Coturn TURN Server Source: https://context7.com/alexxit/webrtc/llms.txt Example docker-compose.yml to deploy a Coturn TURN server. This is essential for external/remote WebRTC connections. ```yaml # docker-compose.yml version: '3.1' services: coturn: image: instrumentisto/coturn network_mode: host volumes: - ~/docker/coturn.conf:/my/coturn.conf command: -c /my/coturn.conf ``` -------------------------------- ### Coturn Configuration File Source: https://context7.com/alexxit/webrtc/llms.txt Example coturn.conf file for setting up a TURN server. Key parameters include realm, listening IPs, ports, and user credentials. ```ini # coturn.conf realm=123.123.123.123 server-name=turnserver fingerprint listening-ip=0.0.0.0 external-ip=123.123.123.123 listening-port=3478 min-port=10000 max-port=20000 user=myuser:mypassword lt-cred-mech ``` -------------------------------- ### Template Example for Shortcuts Source: https://github.com/alexxit/webrtc/blob/master/README.md Utilize JavaScript templates within the `shortcuts` configuration to dynamically set icons based on entity states. This allows for visual feedback on the status of controlled devices. ```yaml shortcuts: - name: Barn Light icon: ${ states['light.yeelight_lamp'].state === 'on' ? 'mdi:outdoor-lamp':'mdi:lamp' } service: light.toggle service_data: entity_id: light.yeelight_lamp ``` -------------------------------- ### Lovelace Card - Minimal Configuration Examples Source: https://context7.com/alexxit/webrtc/llms.txt Basic configurations for the `custom:webrtc-camera` Lovelace card, showing how to use a direct RTSP URL, a named go2rtc stream, or a Home Assistant camera entity. ```yaml # Using a direct RTSP URL type: 'custom:webrtc-camera' url: 'rtsp://admin:pass@192.168.1.10:554/h264/ch01/main/av_stream' ``` ```yaml # Using a named go2rtc stream type: 'custom:webrtc-camera' url: 'front_door' ``` ```yaml # Using a Home Assistant camera entity type: 'custom:webrtc-camera' entity: camera.generic_stream ``` -------------------------------- ### QNAP Camera RTSP URL Source: https://github.com/alexxit/webrtc/blob/master/README.md Example RTSP URL for QNAP QUSBCam2. Refer to the provided documentation for detailed format. ```text rtsp://username:password@192.168.1.123:554/channel1 ``` -------------------------------- ### ONVIF PTZ Configuration Source: https://github.com/alexxit/webrtc/wiki/PTZ-Config-Examples Set up PTZ controls for ONVIF-compliant cameras. This example uses the 'onvif.ptz' service and specifies pan and tilt movements, along with optional zoom controls. ```yaml type: 'custom:webrtc-camera' entity: ... ptz: service: onvif.ptz data_left: entity_id: ... pan: LEFT data_right: entity_id: ... pan: RIGHT data_up: entity_id: ... tilt: UP data_down: entity_id: ... tilt: DOWN data_zoom_in: # optional, for zoom increase entity_id: ... zoom: ZOOM_IN data_zoom_out: # optional, for zoom decrease entity_id: ... zoom: ZOOM_OUT ``` -------------------------------- ### Custom PTZ Script Configuration Source: https://github.com/alexxit/webrtc/wiki/PTZ-Config-Examples Example of configuring custom PTZ controls using Home Assistant scripts. This involves defining a 'rest_command' for camera PTZ actions and then calling these scripts from the card. ```yaml script: camera_ptz: sequence: - service: rest_command.camera_ptz_start data: param: "{{ direction }}" - service: rest_command.camera_ptz_stop data: param: "{{ direction }}" ``` ```yaml type: 'custom:webrtc-camera' entity: ... ptz: service: script.camera_ptz data_left: direction: directionleft data_right: direction: directionright data_up: direction: directionup data_down: direction: directiondown ``` -------------------------------- ### Configure go2rtc.yaml for Streams and API Security Source: https://context7.com/alexxit/webrtc/llms.txt Example configuration for go2rtc.yaml to define API/RTSP listen addresses, authentication, and named camera streams. Recommended to restrict API and RTSP to localhost for security. ```yaml # /config/go2rtc.yaml # Restrict API and RTSP to localhost only (recommended for security) api: listen: 127.0.0.1:1984 username: admin # optional HTTP basic auth password: secret rtsp: listen: 127.0.0.1:8554 username: admin password: secret # Define named streams (referenced by name in the Lovelace card) streams: front_door: rtsp://admin:pass@192.168.1.10:554/h264/ch01/main/av_stream backyard: rtsp://192.168.1.11:554/stream0 dafang: rtsp://192.168.1.12:8554/unicast tapo_hd: rtsp://user:pass@192.168.1.13:554/stream1 tapo_sd: rtsp://user:pass@192.168.1.13:554/stream2 # Optional: FFmpeg transcoding for unsupported codecs ffmpeg: bin: ffmpeg ``` -------------------------------- ### Imou Camera RTSP URL Source: https://github.com/alexxit/webrtc/blob/master/README.md Example RTSP URL for Imou cameras. Replace 'password' with your camera's actual password. ```text rtsp://admin:password@192.168.1.123:554/cam/realmonitor?channel=1&subtype=0 ``` -------------------------------- ### Topvico Camera RTSP URLs Source: https://github.com/alexxit/webrtc/blob/master/README.md Example RTSP URLs for Topvico cameras. Offers two different stream formats. ```text rtsp://192.168.1.123:8554/stream0 ``` ```text rtsp://192.168.1.123:554/ch0_0.264 ``` -------------------------------- ### Hikvision Camera RTSP URL Source: https://github.com/alexxit/webrtc/blob/master/README.md Example RTSP URL for Hikvision cameras. Ensure correct user, password, and IP address. ```text rtsp://user:pass@192.168.1.123:554/ISAPI/Streaming/Channels/102 ``` -------------------------------- ### Custom Shortcuts Position Styling Source: https://github.com/alexxit/webrtc/blob/master/README.md Reposition the shortcuts menu using CSS. This example places the shortcuts to the top right of the card, stacked vertically. ```yaml style: ".shortcuts {left: unset; top: 25px; right: 5px; display: flex; flex-direction: column}" ``` -------------------------------- ### Reolink E1 Zoom PTZ Configuration Source: https://github.com/alexxit/webrtc/wiki/PTZ-Config-Examples Example configuration for Reolink E1 Zoom camera PTZ controls using the ONVIF service. Note the 'move_mode: ContinuousMove' for continuous movement. ```yaml type: custom:webrtc-camera entity: camera.reolink_e1_zoom_profile000_mainstream webrtc: false ptz: service: onvif.ptz data_left: entity_id: camera.reolink_e1_zoom_profile000_mainstream pan: LEFT move_mode: ContinuousMove data_right: entity_id: camera.reolink_e1_zoom_profile000_mainstream pan: RIGHT move_mode: ContinuousMove data_up: entity_id: camera.reolink_e1_zoom_profile000_mainstream tilt: UP move_mode: ContinuousMove data_down: entity_id: camera.reolink_e1_zoom_profile000_mainstream tilt: DOWN move_mode: ContinuousMove data_zoom_in: entity_id: camera.reolink_e1_zoom_profile000_mainstream zoom: ZOOM_IN move_mode: ContinuousMove data_zoom_out: entity_id: camera.reolink_e1_zoom_profile000_mainstream zoom: ZOOM_OUT move_mode: ContinuousMove ``` -------------------------------- ### Roborock PTZ Configuration Source: https://github.com/alexxit/webrtc/wiki/PTZ-Config-Examples Configure PTZ controls for Roborock vacuums using the 'roborock.vacuum_remote_control_move' service. This example defines movement duration, rotation, and velocity. ```yaml ptz: service: roborock.vacuum_remote_control_move data_left: duration: 0 rotation: 30 velocity: 0 entity_id: vacuum.tank data_right: duration: 0 rotation: -30 velocity: 0 entity_id: vacuum.tank data_up: duration: 1000 rotation: 0 velocity: 0.29 entity_id: vacuum.tank data_down: duration: 1000 rotation: 0 velocity: -0.29 entity_id: vacuum.tank ``` -------------------------------- ### Reolink E1 Camera RTSP URL Source: https://github.com/alexxit/webrtc/blob/master/README.md Example RTSP URL for Reolink E1 cameras. This URL is for the main stream. ```text rtsp://admin:password@192.168.1.123:554/h264Preview_01_main ``` -------------------------------- ### WebSocket Proxy API Connection URLs Source: https://context7.com/alexxit/webrtc/llms.txt Examples of WebSocket connection URLs for the `/api/webrtc/ws` endpoint. These are typically assembled automatically by the card and require a signed HA path token. ```bash # Connection URL structure (assembled by the card automatically) ws://homeassistant.local:8123/api/webrtc/ws?&entity=camera.front_door ws://homeassistant.local:8123/api/webrtc/ws?&url=rtsp%3A%2F%2F... ws://homeassistant.local:8123/api/webrtc/ws?&url=&embed=1 ``` -------------------------------- ### Xiaomi Dafang PTZ Configuration (with hack) Source: https://github.com/alexxit/webrtc/wiki/PTZ-Config-Examples Configure PTZ for Xiaomi Dafang cameras using MQTT. This requires the Xiaomi Dafang Hacks to be installed and configured. ```yaml type: 'custom:webrtc-camera' entity: ... ptz: service: mqtt.publish data_left: topic: myhome/dafang/motors/horizontal/set payload: left data_right: topic: myhome/dafang/motors/horizontal/set payload: right data_up: topic: myhome/dafang/motors/vertical/set payload: up data_down: topic: myhome/dafang/motors/vertical/set payload: down ``` -------------------------------- ### Custom PTZ Position Styling Source: https://github.com/alexxit/webrtc/blob/master/README.md Adjust the position of the Pan-Tilt-Zoom (PTZ) controls using CSS. This example moves the PTZ controls to the left side of the card. ```yaml style: ".ptz {right: unset; left: 10px}" ``` -------------------------------- ### Custom Header Line Position Styling Source: https://github.com/alexxit/webrtc/blob/master/README.md Adjust the position of the header line using CSS. This example moves the header line to the bottom of the header area. ```yaml style: '.header {top: unset; bottom: 6px}' ``` -------------------------------- ### WebSocket Proxy API Poster/Snapshot Request Source: https://context7.com/alexxit/webrtc/llms.txt Fetch a poster image or snapshot using the WebSocket API. The request is made via GET to the `/api/webrtc/ws` endpoint with a signed token and poster entity. ```bash # Fetch poster/snapshot image (returns JPEG) GET /api/webrtc/ws?&poster=camera.front_door GET /api/webrtc/ws?&poster=front_door_snap ``` -------------------------------- ### Configure Media Players for Camera Streams Source: https://github.com/alexxit/webrtc/blob/master/README.md Set up virtual Media Players for your cameras in configuration.yaml to stream audio. Ensure the 'stream' and 'audio' parameters match your camera's capabilities and go2rtc configuration. ```yaml media_player: - platform: webrtc name: Dahua Camera stream: dahua audio: pcmu/48000 - platform: webrtc name: Tapo Camera stream: tapo audio: pcma ``` -------------------------------- ### Minimal Configuration with RTSP URL Source: https://github.com/alexxit/webrtc/blob/master/README.md Use this minimal configuration when you have a direct RTSP stream URL. Ensure the URL is correct and accessible. ```yaml type: 'custom:webrtc-camera' url: 'rtsp://rtsp:12345678@192.168.1.123:554/av_stream/ch0' ``` -------------------------------- ### Minimal Configuration with Camera Entity Source: https://github.com/alexxit/webrtc/blob/master/README.md Use this configuration to directly link the card to a Home Assistant camera entity. Ensure the entity ID is correct. ```yaml type: 'custom:webrtc-camera' entity: camera.generic_stream # change to your camera entity_id ``` -------------------------------- ### Lovelace Card - Full Configuration Options Source: https://context7.com/alexxit/webrtc/llms.txt Comprehensive configuration for the `custom:webrtc-camera` Lovelace card, detailing all available options for stream source, modes, media tracks, server settings, display, lifecycle, digital PTZ, and custom actions. ```yaml type: 'custom:webrtc-camera' # Stream source (one required) url: 'rtsp://rtsp:12345678@192.168.1.123:554/av_stream/ch0' entity: camera.generic_stream # Streaming mode priority (comma-separated, tried in order) # Options: webrtc, webrtc/tcp, mse, hls, mp4, mjpeg mode: webrtc,webrtc/tcp,mse,hls,mjpeg # Media tracks to request # Options: video, audio, microphone media: video,audio # Custom go2rtc server (overrides integration setting) server: 'http://192.168.1.50:1984/' # Card display title: Front Door Camera poster: https://example.com/splash.png # or camera entity, go2rtc stream name, Jinja2 template muted: false # initial mute state ui: true # show custom video controls (play/pause, volume, fullscreen, PiP, screenshot) # Stream lifecycle background: false # keep stream running even when card not visible intersection: 0.75 # pause stream when less than 75% visible (0 to disable) # Digital PTZ (zoom/pan via mouse and touch) digital_ptz: mouse_drag_pan: true mouse_wheel_zoom: true mouse_double_click_zoom: true touch_drag_pan: true touch_pinch_zoom: true touch_tap_drag_zoom: true persist: true # save zoom/pan state across page reloads # Custom action shortcuts shortcuts: - name: Record icon: mdi:record-circle-outline service: switch.toggle service_data: entity_id: switch.camera_record # Video CSS overrides style: "video {aspect-ratio: 16/9; object-fit: fill;}" ``` -------------------------------- ### Create Temporary Camera Link Source: https://github.com/alexxit/webrtc/wiki/Cast-or-share-camera-stream Generate a temporary, shareable link to a camera stream using the `webrtc.create_link` service. The link has a default open limit of 1 and a time-to-live of 60 seconds, accessible without Home Assistant login. Be aware that the viewer may obtain your real IP address. ```yaml script: create_camera_link: alias: Create temporary camera link sequence: - variables: link_id: "0{% for _ in range(39) %}{{ range(10)|random }}{% endfor %}" - service: webrtc.create_link data: link_id: "{{ link_id }}" # create a random or permanent link ID # url: rtsp://rtsp:12345678@192.168.1.123:554/av_stream/ch0 entity: camera.sonoff # you can use camera entity_id or url open_limit: 1 # how many times a link can be opened (0 - unlimit, 1 - default) time_to_live: 60 # how many seconds will the link live (0 - unlimit, 60 - default) - service: persistent_notification.create data: message: 'Open Camera' ``` -------------------------------- ### Custom Mode Label Position Styling Source: https://github.com/alexxit/webrtc/blob/master/README.md Modify the position of the mode label within the header using CSS. This example places the mode label at the bottom of the header. ```yaml style: '.header {bottom: 6px} .mode {position: absolute; bottom: 0px}' ``` -------------------------------- ### Configure WebRTC Media Players Source: https://context7.com/alexxit/webrtc/llms.txt Define WebRTC media players in your configuration.yaml. Specify the stream name from go2rtc and the audio codec the camera accepts. ```yaml media_player: - platform: webrtc name: Dahua Doorbell stream: dahua # go2rtc stream name audio: pcmu/48000 # codec/rate the camera accepts - platform: webrtc name: Tapo Indoor stream: tapo audio: pcma # G.711 A-law ``` -------------------------------- ### Configuration with Multiple Streams Source: https://github.com/alexxit/webrtc/blob/master/README.md Define multiple streams with different modes and media types. This allows for adaptive streaming or selecting specific audio/video tracks. ```yaml type: 'custom:webrtc-camera' streams: - url: go2rtc_stream_hd name: HD # name is optional mode: webrtc # mode is optional media: video # media is optional - url: go2rtc_stream_sd name: SD mode: mse media: audio ``` -------------------------------- ### Add Custom Card to UI Resources (YAML Mode) Source: https://github.com/alexxit/webrtc/blob/master/README.md If managing your Home Assistant UI in YAML mode, add this resource entry to enable the custom:webrtc-camera card. ```yaml url: /webrtc/webrtc-camera.js type: module ``` -------------------------------- ### Paused by Default Configuration Source: https://github.com/alexxit/webrtc/blob/master/README.md Configure the card to show only a poster initially, with the stream loading only when interacted with. This saves resources when the stream is not actively being watched. ```yaml type: custom:webrtc-camera poster: dahua1-snap # stream name from go2rtc.yaml (http-snapshot) streams: - url: '' # empty url, so only poster will be shown - url: dahua1 # stream name from go2rtc.yaml (rtsp-stream) ``` -------------------------------- ### Video Aspect Ratio Styling Source: https://github.com/alexxit/webrtc/blob/master/README.md Apply custom CSS to set the video aspect ratio and object fit. Use 'fill' for object-fit to ensure the video fills the container, potentially distorting aspect ratio if it doesn't match. ```yaml style: "video {aspect-ratio: 16/9; object-fit: fill;}" ``` -------------------------------- ### Unifi Camera RTSP Configuration Source: https://github.com/alexxit/webrtc/blob/master/README.md Instructions for obtaining the RTSP link for Unifi cameras. Requires modifying the default rstps:// link to rstp://, changing the port, and removing query parameters. ```text rstp://:@:7447/ ``` -------------------------------- ### Configure go2rtc to Use TURN Server Source: https://context7.com/alexxit/webrtc/llms.txt Reference the deployed TURN server in your go2rtc configuration (go2rtc.yaml) under the 'webrtc.ice_servers' section. Provide the server URL, username, and password. ```yaml # go2rtc.yaml — reference the TURN server webrtc: ice_servers: - urls: [turn:123.123.123.123:3478] username: myuser credential: mypassword ``` -------------------------------- ### Embed WebRTC Camera Component Source: https://github.com/alexxit/webrtc/blob/master/custom_components/webrtc/www/embed.html This script initializes and embeds a WebRTC camera component. It parses URL query parameters to configure the component and sets up a mock WebSocket connection for demonstration purposes. ```javascript const config = {}; for (const [k, v] of new URLSearchParams(location.search)) { if (v === 'true') config[k] = true; else if (v === 'false') config[k] = false; else config[k] = v; } const card = document.createElement('webrtc-camera'); card.setConfig(config); card.hass = { callWS: () => new Promise(resolve => { resolve(''); }), hassUrl: () => location.origin + '/api/webrtc/ws?embed=1' }; document.body.appendChild(card); ``` -------------------------------- ### Service: webrtc.create_link Source: https://context7.com/alexxit/webrtc/llms.txt Generates a temporary or permanent public URL for a camera stream, allowing access without Home Assistant credentials. Useful for sharing camera feeds. ```APIDOC ## Service — `webrtc.create_link` Creates a temporary (or permanent) public URL to a camera stream, accessible without Home Assistant credentials. ```yaml # Create a one-time, 60-second shareable camera link and notify via HA script: share_camera: alias: Share camera link sequence: - variables: link_id: "0{% for _ in range(39) %}{{ range(10)|random }}{% endfor %}" - service: webrtc.create_link data: link_id: "{{ link_id }}" entity: camera.front_door # or use url: rtsp://... open_limit: 1 # 0 = unlimited opens time_to_live: 300 # seconds; 0 = never expires - service: persistent_notification.create data: title: Camera Link message: > Watch Front Door (expires in 5 min) ``` ``` -------------------------------- ### Create Temporary Camera Link Source: https://context7.com/alexxit/webrtc/llms.txt Generates a temporary, shareable URL for a camera stream using the webrtc.create_link service. Useful for one-time shares without requiring HA credentials. ```yaml # Create a one-time, 60-second shareable camera link and notify via HA script: share_camera: alias: Share camera link sequence: - variables: link_id: "0{% for _ in range(39) %}{{ range(10)|random }}{% endfor %}" - service: webrtc.create_link data: link_id: "{{ link_id }}" entity: camera.front_door # or use url: rtsp://... open_limit: 1 # 0 = unlimited opens time_to_live: 300 # seconds; 0 = never expires - service: persistent_notification.create data: title: Camera Link message: > Watch Front Door (expires in 5 min) ``` -------------------------------- ### PTZ Controls for Xiaomi Dafang Cameras Source: https://context7.com/alexxit/webrtc/llms.txt Set up PTZ controls for Xiaomi Dafang cameras via MQTT using the mqtt.publish service. ```yaml # Xiaomi Dafang via MQTT type: 'custom:webrtc-camera' entity: camera.dafang ptz: service: mqtt.publish data_left: topic: myhome/dafang/motors/horizontal/set payload: left data_right: topic: myhome/dafang/motors/horizontal/set payload: right data_up: topic: myhome/dafang/motors/vertical/set payload: up data_down: topic: myhome/dafang/motors/vertical/set payload: down ``` -------------------------------- ### Tapo PTZ Configuration Source: https://github.com/alexxit/webrtc/wiki/PTZ-Config-Examples Set up PTZ controls for Tapo cameras using the 'button.press' service. This configuration assumes dedicated buttons for each movement direction. ```yaml type: custom:webrtc-camera streams: - entity: camera.cameraname_hd_stream mode: webrtc muted: true ptz: service: button.press data_left: entity_id: button.cameraname_move_left data_right: entity_id: button.cameraname_move_right data_up: entity_id: button.cameraname_move_up data_down: entity_id: button.cameraname_move_down ``` -------------------------------- ### Enable Debug Logging for WebRTC Component Source: https://context7.com/alexxit/webrtc/llms.txt Enable debug logging for the 'custom_components.webrtc' logger in Home Assistant's configuration.yaml to diagnose stream connection issues. ```yaml logger: default: warning logs: custom_components.webrtc: debug ``` -------------------------------- ### Paused-by-default Camera Stream Source: https://context7.com/alexxit/webrtc/llms.txt Configure the camera to show only a poster until the user clicks. Use an empty stream URL for the poster-only mode. ```yaml type: custom:webrtc-camera poster: front_door_snap # go2rtc snapshot stream name streams: - url: '' # empty = show poster only - url: front_door # actual stream ``` -------------------------------- ### Minimal Configuration with Stream Name Source: https://github.com/alexxit/webrtc/blob/master/README.md Configure the card using a stream name defined in your go2rtc configuration. This is useful for managing multiple streams centrally. ```yaml type: 'custom:webrtc-camera' url: 'camera1' # stream name from go2rtc.yaml ``` -------------------------------- ### PTZ Controls for ONVIF Cameras Source: https://context7.com/alexxit/webrtc/llms.txt Map directional buttons to ONVIF PTZ services for native Home Assistant camera integrations. ```yaml # ONVIF cameras (native HA integration) type: 'custom:webrtc-camera' entity: camera.reolink_e1_zoom ptz: service: onvif.ptz data_left: entity_id: camera.reolink_e1_zoom pan: LEFT move_mode: ContinuousMove data_right: entity_id: camera.reolink_e1_zoom pan: RIGHT move_mode: ContinuousMove data_up: entity_id: camera.reolink_e1_zoom tilt: UP move_mode: ContinuousMove data_down: entity_id: camera.reolink_e1_zoom tilt: DOWN move_mode: ContinuousMove data_zoom_in: entity_id: camera.reolink_e1_zoom zoom: ZOOM_IN move_mode: ContinuousMove data_zoom_out: entity_id: camera.reolink_e1_zoom zoom: ZOOM_OUT move_mode: ContinuousMove ``` -------------------------------- ### Lovelace Card - Multiple Switchable Streams Source: https://context7.com/alexxit/webrtc/llms.txt Configuration for the `custom:webrtc-camera` Lovelace card to display multiple switchable streams. Streams can be defined using go2rtc names, HA entities, and specify individual modes and media tracks. ```yaml type: 'custom:webrtc-camera' streams: - url: front_door_hd # go2rtc stream name name: HD mode: webrtc media: video,audio - url: front_door_sd name: SD mode: mse media: audio - entity: camera.front_door_lowres name: Fallback ``` -------------------------------- ### PTZ Controls for Sonoff Cameras Source: https://context7.com/alexxit/webrtc/llms.txt Configure PTZ controls for Sonoff cameras using the sonoff.send_command service. ```yaml # Sonoff cameras type: 'custom:webrtc-camera' entity: camera.sonoff_cam ptz: opacity: 0.4 service: sonoff.send_command data_left: device: '048123' cmd: left data_right: device: '048123' cmd: right data_up: device: '048123' cmd: up data_down: device: '048123' cmd: down ``` -------------------------------- ### Two-Way Audio Configuration Source: https://context7.com/alexxit/webrtc/llms.txt Enable two-way audio by setting the 'microphone' media type. Requires HTTPS and WebRTC mode. ```yaml type: 'custom:webrtc-camera' streams: - url: front_door # view-only stream - url: front_door name: Intercom mode: webrtc media: video,audio,microphone # microphone enables two-way audio ``` -------------------------------- ### Docker Compose for Coturn Service Source: https://github.com/alexxit/webrtc/wiki/Coturn-Example Defines the Coturn service in a docker-compose.yml file. Ensure the volume path points to your local coturn.conf file. ```yaml version: '3.1' services: coturn: image: instrumentisto/coturn network_mode: host volumes: - ~/docker/coturn.conf:/my/coturn.conf command: -c /my/coturn.conf ``` -------------------------------- ### DashCast Service for Single Camera Stream Source: https://github.com/alexxit/webrtc/wiki/Cast-or-share-camera-stream Utilize the `webrtc.dash_cast` service to cast a single camera stream using the DashCast application. This method works even with local HTTP access to Home Assistant. ```yaml script: dash_cast_camera: alias: DashCast camera sequence: - service: webrtc.dash_cast entity_id: media_player.mibox4 # change to you chromecast media player data: # url: rtsp://rtsp:12345678@192.168.1.123:554/av_stream/ch0 entity: camera.sonoff # you can use camera entity_id or url extra: # optional settings for custom card (like in readme) mode: webrtc,mse ``` -------------------------------- ### ESLint Configuration in package.json Source: https://github.com/alexxit/webrtc/wiki/Developer-Guide Defines the ESLint configuration within the package.json file. This includes environment settings, parser options, rules, plugins, and overrides for HTML files. ```json { "devDependencies": { "eslint": "^8.44.0", "eslint-plugin-html": "^7.1.0" }, "eslintConfig": { "env": { "browser": true, "es6": true }, "parserOptions": { "ecmaVersion": 2017, "sourceType": "module" }, "rules": { "no-var": "error", "no-undef": "error", "no-unused-vars": "warn", "prefer-const": "error", "quotes": [ "error", "single" ], "semi": "error" }, "plugins": [ "html" ], "overrides": [ { "files": [ "*.html" ], "parserOptions": { "sourceType": "script" } } ] } } ``` -------------------------------- ### Automate TTS Announcements via Camera Source: https://context7.com/alexxit/webrtc/llms.txt Trigger a TTS announcement through a camera's speaker when a binary sensor (e.g., doorbell) is activated. Requires the tts integration and a configured media player. ```yaml automation: - alias: Announce visitor trigger: - platform: state entity_id: binary_sensor.doorbell to: 'on' action: - service: tts.google_translate_say data: entity_id: media_player.dahua_doorbell message: "Someone is at the door" ``` -------------------------------- ### PTZ Controls for Tapo Cameras Source: https://context7.com/alexxit/webrtc/llms.txt Configure PTZ controls for Tapo cameras using button presses via the button.press service. ```yaml # Tapo cameras (HomeAssistant-Tapo-Control integration) type: custom:webrtc-camera streams: - entity: camera.tapo_hd_stream mode: webrtc muted: true ptz: service: button.press data_left: entity_id: button.tapo_move_left data_right: entity_id: button.tapo_move_right data_up: entity_id: button.tapo_move_up data_down: entity_id: button.tapo_move_down ``` -------------------------------- ### PTZ Controls Configuration Source: https://context7.com/alexxit/webrtc/llms.txt Configure Pan-Tilt-Zoom (PTZ) controls for various camera types by mapping directional buttons to Home Assistant service calls. Supports ONVIF, Sonoff, Xiaomi Dafang, and Tapo cameras. ```APIDOC ## PTZ Controls — Physical Camera Movement The `ptz` key maps directional buttons to any Home Assistant service call. ```yaml # ONVIF cameras (native HA integration) type: 'custom:webrtc-camera' entity: camera.reolink_e1_zoom ptz: service: onvif.ptz data_left: entity_id: camera.reolink_e1_zoom pan: LEFT move_mode: ContinuousMove data_right: entity_id: camera.reolink_e1_zoom pan: RIGHT move_mode: ContinuousMove data_up: entity_id: camera.reolink_e1_zoom tilt: UP move_mode: ContinuousMove data_down: entity_id: camera.reolink_e1_zoom tilt: DOWN move_mode: ContinuousMove data_zoom_in: entity_id: camera.reolink_e1_zoom zoom: ZOOM_IN move_mode: ContinuousMove data_zoom_out: entity_id: camera.reolink_e1_zoom zoom: ZOOM_OUT move_mode: ContinuousMove # Sonoff cameras type: 'custom:webrtc-camera' entity: camera.sonoff_cam ptz: opacity: 0.4 service: sonoff.send_command data_left: device: '048123' cmd: left data_right: device: '048123' cmd: right data_up: device: '048123' cmd: up data_down: device: '048123' cmd: down # Xiaomi Dafang via MQTT type: 'custom:webrtc-camera' entity: camera.dafang ptz: service: mqtt.publish data_left: topic: myhome/dafang/motors/horizontal/set payload: left data_right: topic: myhome/dafang/motors/horizontal/set payload: right data_up: topic: myhome/dafang/motors/vertical/set payload: up data_down: topic: myhome/dafang/motors/vertical/set payload: down # Tapo cameras (HomeAssistant-Tapo-Control integration) type: custom:webrtc-camera streams: - entity: camera.tapo_hd_stream mode: webrtc muted: true ptz: service: button.press data_left: entity_id: button.tapo_move_left data_right: entity_id: button.tapo_move_right data_up: entity_id: button.tapo_move_up data_down: entity_id: button.tapo_move_down ``` ``` -------------------------------- ### Play Audio File via Camera Speaker Source: https://context7.com/alexxit/webrtc/llms.txt Play a specific audio file through a camera's speaker using the `play_media` service. Ensure the media file is accessible via Home Assistant's media source. ```yaml - service: media_player.play_media data: entity_id: media_player.tapo_indoor media_content_id: media-source://media_source/local/chime.mp3 media_content_type: audio/mp3 ``` -------------------------------- ### EZVIZ C3W, C3WN, C6CN, C6T RTSP Stream Source: https://github.com/alexxit/webrtc/blob/master/README.md Standard RTSP stream URL for several EZVIZ camera models. ```text rtsp://admin:pass@192.168.1.123:554/h264_stream ``` -------------------------------- ### Sonoff PTZ Configuration Source: https://github.com/alexxit/webrtc/wiki/PTZ-Config-Examples Configure PTZ controls for Sonoff cameras using the 'sonoff.send_command' service. Ensure your camera is compatible and the device ID and commands are correct. ```yaml type: 'custom:webrtc-camera' entity: ... ptz: # optional PTZ controls opacity: 0.4 # optional default contols opacity service: sonoff.send_command # service for control PTZ (check Hass docs to your camera) data_left: # service data for each direction device: '048123' cmd: left data_right: device: '048123' cmd: right data_up: device: '048123' cmd: up data_down: device: '048123' cmd: down ``` -------------------------------- ### Xiaomi Dafang Camera RTSP Configuration Source: https://github.com/alexxit/webrtc/blob/master/README.md RTSP stream configuration for Xiaomi Dafang cameras with custom hacks. Includes video and audio stream parameters. ```text rtsp://192.168.1.123:8554/unicast ``` -------------------------------- ### Video Rotation Styling (Client-side) Source: https://github.com/alexxit/webrtc/blob/master/README.md Rotate the video stream directly in the browser using CSS. This method is free of CPU cost on the server but might affect the aspect ratio if not handled correctly. ```yaml style: 'video {transform: rotate(90deg); aspect-ratio: 1}' ``` -------------------------------- ### Two-Way Audio Configuration Source: https://context7.com/alexxit/webrtc/llms.txt Enables two-way audio communication by specifying 'microphone' in the media stream configuration. Requires a supported go2rtc source and HTTPS access. ```APIDOC ## Lovelace Card — Two-Way Audio Two-way audio requires: a supported go2rtc source, HTTPS access to Home Assistant, and WebRTC mode. ```yaml type: 'custom:webrtc-camera' streams: - url: front_door # view-only stream - url: front_door name: Intercom mode: webrtc media: video,audio,microphone # microphone enables two-way audio ``` ``` -------------------------------- ### PTZ Controls with JavaScript Templates Source: https://context7.com/alexxit/webrtc/llms.txt Use JavaScript expressions in PTZ data to dynamically reference the current stream name or ID. ```yaml type: 'custom:webrtc-camera' streams: - url: cam_living_room name: Living Room - url: cam_garden name: Garden ptz: service: notify.persistent_notification data_left: message: "Left for ${ this.streamName } clicked" data_right: message: "Right for ${ this.streamID } clicked" ``` -------------------------------- ### Configure Entities Card for Casting Source: https://context7.com/alexxit/webrtc/llms.txt Use the 'cast' entity type within an 'entities' card to add buttons for casting Lovelace views to Chromecast devices. Specify the dashboard and view to cast. ```yaml # entities card with cast buttons type: entities entities: - type: cast name: Cast all cameras dashboard: lovelace view: cameras # /lovelace/cameras - type: cast name: Cast front door dashboard: lovelace-cameras view: front-door # /lovelace-cameras/front-door ``` -------------------------------- ### C-tronics CTIPC-690C RTSP/ONVIF Stream Source: https://github.com/alexxit/webrtc/blob/master/README.md Provides main stream RTSP or ONVIF URLs for C-tronics CTIPC-690C cameras. Supports sound. ```text rtsp://username:password@192.168.1.xx:554/11 ``` ```text onvif://username:password@192.168.1.xx:8080?subtype=MainStreamProfileToken ``` -------------------------------- ### PTZ JavaScript Templates Source: https://context7.com/alexxit/webrtc/llms.txt Utilize JavaScript expressions within `ptz.data_*` to dynamically reference the current stream name or ID for PTZ control actions. ```APIDOC ## PTZ — JavaScript Templates Use JavaScript expressions in `ptz.data_*` to reference current stream name or ID. ```yaml type: 'custom:webrtc-camera' streams: - url: cam_living_room name: Living Room - url: cam_garden name: Garden ptz: service: notify.persistent_notification data_left: message: "Left for ${ this.streamName } clicked" data_right: message: "Right for ${ this.streamID } clicked" ``` ``` -------------------------------- ### WebSocket Proxy API Source: https://context7.com/alexxit/webrtc/llms.txt The backend proxies WebSocket connections from the card to go2rtc. Authenticated via signed HA path tokens. Parameters are passed as query strings. ```APIDOC ## WebSocket Proxy API — `/api/webrtc/ws` ### Description Proxies WebSocket connections from the card to go2rtc, authenticated via signed HA path tokens. Parameters are passed as query strings. ### Connection URL Structure ``` ws://homeassistant.local:8123/api/webrtc/ws?&entity=camera.front_door ws://homeassistant.local:8123/api/webrtc/ws?&url=rtsp%3A%2F%2F... ws://homeassistant.local:8123/api/webrtc/ws?&url=&embed=1 ``` ### Fetch Poster/Snapshot Image #### Method GET #### Endpoint `/api/webrtc/ws?&poster=` #### Description Fetches a poster or snapshot image from the camera stream. Returns JPEG format. #### Query Parameters - **signed_token** (string) - Required - Signed Home Assistant path token for authentication. - **poster** (string) - Required - The entity ID of the camera or a custom name for the snapshot. #### Response Example (JPEG Image Data) ``` -------------------------------- ### Entities Card for Casting Cameras Source: https://github.com/alexxit/webrtc/wiki/Cast-or-share-camera-stream Use the entities card in Lovelace to cast camera streams to compatible devices. Ensure you have public HTTPS access to your Home Assistant. ```yaml type: entities entities: - type: cast name: Cast all cameras dashboard: lovelace view: cameras # View URL: https://myhass.duckdns.org/lovelace/cameras - type: cast name: Cast main camera dashboard: lovelace-cameras view: sonoff # View URL: https://myhass.duckdns.org/lovelace-cameras/sonoff ``` -------------------------------- ### Enable Two-Way Audio in WebRTC Camera Source: https://github.com/alexxit/webrtc/blob/master/README.md To enable two-way audio, add 'microphone' to the 'media' parameter in your stream configuration. This allows for audio input from the microphone. ```yaml type: 'custom:webrtc-camera' streams: - url: go2rtc_stream - url: go2rtc_stream mode: webrtc media: video,audio,microphone ``` -------------------------------- ### GW Security GW5071IP Potential RTSP Streams Source: https://github.com/alexxit/webrtc/blob/master/README.md These are potential RTSP stream URLs for the GW Security GW5071IP camera, as it is not currently working. One option includes username and password in the URL, the other uses query parameters. ```text rtsp://admin:123456@192.168.0.207:554/live/main ``` ```text rtsp://192.168.0.207:554/live/main?username=admin&password=123456 ```