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

PTZ Controls do not work. #1715

Closed
Tintef opened this issue Dec 8, 2024 · 18 comments
Closed

PTZ Controls do not work. #1715

Tintef opened this issue Dec 8, 2024 · 18 comments
Labels
question Further information is requested

Comments

@Tintef
Copy link

Tintef commented Dec 8, 2024

Versions:

  • Frigate Card: v6.6.0-beta9
  • Frigate: v5.5.1

[REQUIRED] Card diagnostic information:

card_version: 6.0.0-beta.9
browser: >-
  Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML,
  like Gecko) Chrome/131.0.0.0 Safari/537.36
date: 2024-12-08T22:21:30.962Z
lang: en_GB
timezone: America/Montevideo
git:
  hash: b2b7a08
  build_date: Wed, 04 Dec 2024 04:35:32 GMT
  commit_date: Tue, 3 Dec 2024 20:26:56 -0800
ha_version: 2024.12.1
integrations:
  reolink:
    detected: true
  frigate:
    detected: true
    version: 5.5.1
    devices:
      01J2TA0J3ZGH65WNX9RGJE0STJ: 5.5.1/0.14.0-da913d8
  hass_web_proxy:
    detected: false
  motioneye:
    detected: true
config:
  type: custom:frigate-card
  cameras:
    - camera_entity: camera.front
      live_provider: go2rtc
    - camera_entity: camera.gate
      live_provider: go2rtc
    - camera_entity: camera.garden
      live_provider: go2rtc
    - camera_entity: camera.dogcam
      live_provider: go2rtc
    - camera_entity: camera.ptz
      live_provider: go2rtc
  view:
    default: live
    camera_select: live
    dark_mode: 'on'

[REQUIRED] Description of problem:

I can't seem to get my PTZ controls to work on the card.

  • Controls work fine on frigate, and I can see and use all my presets as well
  • Controls show on the card, but they don't work (none of them)
  • Also, on the card, I only see a home button, not all my presents, not sure how this should work tho

Note: I don't have the Reolink integration installed or a Replink device yet (I'll add a doorbell in a few weeks) so I'm not sure why it's reporting as detected.

[OPTIONAL] Last working release (if known):

I just installed this camera so I don't know if it's release related. I tried on beta-8 and beta-9, none worked.

[OPTIONAL] Javascript errors shown in the web inspector:

None.

[OPTIONAL] Additional information:

I tried debugging this a bit with the chrome devtools, and I noticed that at least the events that I want to do some action is getting to an executePTZAction function:

    async executePTZAction(e, t, n) {
        const a = this._store.getCameraConfig(e);
        if (!a)
            return;
        const i = q_(a, t, n);
        if (i)
            return await this._api.getActionsManager().executeActions(i);
        const r = this._api.getHASSManager().getHASS()
          , o = this._store.getEngineForCameraID(e);
        return o && r ? await this._requestLimit.add(( () => o.executePTZAction(r, a, t, n))) : void 0
    }

Where:

e = "camera.ptz"
n = { phase: "start", preset: undefined }
t = "right"
@Tintef Tintef added the bug Something isn't working label Dec 8, 2024
@dermotduffy
Copy link
Owner

dermotduffy commented Dec 8, 2024

Note: I don't have the Reolink integration installed or a Replink device yet (I'll add a doorbell in a few weeks) so I'm not sure why it's reporting as detected.
Also, on the card, I only see a home button, not all my presents, not sure how this should work tho

FYI: Both of these are working as intended (reolink is part of HA core, and the card only supports using the 1st preset so far).

Can you visit https://<PATH_TO_YOUR_FRIGATE_INSTANCE>/api/<FRIGATE_CAMERA_NAME>/ptz/info

... and tell me what you get back? It'll be a JSON blob.

@Tintef
Copy link
Author

Tintef commented Dec 8, 2024

FYI: Both of these are working as intended (reolink is part of HA core, and the card only supports using the 1st preset so far).

Perfect, thanks for the clarification.

Can you visit https://<PATH_TO_YOUR_FRIGATE_INSTANCE>/api/<CAMERA_NAME>/ptz/info and tell me what you get back? It'll be a JSON blob.

{
  "features": [
    "pt",
    "zoom",
    "pt-r",
    "zoom-r",
    "zoom-a"
  ],
  "name": "PTZ",
  "presets": [
    "door",
    "middle",
    "back",
    "door_zoomed"
  ]
}

@dermotduffy
Copy link
Owner

I assume whichever camera has the PTZ controls (probably camera.ptz), is an entity from the Frigate integration and not some other camera?

Looking at the config, and that JSON, it's not clear why it's not working.

@Tintef
Copy link
Author

Tintef commented Dec 8, 2024

Yes, I only have one camera with PTZ controls, named ptz so the ha entity is camera.ptz (naming is hard 😅).

Yeah, it should work, but I can't find anything that's wrong.

Maybe I could install the card manually instead of via HACS to add some console logs? Is there a guide to so? More than happy to take a look at what's going on and report back with my findings

@dermotduffy
Copy link
Owner

If you're comfortable playing around in devtools, that might help us figure this out. This is the ultimate call to the Frigate integration to do the PTZ move:

https://github.com/dermotduffy/frigate-hass-card/blob/main/src/camera-manager/frigate/engine-frigate.ts#L1043

I'd love to know if the call gets in there. This is the code you linked to, it should call the above. Right now I can't tell if the card is not making the call and nothing is happening, or the card is messing up.

The other idea would be to manually call the services from /developer-tools/action on your HA instance, try a call like this and see if your camera moves:

action: frigate.ptz
target:
  entity_id: camera.ptz
data:
  action: move
  argument: left <-------------- Change this to right/left to move all the way right or left

If it doesn't move calling the service manually, there's no way the card could work. If it does work when you call it manually, but doesn't via the card, something is wrong with the card...

@dermotduffy
Copy link
Owner

Maybe I could install the card manually instead of via HACS to add some console logs? Is there a guide to so? More than happy to take a look at what's going on and report back with my findings

If you're a developer, you could download the repo, build the card yourself, and install that version. This would give you the full sourcemaps and lets you navigate the card easier. There's a video at the bottom of this that isn't exactly what you want, but would let you substitute in your "home built" version of the card:

https://card.camera/#/advanced-installation?id=unreleased-versions

@Tintef
Copy link
Author

Tintef commented Dec 9, 2024

If you're comfortable playing around in devtools, that might help us figure this out. This is the ultimate call to the Frigate integration to do the PTZ move:

There's no API call on the network tab of the devtools when I click the PTZ buttons.

The other idea would be to manually call the services from /developer-tools/action on your HA instance, try a call like this and see if your camera moves:

Doesn't move my camera neither an API call on the devtools network tab (see attached video).

ptz-not-working.mov

If you're a developer, you could download the repo, build the card yourself, and install that version. This would give you the full sourcemaps and lets you navigate the card easier.

Sounds good, I'll give that a try later this week and report back my findings!

@dermotduffy
Copy link
Owner

Doesn't move my camera neither an API call on the devtools network tab (see attached video).

Great screencap. Note that we wouldn't expect any new network traffic when you perform that action -- the browser would just be reusing a pre-existing websocket, the real call would be between your HA instance and your Frigate backend.

In any case, since just manually doing the action (as per your video) doesn't work, the issue is not likely related to the card -- as the card is just calling that same action (FKA: service call). We need to figure out why HA is not doing anything when it receives that action. Once that works, the card should also work.

Is there anything interesting in your Home Assistant or Frigate logs when you issue that action call?

@Tintef
Copy link
Author

Tintef commented Dec 9, 2024

Is there anything interesting in your Home Assistant or Frigate logs when you issue that action call?

No logs on either of them that seem to be triggered by pressing the buttons or doing the action call on HA devtools.

I do see these errors on frigate logs, which are for camera that don't have onvif setup because they aren't PTZ cameras.

Screenshot 2024-12-09 at 08 35 29

I found an issue on frigate talking about it, saying it's something on this card I think

@dermotduffy
Copy link
Owner

I found an blakeblackshear/frigate#14056, saying it's something on this card I think

That's Frigate being overly loggy when the card simply asks what PTZ capabilities the camera has. They already fixed that in latest releases. This is not related to your problem.

@dermotduffy
Copy link
Owner

No logs on either of them that seem to be triggered by pressing the buttons or doing the action call on HA devtools.

Your Frigate log should show something like this, when you call the action (manually or button):

2024-12-09 17:40:37.405435316 [2024-12-09 17:40:37] frigate.comms.dispatcher INFO : Setting ptz command to move_left for office

@dermotduffy
Copy link
Owner

[Changing this from bug for now, as it seems very unlikely this is a problem with the card, since simply calling the actions manually also does not work]

@dermotduffy dermotduffy added question Further information is requested and removed bug Something isn't working labels Dec 10, 2024
@ovesely1
Copy link

ovesely1 commented Dec 13, 2024

same issue here. Update everything to the latest version
HACS frigate HA integration v5.6.0
frigate lovelace card v6.0.6
HA CORE 2024.12.3

I have tried that in two browsers, chrome and firefox. It works the same. I can control my cam over PTZ buttons in Frigate and i can see the PTZ buttons on the screen in the frigate card, but they are not working at all.

I also tried to perform manual action using devtools, with the same result as in the previous comments. Nothing in any log which I can find (HA, Frigate) Can I help you somehow to investigate what is wrong?

log:
card_version: 6.0.6
browser: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0
date: 2024-12-13T23:01:08.089Z
lang: en
timezone: Europe/Prague
git:
hash: ed0bb99
build_date: Fri, 13 Dec 2024 16:12:40 GMT
commit_date: Fri, 13 Dec 2024 08:11:26 -0800
ha_version: 2024.12.3
integrations:
reolink:
detected: true
frigate:
detected: true
version: 5.6.0
devices:
01JBJJD55MAPK0SKKR8K09ZGSB: 5.6.0/0.14.1-f4f3cfa
hass_web_proxy:
detected: false
motioneye:
detected: true
config:
type: custom:frigate-card
cameras:
- camera_entity: camera.testovaci
live_provider: go2rtc
go2rtc:
modes:
- webrtc
stream: Testovaci_main
dimensions:
aspect_ratio_mode: dynamic
performance:
features:
media_chunk_size: 602
live:
lazy_load: false
draggable: false
preload: true
controls: {}
view: {}
status_bar:
position: top

@dermotduffy
Copy link
Owner

dermotduffy commented Dec 14, 2024

Long-shot: Have you both correctly got MQTT setup in your HA instance? Do switch entities for Frigate work correctly? I ask since MQTT is used to send the PTZ commands from HA to Frigate.

If that's not the issue, I'm at a bit of a loss. A good debugging step might be to watch the MQTT traffic between HA and Frigate. On Linux, here's an annotated example of my doing that. Other OSes have similar tools:

(~) $ mosquitto_sub -t frigate/office/ptz/#
move_down <------------ When I send an down command
stop
move_up <------------ When I send an up command
stop
move_left <------------ When I send a left command
stop

@NickM-27 might have some other ideas (Nick -- issue best summarized in video above -- PTZ service calls not doing anything).

@ovesely1
Copy link

I have found what is the root cause of this issue:
I tried to reconfigure frigate and reboot. I can move the cam up, down, right, left only until I click to zoom in button. After that nothing works until frigate is rebooted again.

Se attached frigate log bellow. At 3:27 I clicked on zoom in button on the frigate card:

2024-12-14 03:25:53.012963415 [2024-12-14 03:25:53] frigate.comms.dispatcher INFO : Setting ptz command to move_left for Testovaci
2024-12-14 03:25:53.162776987 [2024-12-14 03:25:53] frigate.comms.dispatcher INFO : Setting ptz command to stop for Testovaci
2024-12-14 03:25:54.368155934 [2024-12-14 03:25:54] frigate.comms.dispatcher INFO : Setting ptz command to move_right for Testovaci
2024-12-14 03:25:54.414855528 [2024-12-14 03:25:54] frigate.comms.dispatcher INFO : Setting ptz command to stop for Testovaci
2024-12-14 03:25:54.440128704 [2024-12-14 03:25:54] frigate.comms.dispatcher INFO : Setting ptz command to move_right for Testovaci
2024-12-14 03:25:54.484369761 [2024-12-14 03:25:54] frigate.comms.dispatcher INFO : Setting ptz command to stop for Testovaci
2024-12-14 03:25:54.634538091 [2024-12-14 03:25:54] frigate.comms.dispatcher INFO : Setting ptz command to move_right for Testovaci
2024-12-14 03:25:54.691189718 [2024-12-14 03:25:54] frigate.comms.dispatcher INFO : Setting ptz command to stop for Testovaci
2024-12-14 03:25:54.824198177 [2024-12-14 03:25:54] frigate.comms.dispatcher INFO : Setting ptz command to move_right for Testovaci
2024-12-14 03:25:54.925426341 [2024-12-14 03:25:54] frigate.comms.dispatcher INFO : Setting ptz command to stop for Testovaci
2024-12-14 03:25:55.035368675 [2024-12-14 03:25:55] frigate.comms.dispatcher INFO : Setting ptz command to move_right for Testovaci
2024-12-14 03:25:55.092953475 [2024-12-14 03:25:55] frigate.comms.dispatcher INFO : Setting ptz command to stop for Testovaci
2024-12-14 03:25:57.263526117 [2024-12-14 03:25:57] frigate.comms.dispatcher INFO : Setting ptz command to move_right for Testovaci
2024-12-14 03:25:57.357443439 [2024-12-14 03:25:57] frigate.comms.dispatcher INFO : Setting ptz command to stop for Testovaci
2024-12-14 03:25:57.721996384 [2024-12-14 03:25:57] frigate.comms.dispatcher INFO : Setting ptz command to move_right for Testovaci
2024-12-14 03:25:57.864260559 [2024-12-14 03:25:57] frigate.comms.dispatcher INFO : Setting ptz command to stop for Testovaci
2024-12-14 03:25:58.018686594 [2024-12-14 03:25:58] frigate.comms.dispatcher INFO : Setting ptz command to move_right for Testovaci
2024-12-14 03:25:58.119477166 [2024-12-14 03:25:58] frigate.comms.dispatcher INFO : Setting ptz command to stop for Testovaci
2024-12-14 03:25:58.532873613 [2024-12-14 03:25:58] frigate.comms.dispatcher INFO : Setting ptz command to move_right for Testovaci
2024-12-14 03:25:58.703273589 [2024-12-14 03:25:58] frigate.comms.dispatcher INFO : Setting ptz command to stop for Testovaci
2024-12-14 03:25:58.885464814 [2024-12-14 03:25:58] frigate.comms.dispatcher INFO : Setting ptz command to move_right for Testovaci
2024-12-14 03:25:58.990135695 [2024-12-14 03:25:58] frigate.comms.dispatcher INFO : Setting ptz command to stop for Testovaci
2024-12-14 03:26:29.823492289 [2024-12-14 03:26:29] frigate.comms.dispatcher INFO : Setting ptz command to move_down for Testovaci
2024-12-14 03:26:29.893274303 [2024-12-14 03:26:29] frigate.comms.dispatcher INFO : Setting ptz command to stop for Testovaci
2024-12-14 03:26:31.099371435 [2024-12-14 03:26:31] frigate.comms.dispatcher INFO : Setting ptz command to move_down for Testovaci
2024-12-14 03:26:31.204018969 [2024-12-14 03:26:31] frigate.comms.dispatcher INFO : Setting ptz command to stop for Testovaci
2024-12-14 03:27:10.968734230 Exception in thread mqtt:
2024-12-14 03:27:10.968738338 Traceback (most recent call last):
2024-12-14 03:27:10.970500604 File "/usr/local/lib/python3.9/dist-packages/onvif/client.py", line 23, in wrapped
2024-12-14 03:27:10.970505719 return func(*args, **kwargs)
2024-12-14 03:27:10.970508885 File "/usr/local/lib/python3.9/dist-packages/onvif/client.py", line 153, in wrapped
2024-12-14 03:27:10.970510827 return call(params, callback)
2024-12-14 03:27:10.970539487 File "/usr/local/lib/python3.9/dist-packages/onvif/client.py", line 140, in call
2024-12-14 03:27:10.970541611 ret = func(**params)
2024-12-14 03:27:10.970543351 File "/usr/local/lib/python3.9/dist-packages/zeep/proxy.py", line 46, in call
2024-12-14 03:27:10.970544921 return self._proxy._binding.send(
2024-12-14 03:27:10.970546728 File "/usr/local/lib/python3.9/dist-packages/zeep/wsdl/bindings/soap.py", line 135, in send
2024-12-14 03:27:10.970578682 return self.process_reply(client, operation_obj, response)
2024-12-14 03:27:10.970580771 File "/usr/local/lib/python3.9/dist-packages/zeep/wsdl/bindings/soap.py", line 229, in process_reply
2024-12-14 03:27:10.970859314 return self.process_error(doc, operation)
2024-12-14 03:27:10.970861972 File "/usr/local/lib/python3.9/dist-packages/zeep/wsdl/bindings/soap.py", line 391, in process_error
2024-12-14 03:27:10.970863443 raise Fault(
2024-12-14 03:27:10.970864887 zeep.exceptions.Fault
2024-12-14 03:27:21.472652 2024-12-14 03:27:10.970866177
2024-12-14 03:27:10.970867801 During handling of the above exception, another exception occurred:
2024-12-14 03:27:21.472706 2024-12-14 03:27:10.970869098
2024-12-14 03:27:10.970870561 Traceback (most recent call last):
2024-12-14 03:27:10.970872157 File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
2024-12-14 03:27:10.970873535 self.run()
2024-12-14 03:27:10.970875094 File "/usr/lib/python3.9/threading.py", line 892, in run
2024-12-14 03:27:10.970876598 self._target(*self._args, **self._kwargs)
2024-12-14 03:27:10.970878294 File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 4523, in _thread_main
2024-12-14 03:27:10.970879775 self.loop_forever(retry_first_connection=True)
2024-12-14 03:27:10.970881468 File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 2297, in loop_forever
2024-12-14 03:27:10.971070231 rc = self._loop(timeout)
2024-12-14 03:27:10.971072672 File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 1686, in _loop
2024-12-14 03:27:10.971496522 rc = self.loop_read()
2024-12-14 03:27:10.971499916 File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 2100, in loop_read
2024-12-14 03:27:10.971688939 rc = self._packet_read()
2024-12-14 03:27:10.971717282 File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 3142, in _packet_read
2024-12-14 03:27:10.972235707 rc = self._packet_handle()
2024-12-14 03:27:10.972238709 File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 3808, in _packet_handle
2024-12-14 03:27:10.972860337 return self._handle_publish()
2024-12-14 03:27:10.972863613 File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 4145, in _handle_publish
2024-12-14 03:27:10.973462995 self._handle_on_message(message)
2024-12-14 03:27:10.973466494 File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 4487, in _handle_on_message
2024-12-14 03:27:10.974766679 callback(self, self._userdata, message)
2024-12-14 03:27:10.974772584 File "/opt/frigate/frigate/comms/mqtt.py", line 113, in on_mqtt_command
2024-12-14 03:27:10.974774177 self._dispatcher(
2024-12-14 03:27:10.974775920 File "/opt/frigate/frigate/comms/dispatcher.py", line 98, in _receive
2024-12-14 03:27:10.974777463 self._on_ptz_command(camera_name, payload)
2024-12-14 03:27:10.974779282 File "/opt/frigate/frigate/comms/dispatcher.py", line 352, in _on_ptz_command
2024-12-14 03:27:10.974780924 self.onvif.handle_command(camera_name, command, param)
2024-12-14 03:27:10.974782610 File "/opt/frigate/frigate/ptz/onvif.py", line 555, in handle_command
2024-12-14 03:27:10.974963293 self._zoom(camera_name, command)
2024-12-14 03:27:10.974992006 File "/opt/frigate/frigate/ptz/onvif.py", line 485, in _zoom
2024-12-14 03:27:10.975190590 onvif.get_service("ptz").ContinuousMove(move_request)
2024-12-14 03:27:10.975232812 File "/usr/local/lib/python3.9/dist-packages/onvif/client.py", line 26, in wrapped
2024-12-14 03:27:10.975346825 raise ONVIFError(err)
2024-12-14 03:27:10.975431467 onvif.exceptions.ONVIFError: Unknown error:

@alray31
Copy link
Contributor

alray31 commented Dec 14, 2024

Same here, after clicking zoom in or zoom out on the card, the card ptz stops working until frigate is restarted.
Clicking on the "PTZ home" button cause the same issue.

@dermotduffy
Copy link
Owner

This makes it very likely to be a Frigate backend problem. I suggest you file an issue in that repo with the above description: https://github.com/blakeblackshear/frigate .

@dermotduffy
Copy link
Owner

[Closing this here, as it seems pretty conclusively to not be a card issue]

@dermotduffy dermotduffy closed this as not planned Won't fix, can't repro, duplicate, stale Dec 14, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jan 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants