PTZ control - cbrightly/hass-aidot-cameras GitHub Wiki

PTZ control (pan / tilt / zoom)

PTZ cameras expose two ways to move the camera. The buttons follow the direction codes the camera advertises; the reference model (A001064) advertises pan only, so it gets left / right / stop.

PTZ commands ride the active stream session, so the camera must be streaming - open the live view first. Use stop to halt continuous motion.

1. Button entities

Only the buttons the camera actually supports are created (and they are disabled by default - enable them from the device page):

  • A pan-only camera - the A001064 - gets _left / _right / _stop.
  • _up / _down appear only on a camera that advertises tilt.
  • Zoom buttons appear only if the camera advertises zoom capability.

Good for automations and quick taps.

2. The aidot.ptz service

One call for any direction; handy in scripts and as a dashboard card's tap target. The service accepts tilt and zoom too, for a camera that advertises them; on the A001064 only left, right and stop move it.

service: aidot.ptz
target:
  entity_id: camera.outdoor_ptz
data:
  direction: left      # up/down/left/right/left_up/left_down/right_up/right_down/zoom_in/zoom_out/stop
  speed: 4             # 1 (slow) - 8 (fast)

See the Services reference for the full field list.

Overlay the controls on the live view (no custom cards)

Home Assistant has no built-in PTZ overlay (neither does ONVIF/Reolink - it's a core limitation), but you can put the arrows on top of the live feed with the built-in Picture Elements card - no HACS required. Tapping an arrow moves the camera instead of opening a dialog.

camera_view: live is important: it keeps the WebRTC session open so PTZ commands have an active channel. While the stream is connecting the card shows the camera's latest event thumbnail as a poster (no blank tile).

The example uses the three buttons the A001064 has. Add _up / _down and _zoom_in / _zoom_out elements in the same shape only if your camera advertises tilt or zoom and so has those buttons.

type: picture-elements
camera_image: camera.outdoor_ptz
camera_view: live
elements:
  - type: icon
    icon: mdi:arrow-left-bold
    style: {top: 50%, left: 8%, transform: translate(-50%,-50%), color: white}
    tap_action: {action: perform-action, perform_action: button.press,
                 target: {entity_id: button.outdoor_ptz_ptz_left}}
  - type: icon
    icon: mdi:arrow-right-bold
    style: {top: 50%, left: 92%, transform: translate(-50%,-50%), color: white}
    tap_action: {action: perform-action, perform_action: button.press,
                 target: {entity_id: button.outdoor_ptz_ptz_right}}
  - type: icon
    icon: mdi:stop-circle-outline
    style: {bottom: 8%, left: 50%, transform: translate(-50%,50%), color: white}
    tap_action: {action: perform-action, perform_action: button.press,
                 target: {entity_id: button.outdoor_ptz_ptz_stop}}

For a polished joystick/D-pad in the fullscreen view, the HACS Advanced Camera Card can bind its PTZ controls to these same buttons - optional, for the best experience.

See Automation examples for a scheduled PTZ patrol.