ptz
What a preset id DOES on this camera.
What a preset id DOES on this camera.
On several PTZ firmwares the preset namespace is shared: low ids are stored positions, a reserved band triggers camera FUNCTIONS. The dispensa camera (Hikvision) returns its own reserved band in the preset list, named by the firmware:
34 Back to origin · 39 Day mode · 40 Night mode · 46 Day/Night Auto Mode 92 Set manual limits · 93 Save manual limits · 94 Remote reboot 95 Call OSD menu
Saving over one is what produced PUT /ISAPI/PTZCtrl/channels/1/presets/34 -> HTTP 500: the camera refusing to let "Back to origin" be overwritten, surfaced to the operator as a transport failure.
A function preset stays fully usable as a DESTINATION -- goToPreset('34') is the single most useful thing that camera can do. Only savePreset and deletePreset are gated.
At a glance
| Capability | ptz |
| Provided by | The device's own driver provides it: each device registers its own provider. |
| Active providers per device | one |
| Device types | camera |
| Device settings | Yes: its settings section on the device page is built from this capability's methods. |
| Source | packages/types/src/capabilities/ptz.cap.ts |
Methods
Every method takes the device id (deviceId) to address the device; the input tables below list the other fields.
| Method | Kind | Required of a provider | Access |
|---|---|---|---|
move | mutation | yes | default |
continuousMove | mutation | yes | default |
goHome | mutation | yes | default |
getPresets | query | yes | default |
goToPreset | mutation | yes | default |
savePreset | mutation | yes | admin |
deletePreset | mutation | yes | admin |
getOptions | query | yes | default |
stop | mutation | yes | default |
getHomePreset | query | yes | default |
setHomePreset | mutation | yes | admin |
captureHomeHere | mutation | yes | admin |
getHomeReturn | query | yes | default |
setHomeReturn | mutation | yes | admin |
getPosition | query | yes | default |
setAutofocus | mutation | yes | default |
move
mutation
Input
| Field | Type | Required | Description |
|---|---|---|---|
pan | number | no | |
tilt | number | no | |
zoom | number | no | |
speed | number | no |
Output
Nothing.
continuousMove
mutation
Input
| Field | Type | Required | Description |
|---|---|---|---|
pan | number | no | |
tilt | number | no | |
zoom | number | no | |
speed | number | no |
Output
Nothing.
goHome
mutation
Move to the camera's configured home preset. THROWS when getHomePreset() resolves to none -- a head that did not move must never look like a head that went home.
Input
No fields besides deviceId.
Output
Nothing.
Actions (offered in automations and on device cards)
| Action | Label | Sets |
|---|---|---|
ptz.goHome | PTZ go home |
getPresets
query
Input
No fields besides deviceId.
Output
({ id: string; name: string; fn: "home" | "day-mode" | "night-mode" | "day-night-auto" | "set-limits" | "save-limits" | "reboot" | "osd-menu" | null; writable: boolean })[]
goToPreset
mutation
Input
| Field | Type | Required | Description |
|---|---|---|---|
presetId | string | yes |
Output
Nothing.
Actions (offered in automations and on device cards)
| Action | Label | Sets |
|---|---|---|
ptz.goToPreset | PTZ go to preset |
savePreset
mutation
Input
| Field | Type | Required | Description |
|---|---|---|---|
presetId | string | yes | |
name | string | yes |
Output
Nothing.
Actions (offered in automations and on device cards)
| Action | Label | Sets |
|---|---|---|
ptz.savePreset | Save PTZ preset here |
deletePreset
mutation
Input
| Field | Type | Required | Description |
|---|---|---|---|
presetId | string | yes |
Output
Nothing.
getOptions
query
Input
No fields besides deviceId.
Output
Per-camera PTZ availability descriptor — drives the UI.
| Field | Type | Required | Description |
|---|---|---|---|
hasPan | boolean | yes | |
hasTilt | boolean | yes | |
hasZoom | boolean | yes | |
supportsPresets | boolean | yes | |
maxPresets | number | no | Max number of named presets the camera supports, when known. |
hasAutofocus | boolean | yes | Whether the camera exposes a controllable autofocus toggle (boolean hasX per the getOptions availability convention). |
speedSteps | number | null | yes | How many distinct speeds this camera's NATIVE scale offers. The cap's speed is normalized 0..1 and each provider maps it down -- Baichuan 1..63, Dahua 1..8, ISAPI's percentage -100..100. The normalized value hides how coarse that really is: asking an amcrest for 0.37 is meaningless, because it has eight steps and three of them round to the same one. A loop that tunes its own gain has to know the granularity of the knob it is turning. null = the driver does not know, or the scale is continuous (ONVIF takes a float). Never a made-up number. |
moveImpulseMs | number | null | yes | How long ONE move pulse runs on this driver, ms. move is a self-terminating burst everywhere, but every provider hardcoded its own duration in private -- 200 reolink, 350 amcrest, 500 hikvision, 1000 onvif -- so no caller could read it. It is the DENOMINATOR of "how far did the head travel per pulse": without it a measured displacement has no gain to be divided into. null = the driver cannot say. |
stop
mutation
Input
No fields besides deviceId.
Output
Nothing.
Actions (offered in automations and on device cards)
| Action | Label | Sets |
|---|---|---|
ptz.stop | Stop moving |
getHomePreset
query
Which preset goHome targets, and who decided it.
Input
No fields besides deviceId.
Output
Which preset goHome goes to, and WHO decided.
107 Camera camera Carol (reolink) preset 0 holds "stanza" 1438 Camera dispensa (hikvision) preset 1 holds "Credenza" 3836 Camera studio (amcrest) preset 1 holds "Preset1"
So goHome meant "go wherever the operator happened to save in slot 0 or 1", and two of the three swallowed the failure in a bare catch. For autotrack this is the HOTTEST path -- it runs every time a subject is released -- so it needs an answer that is true per camera and audible when it is missing.
source is what makes it honest:
operator-- picked in the UI, stored by the provider.firmware-- the camera itself named a presetfn: 'home'(Hikvision's "Back to origin"), adopted as the default with nothing to configure.native-- the driver homes WITHOUT a preset at all. ONVIF does:goHomeisptzAbsoluteMove({x:0, y:0, zoom:0}).presetIdis null and that is not a failure -- there is nothing to pick, and the UI must offer no picker.none-- nothing is configured and the camera names nothing.goHomeREFUSES rather than moving the head somewhere arbitrary.
source === 'none' is the refusal condition, NOT presetId === null: the native case has no preset and homes perfectly well.
| Field | Type | Required | Description |
|---|---|---|---|
presetId | string | null | yes | |
source | "operator" | "firmware" | "native" | "none" | yes |
setHomePreset
mutation
Pin the home preset for this camera. null clears the operator's choice and falls back to whatever the firmware names, or to none.
Input
| Field | Type | Required | Description |
|---|---|---|---|
presetId | string | null | yes |
Output
Nothing.
Actions (offered in automations and on device cards)
| Action | Label | Sets |
|---|---|---|
ptz.setHomePreset | Set PTZ home preset |
captureHomeHere
mutation
Make WHERE THE HEAD IS POINTING RIGHT NOW this camera's home.
setHomePreset takes a preset id, and a preset id is the wrong shape for the most natural thing an operator does: aim the camera, then say "here". It is also the only shape a camera whose home is NOT a preset can accept -- Reolink's home is a guard point, a stored position with no id at all, and hiding the control for that case (as the UI briefly did) left the one vendor with a native home unable to set it.
Each provider does it its own way: reolink setGrd with needSetPos, pinning the guard point here hikvision / amcrest save a preset, then pin it as home onvif REFUSES -- its home is the PTZ origin and cannot be moved
A provider that cannot honour it throws rather than silently doing nothing: an operator who pressed "set home here" and saw no error would believe it took.
Input
No fields besides deviceId.
Output
Nothing.
Actions (offered in automations and on device cards)
| Action | Label | Sets |
|---|---|---|
ptz.captureHomeHere | Set PTZ home here |
getHomeReturn
query
Whether the camera returns home on its own when left idle, and after how long. null when it has no such behaviour at all.
Reolink's guard point carries one (timeout, freely settable in seconds). It is a real function of the camera that we did not expose at all, and it belongs next to the home it governs rather than in a vendor settings page nobody associates with Home.
Input
No fields besides deviceId.
Output
| Field | Type | Required | Description |
|---|---|---|---|
enabled | boolean | yes | |
seconds | number | yes |
setHomeReturn
mutation
Set both together. Refused by a camera with no idle-return behaviour.
They travel together for the same reason they are read together: the underlying write carries both, so setting one alone means reading the other back first and racing whoever else is writing.
Input
| Field | Type | Required | Description |
|---|---|---|---|
enabled | boolean | yes | |
seconds | number | yes |
Output
Nothing.
Actions (offered in automations and on device cards)
| Action | Label | Sets |
|---|---|---|
ptz.setHomeReturn | Set PTZ return home |
getPosition
query
Pull the current PTZ position. Redundant with the auto-injected getStatus method (see status below); kept for callers that haven't migrated. Will be folded into getStatus in a future cleanup pass once all consumers use the typed status surface.
Input
No fields besides deviceId.
Output
Where the head is pointing -- per axis, and null when the driver cannot read it.
All four said 0:
reolink return { pan: 0, tilt: 0, zoom: 0 } "until a position-query path lands upstream" hikvision stub, "firmware-dependent and frequently absent" amcrest stub, "no generic absolute-position read for this model family" onvif throws
So every consumer asking where a camera points was told "perfectly centred" by four cameras that had never looked.
There is one: PtzStatusSchema extends this, so the lie had already propagated into getStatus, which is the surface getPosition's own comment tells callers to migrate to.
| Field | Type | Required | Description |
|---|---|---|---|
pan | number | null | yes | |
tilt | number | null | yes | |
zoom | number | null | yes |
setAutofocus
mutation
Toggle the camera's autofocus. Only meaningful when getOptions().hasAutofocus is true.
Input
| Field | Type | Required | Description |
|---|---|---|---|
enabled | boolean | yes |
Output
Nothing.
Actions (offered in automations and on device cards)
| Action | Label | Sets |
|---|---|---|
ptz.autofocusOn | Autofocus on | |
ptz.autofocusOff | Autofocus off |
Status
| Field | Type | Required | Description |
|---|---|---|---|
pan | number | null | yes | |
tilt | number | null | yes | |
zoom | number | null | yes | |
autofocus | boolean | yes |