WebRTC icon indicating copy to clipboard operation
WebRTC copied to clipboard

PTZ controls with the official HASS Reolink integration

Open threnbo opened this issue 1 year ago • 7 comments

Is it possible to use PTZ controls when using the official Relink integration (camera model E1 Zoom)?

The integrations adds button entities for PTZ controls. I tried using the example posted here https://github.com/AlexxIT/WebRTC/issues/167 but it doesn't work.

When adding the camera with the official Onvif integration the above mentioned example works, but I want to use several entites only added by the Reolink integration.

Thank you!

threnbo avatar Nov 22 '23 16:11 threnbo

It seems to work with this code:

type: custom:webrtc-camera
entity: camera.e1_zoom_main
ui: true
ptz:
  service: button.press
  data_left:
    entity_id: button.e1_zoom_ptz_left
  data_right:
    entity_id: button.e1_zoom_ptz_right
  data_up:
    entity_id: button.e1_zoom_ptz_up
  data_down:
    entity_id: button.e1_zoom_ptz_down
  data_zoom_in:
    entity_id: button.e1_zoom_ptz_zoom_in
  data_zoom_out:
    entity_id: button.e1_zoom_ptz_zoom_out

Remaining problem is that one button press means full movement in each direction.

threnbo avatar Nov 23 '23 16:11 threnbo

I see in the reolink integration docs that: "PTZ left, right, up, down, zoom in and zoom out will continually move the camera in the respective position until the PTZ stop is called or the hardware limit is reached."

So the issue could be solved with calling script like this:

e1_zoom_ptz_up_with_stop:
  alias: e1_zoom_ptz_up_with_stop
  sequence:
  - service: button.press
    target:
      entity_id: button.e1_zoom_ptz_up
  - delay:
      seconds: 0.5
  - service: button.press
    target:
      entity_id: button.e1_zoom_ptz_stop

The question is how to call that script from webrtc camera card?

muzzy124 avatar Dec 11 '23 09:12 muzzy124

You can use an automation for that.

Bildschirmfoto 2024-02-08 um 21 24 56

tunip avatar Feb 08 '24 20:02 tunip

Hi all,

I solved it with calling script from webrtc camera card like this:

type: custom:webrtc-camera
url: camera.garage_main
ui: true
background: true
muted: true
ptz:
  service: script.toggle
  data_left:
    entity_id: script.reolink_left
  data_right:
    entity_id: script.reolink_right
  data_up:
    entity_id: script.reolink_up
  data_down:
    entity_id: script.reolink_down

Here is my script example:

alias: Reolink Down
sequence:
  - service: button.press
    data: {}
    target:
      entity_id:
        - button.garage_ptz_down
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 500
  - service: button.press
    data: {}
    target:
      entity_id: button.garage_ptz_stop
mode: single
icon: mdi:arrow-down

So I have one script for each direction. Working well.

Greetings

Paul

porly1985 avatar Jun 01 '24 18:06 porly1985

@porly1985

could you please provide the complete YAML code with all the commands for the PTZ Control of the Reolink camera? I have the Reolink E1 Outdsoor pro.

That would be great!

groover0815 avatar Jun 17 '24 09:06 groover0815

WebRTC Card:

type: custom:webrtc-camera
url: camera.garage_main
ui: true
poster: camera.garage_snapshots_main
background: false
muted: true
persist: false
ptz:
  service: script.toggle
  data_left:
    entity_id: script.reolink_left
  data_right:
    entity_id: script.reolink_right
  data_up:
    entity_id: script.reolink_up
  data_down:
    entity_id: script.reolink_down
shortcuts:
  - name: Set Guard Position
    icon: mdi:crosshairs-gps
    service: button.press
    service_data:
      entity_id: button.garage_guard_set_current_position
  - name: Light
    icon: mdi:spotlight-beam
    service: light.toggle
    service_data:
      entity_id: light.garage_floodlight
  - name: Set Focus
    icon: mdi:focus-field
    service: number.set_value
    service_data:
      entity_id: number.garage_focus
      value: '74'
  - name: Record
    icon: mdi:record-circle-outline
    service: script.toggle
    service_data:
      entity_id: script.record_garage
style: |

  .ptz {
    opacity: 1;
  }
  .pictureinpicture {
    display: none;
  }
  .shortcuts {
    position: absolute;
    top: unset;
    bottom: 1%;
    left: 50%;
    transform: translateX(-50%); 
    display: flex;
    flex-direction: row;
    gap: 20px;
    opacity: 1;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 5px;
    padding: 5px; 
    justify-content: center;
    
  }

Scripts:

alias: Reolink Down
sequence:
  - service: button.press
    data: {}
    target:
      entity_id:
        - button.garage_ptz_down
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 500
  - service: button.press
    data: {}
    target:
      entity_id: button.garage_ptz_stop
mode: single
icon: mdi:arrow-down
alias: Reolink Left
sequence:
  - service: button.press
    data: {}
    target:
      entity_id: button.garage_ptz_left
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 500
  - service: button.press
    data: {}
    target:
      entity_id: button.garage_ptz_stop
mode: single
icon: mdi:arrow-left
alias: Reolink Right
sequence:
  - service: button.press
    data: {}
    target:
      entity_id: button.garage_ptz_right
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 500
  - service: button.press
    data: {}
    target:
      entity_id: button.garage_ptz_stop
mode: single
icon: mdi:arrow-right
alias: Reolink Up
sequence:
  - service: button.press
    data: {}
    target:
      entity_id: button.garage_ptz_up
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 500
  - service: button.press
    data: {}
    target:
      entity_id: button.garage_ptz_stop
mode: single
icon: mdi:arrow-up

porly1985 avatar Jun 23 '24 17:06 porly1985

thank you @porly1985

Should I copy this code in a new YAML file with my camera "Kamera Haustür" complete?

groover0815 avatar Jun 24 '24 09:06 groover0815