GaryOkie c7bba3c5b5
Update amcrest doc for new "ptz_control" service (#12383)
* Update amcrest doc for new "ptz_control" service

included full description of ptz_control service and its attributes along with a complete picture-elements card example showing functional arrow movement icons. 

Also mentioned this component can be used for Dahua cameras.

* Update source/_integrations/amcrest.markdown

Co-Authored-By: Franck Nijhof <frenck@frenck.nl>

* Update source/_integrations/amcrest.markdown

Co-Authored-By: Franck Nijhof <frenck@frenck.nl>

* Update source/_integrations/amcrest.markdown

Co-Authored-By: Franck Nijhof <frenck@frenck.nl>

* Update source/_integrations/amcrest.markdown

Co-Authored-By: Franck Nijhof <frenck@frenck.nl>

* Update source/_integrations/amcrest.markdown

Co-Authored-By: Franck Nijhof <frenck@frenck.nl>

* removed "top/bottom" alternate movement commands.

* implement Phil's corrections/suggestions

Also updated the picture-elements card to add a zoom-in/out icon in the center of the arrows.

New example image will also be uploaded once I figure out how to do that in the markdown.

* attempt to create an amcrest folder (for images)

* delete empty amcrest file.

It needed to be a folder.
yet to figure out how to make it so.

* create /amcrest/amcrest_ptz.jpg 

create /amcrest/dummy file in the hopes this creates a new folder

* Upload new amcrest_ptz image

finally figured out how to create a new folder in multiple steps.

* fix ptz_control table formatting

Problem was copying the ptz control markdown from Foscam doc which had 2 columns, not 3.
(all this -|-|- lingo was new to me, and thought copying what worked for one, would work for the other)

Also moved the 2 usage notes to their own subsection

* Delete amcrest_ptz.JPG

deleting because extension is all caps, not lc.    did not see a way to rename a committed file.

* amcrest_ptz.jpg uploaded

* ✏️ Tweak

Co-authored-by: Franck Nijhof <frenck@frenck.nl>
2020-03-21 07:50:12 +01:00

12 KiB

title, description, logo, ha_category, ha_iot_class, ha_release, ha_codeowners, ha_domain
title description logo ha_category ha_iot_class ha_release ha_codeowners ha_domain
Amcrest Instructions on how to integrate Amcrest (or Dahua) IP cameras within Home Assistant. amcrest.png
Hub
Binary Sensor
Camera
Sensor
Local Polling 0.49
@pnbruckner
amcrest

The amcrest camera platform allows you to integrate your Amcrest or Dahua IP camera in Home Assistant.

There is currently support for the following device types within Home Assistant:

  • Binary Sensor
  • Camera
  • Sensor

Configuration

To enable your camera in your installation, add the following to your configuration.yaml file:

# Example configuration.yaml entry
amcrest:
  - host: IP_ADDRESS_CAMERA
    username: YOUR_USERNAME
    password: YOUR_PASSWORD

{% configuration %} host: description: > The IP address or hostname of your camera. If using a hostname, make sure the DNS works as expected. required: true type: string username: description: The username for accessing your camera. required: true type: string password: description: The password for accessing your camera. required: true type: string name: description: > This parameter allows you to override the name of your camera. In the case of multi-camera setups, this is highly recommended as camera id number will be randomly changed at each reboot if a name is not allocated. required: false type: string default: Amcrest Camera port: description: The port that the camera is running on. required: false type: integer default: 80 resolution: description: > This parameter allows you to specify the camera resolution. For a high resolution (1080/720p), specify the option high. For VGA resolution (640x480p), specify the option low. required: false type: string default: high stream_source: description: > The data source for the live stream. mjpeg will use the camera's native MJPEG stream, whereas snapshot will use the camera's snapshot API to create a stream from still images. You can also set the rtsp option to generate the streaming via RTSP protocol. required: false type: string default: snapshot ffmpeg_arguments: description: > Extra options to pass to ffmpeg, e.g., image quality or video filter options. required: false type: string default: -pred 1 authentication: description: > Defines which authentication method to use only when stream_source is mjpeg. Currently, aiohttp only support basic. required: false type: string default: basic scan_interval: description: Defines the update interval of the sensor in seconds. required: false type: integer default: 10 binary_sensors: description: > Conditions to display in the frontend. The following conditions can be monitored: required: false type: list default: None keys: motion_detected: description: "Return on when a motion is detected, off when not." online: description: "Return on when camera is available (i.e., responding to commands), off when not." sensors: description: > Conditions to display in the frontend. The following conditions can be monitored: required: false type: list default: None keys: sdcard: description: Return the SD card usage by reporting the total and used space. ptz_preset: description: > Return the number of PTZ preset positions configured for the given camera. control_light: description: > Automatically control the camera's indicator light, turning it on if the audio or video streams are enabled, and turning it off if both streams are disabled. required: false type: boolean default: true {% endconfiguration %}

Note: Amcrest cameras with newer firmware no longer have the ability to stream high definition video with MJPEG encoding. You may need to use low resolution stream or the snapshot stream source instead. If the quality seems too poor, lower the Frame Rate (FPS) and max out the Bit Rate settings in your camera's configuration manager. If you defined the stream_source to mjpeg, make sure your camera supports Basic HTTP authentication. Newer Amcrest firmware may not work, then rtsp is recommended instead.

Note: If you set the stream_source option to rtsp, make sure to follow the steps mentioned at FFmpeg documentation to install the ffmpeg.

Services

Once loaded, the amcrest integration will expose services that can be called to perform various actions. The entity_id service attribute can specify one or more specific cameras, or all can be used to specify all configured Amcrest cameras.

Available services: enable_audio, disable_audio, enable_motion_recording, disable_motion_recording, enable_recording, disable_recording, goto_preset, set_color_bw, start_tour, stop_tour, and ptz_control

Service enable_audio/disable_audio

These services enable or disable the camera's audio stream.

Service data attribute Optional Description
entity_id no The entity ID of the camera to control. May be a list of multiple entity IDs. To target all cameras, set entity ID to all.

Service enable_motion_recording/disable_motion_recording

These services enable or disable the camera to record a clip to its configured storage location when motion is detected.

Service data attribute Optional Description
entity_id no The entity ID of the camera to control. May be a list of multiple entity IDs. To target all cameras, set entity ID to all.

Service enable_recording/disable_recording

These services enable or disable the camera to continuously record to its configured storage location.

Service data attribute Optional Description
entity_id no The entity ID of the camera to control. May be a list of multiple entity IDs. To target all cameras, set entity ID to all.

Service goto_preset

This service will cause the camera to move to one of the PTZ locations configured within the camera.

Service data attribute Optional Description
entity_id no The entity ID of the camera to control. May be a list of multiple entity IDs. To target all cameras, set entity ID to all.
preset no Preset number, starting from 1.

Service set_color_bw

This service will set the color mode of the camera.

Service data attribute Optional Description
entity_id no The entity ID of the camera to control. May be a list of multiple entity IDs. To target all cameras, set entity ID to all.
color_bw no One of auto, bw or color.

Service start_tour/stop_tour

These services start or stop the camera's PTZ tour function.

Service data attribute Optional Description
entity_id no The entity ID of the camera to control. May be a list of multiple entity IDs. To target all cameras, set entity ID to all.

Service ptz_control

If your Amcrest or Dahua camera supports PTZ, you will be able to pan, tilt or zoom your camera.

Service data attribute Optional Description
entity_id no The entity ID of the camera to control. May be a list of multiple entity IDs. To target all cameras, set entity ID to all.
movement no Direction of the movement. Allowed values: zoom_in, zoom_out, up, down, left, right, right_up, right_down, left_up, left_down
travel_time yes Travel time in fractional seconds. Allowed values: 0 to 1. Default: 0.2.

Notes

  • PTZ zoom capability does not control VariFocal lens adjustments.
  • There can be several seconds of lag before the video (snapshot or live) reflects the camera movement.

Example card with controls

Screenshot using a picture-elements with PTZ controls. Example showing an Amcrest IP2M-841 PT camera with controls for Pan and Tilt.

Using the following picture-elements card code, you can display a live video feed from an Amcrest camera with controls for moving or zooming the camera.

type: picture-elements
entity: camera.lakehouse
camera_image: camera.lakehouse
camera_view: live   # or auto for snapshot view
elements:
  - type: icon
    icon: 'mdi:arrow-up'
    style:
      background: 'rgba(255, 255, 255, 0.25)'
      right: 25px
      bottom: 50px
    tap_action:
      action: call-service
      service: amcrest.ptz_control
      service_data:
        entity_id: camera.lakehouse
        movement: up
  - type: icon
    icon: 'mdi:arrow-down'
    style:
      background: 'rgba(255, 255, 255, 0.25)'
      right: 25px
      bottom: 0px
    tap_action:
      action: call-service
      service: amcrest.ptz_control
      service_data:
        entity_id: camera.lakehouse
        movement: down
  - type: icon
    icon: 'mdi:arrow-left'
    style:
      background: 'rgba(255, 255, 255, 0.25)'
      right: 50px
      bottom: 25px
    tap_action:
      action: call-service
      service: amcrest.ptz_control
      service_data:
        entity_id: camera.lakehouse
        movement: left
  - type: icon
    icon: 'mdi:arrow-right'
    style:
      background: 'rgba(255, 255, 255, 0.25)'
      right: 0px
      bottom: 25px
    tap_action:
      action: call-service
      service: amcrest.ptz_control
      service_data:
        entity_id: camera.lakehouse
        movement: right
  - type: icon
    icon: 'mdi:arrow-top-left'
    style:
      background: 'rgba(255, 255, 255, 0.25)'
      right: 50px
      bottom: 50px
    tap_action:
      action: call-service
      service: amcrest.ptz_control
      service_data:
        entity_id: camera.lakehouse
        movement: left_up
  - type: icon
    icon: 'mdi:arrow-top-right'
    style:
      background: 'rgba(255, 255, 255, 0.25)'
      right: 0px
      bottom: 50px
    tap_action:
      action: call-service
      service: amcrest.ptz_control
      service_data:
        entity_id: camera.lakehouse
        movement: right_up
  - type: icon
    icon: 'mdi:arrow-bottom-left'
    style:
      background: 'rgba(255, 255, 255, 0.25)'
      right: 50px
      bottom: 0px
    tap_action:
      action: call-service
      service: amcrest.ptz_control
      service_data:
        entity_id: camera.lakehouse
        movement: left_down
  - type: icon
    icon: 'mdi:arrow-bottom-right'
    style:
      background: 'rgba(255, 255, 255, 0.25)'
      right: 0px
      bottom: 0px
    tap_action:
      action: call-service
      service: amcrest.ptz_control
      service_data:
        entity_id: camera.lakehouse
        movement: right_down
  - type: icon
    icon: 'mdi:magnify'
    style:
      background: 'rgba(255, 255, 255, 0.25)'
      bottom: 25px
      right: 25px
    tap_action:
      action: call-service
      service: amcrest.ptz_control
      service_data:
        entity_id: camera.lakehouse
        movement: zoom_in
    hold_action:
      action: call-service
      service: amcrest.ptz_control
      service_data:
        entity_id: camera.lakehouse
        movement: zoom_out

Advanced Configuration

You can also use this more advanced configuration example:

# Example configuration.yaml entry
amcrest:
  - host: IP_ADDRESS_CAMERA_1
    username: YOUR_USERNAME
    password: YOUR_PASSWORD
    binary_sensors:
      - motion_detected
      - online
    sensors:
      - sdcard

  # Add second camera
  - host: IP_ADDRESS_CAMERA_2
    username: YOUR_USERNAME
    password: YOUR_PASSWORD
    name: Amcrest Camera 2
    resolution: low
    stream_source: snapshot
    sensors:
      - ptz_preset

To check if your Amcrest camera is supported/tested, visit the supportability matrix link from the python-amcrest project.