Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transparently call Frigate PTZ via integration #1163

Closed
kirsch33 opened this issue May 16, 2023 · 11 comments
Closed

Transparently call Frigate PTZ via integration #1163

kirsch33 opened this issue May 16, 2023 · 11 comments
Assignees
Labels
votes needed Vote for this feature to encourage prioritization!

Comments

@kirsch33
Copy link

it appears from the latest dev builds that frigate 0.13 will support PTZ natively via ONVIF. it would be nice to be able to configure this only within Frigate itself and have this functionality inherited by the frigate-hass-card instead of needing to add webrtc card into the mix.

it seems as though PTZ functionality has been available in frigate-hass-card since before the PR for ptz control in the frigate repo.

(please correct me if my understanding is incorrect)

@dermotduffy
Copy link
Owner

You are correct, the Frigate card already supports PTZ via Home Assistant service calls.

Myself and @NickM-27 discussed this briefly before, having had a similar idea. If the Frigate API exposed calls to move the camera around, we could proxy calls from the card through the integration to the backend, and the card could just support this out of the box for Frigate cameras...

@dermotduffy
Copy link
Owner

we could proxy calls from the card

Actually, I think a better idea is to implement service calls in HA that call the backend. This would mean that the standard HA "interface" (service-calls) would support Frigate PTZ, so other non-Frigate card uses could benefit. It would also mean very little would need to change on the card, beyond populating some defaults for Frigate cameras.

@dermotduffy dermotduffy changed the title option to inherit PTZ/onvif configuration from frigate (latest dev build) Transparently call Frigate PTZ via integration May 23, 2023
@dermotduffy
Copy link
Owner

dermotduffy commented Jun 30, 2023

Discussed this briefly with @NickM-27 yesterday, I took a few things away:

  1. This is good to go on the backend side.
  2. We agreed a service call in HA will be used to call the backend.
  3. The card can then either call that service, or use a Websocket equivalent.
  4. Frigate also supports "presets" that the card should expose somehow (it can query Frigate to know which Presets are available, and present them in the Card somehow, likely as part of the PTZ control).

@dermotduffy
Copy link
Owner

Update: Nick is working on 2 in blakeblackshear/frigate-hass-integration#510 .

@dermotduffy dermotduffy added the votes needed Vote for this feature to encourage prioritization! label Jul 29, 2023
@TimelessNL
Copy link

You are correct, the Frigate card already supports PTZ via Home Assistant service calls.

I've tried to call the new Frigate service, but so far unsuccessful 😢
Basically I copied the tap_action section from a working entity-button card

elements:
  - type: custom:frigate-card-ptz
    orientation: vertical
    style:
      transform: none
      right: 5%
      top: 50%
    actions_left:
      tap_action:
        action: call-service
        service: frigate.ptz
        target:
          entity_id: camera.backdoor
        data:
          action: move
          argument: left

Which results in the following error (partly Dutch, but the exact error is in English)
afbeelding

@dermotduffy
Copy link
Owner

I think this might be related to #1103 , which I plan to fix in the next major release as it's a breaking change. HA renamed the data parameter for service calls from service_data to data, but the original name is still used in this card. So try this:

elements:
  - type: custom:frigate-card-ptz
    orientation: vertical
    style:
      transform: none
      right: 5%
      top: 50%
    actions_left:
      tap_action:
        action: call-service
        service: frigate.ptz
        target:
          entity_id: camera.backdoor
        service_data:    // <--------------- This is changed
          action: move
          argument: left

As I understand it with the new Frigate PTZ endpoint you need to both move and stop the camera, or it'll just keep going. You should be able to use the start_tap_action (instead of tap_action) for the move call, and a new stop_tap_action to also call stop when the tap is stopped. So it'll start to move when you press the button, and stop when you let it go.

Note that I have not tested calling the new Frigate PTZ endpoints as I'm describing, but it should work. I plan to make this work more "out of the box" for Frigate (without needing so much YAML) in future (that's what this issue is for) -- but hopefully you have enough clues to get this working with the above for now. Good luck.

@TimelessNL
Copy link

TimelessNL commented Sep 16, 2023

Thanks @dermotduffy for your suggestion 😃
I get one step further as it almost works, but could it be that the target: has also changed as I'm now getting:
afbeelding

EDIT
Mmh... it works when the target section is omitted and the entity_id is placed in the service_data section like so:

tap_action:
    action: call-service
    service: frigate.ptz
    service_data:
        entity_id: camera.backdoor
        action: move
        argument: left

EDIT2
You're right, the service calls are continuous and a stop is required.
The following config works
(please note end_tap_action seems to be the right action):

actions_left:
    start_tap_action:
        action: call-service
        service: frigate.ptz
        service_data:
          entity_id: camera.backdoor
          action: move
          argument: left
    end_tap_action:
        action: call-service
        service: frigate.ptz
        service_data:
           entity_id: camera.backdoor
           action: stop

I plan to make this work more "out of the box" for Frigate

That would be great, that would save me some YAML lines 😆

but hopefully you have enough clues to get this working with the above for now. Good luck.

I do as it works now, great thanks!

@Chaoscontrol
Copy link

Chaoscontrol commented Oct 6, 2023

I came to report exactly this after testing, bit I'm late to the party and happy you have found a solution to stop the movement on release.

It works amazingly well, thank you! It would be amazing if this could be integrated automatically in the card though, as the YAML gets reeaally long at this point. :)

Out of curiosity, where are start_tap_action and end_tap_action documented? I was searching into actions looking for this and didn't find anything about it.

@dermotduffy
Copy link
Owner

Out of curiosity, where are start_tap_action and end_tap_action documented? I was searching into actions looking for this and didn't find anything about it.

They are non-standard HA actions, only supported by this card (for this usecase and other similar ones, e.g. microphone hold to speak buttons). They can be used anywhere in the card that normal actions are used -- I don't think there's a specific example about using them with the PTZ control though.

They are referred to in the docs here: https://github.com/dermotduffy/frigate-hass-card#custom-action-types-start_tap-and-end_tap

@dermotduffy
Copy link
Owner

It works amazingly well, thank you! It would be amazing if this could be integrated automatically in the card though, as the YAML gets reeaally long at this point. :)

With the newly merged PR, which will be in the next release, you need no YAML whatsoever for PTZ support as long as the PTZ is setup in Frigate.

@Sidonai-1
Copy link

It works amazingly well, thank you! It would be amazing if this could be integrated automatically in the card though, as the YAML gets reeaally long at this point. :)

With the newly merged PR, which will be in the next release, you need no YAML whatsoever for PTZ support as long as the PTZ is setup in Frigate.

Hi, I have the latest version (5.2.0) and I managed to make it work writing the config manually into the card, but I cannot figure out how to set it up in this 'auto' mode without the long yaml.

I'm probably missing something obvious... I thought the menu options would appear in the interface under buttons or live controls but I cannot find it.

They're Tapo cameras that I have setup in frigate with ONVIF.

Thanks!

@github-actions github-actions bot locked and limited conversation to collaborators Oct 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
votes needed Vote for this feature to encourage prioritization!
Projects
None yet
Development

No branches or pull requests

5 participants