Amcrest
The amcrest
camera platform allows you to integrate your Amcrest
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
configuration.yaml 文件是 Home Assistant 的主要配置文件。它列出了要加载的集成及其特定配置。在某些情况下,需要直接在 configuration.yaml 文件中手动编辑配置。大多数集成可以在 UI 中配置。 [Learn more] file.
在更改了configuration.yaml
configuration.yaml 文件是 Home Assistant 的主要配置文件。它列出了要加载的集成及其特定配置。在某些情况下,需要直接在 configuration.yaml 文件中手动编辑配置。大多数集成可以在 UI 中配置。 [Learn more] 文件后,重启 Home Assistant 以应用更改。 该集成现在显示在集成页面的 设置 > 设备与服务 下。其实体在集成卡片上以及实体标签上列出。
# Example configuration.yaml entry
amcrest:
- host: IP_ADDRESS_CAMERA
username: YOUR_USERNAME
password: YOUR_PASSWORD
Configuration Variables
The IP address or hostname of your camera. If using a hostname, make sure the DNS works as expected.
The username for accessing your camera. Most Amcrest devices use “admin” for the username, even if you’ve configured another username in their app.
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.
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
.
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.
Extra options to pass to FFmpeg, e.g., image quality or video filter options.
Defines which authentication method to use only when stream_source
is mjpeg
. Currently, aiohttp
only support basic
.
Conditions to display in the frontend. The following conditions can be monitored:
Return on
when audio is detected, off
when not. In order to use this feature you must enable it in your cameras interface under Settings > Events > Audio Detection. Uses streaming method (see below).
Return on
when audio is detected, off
when not. In order to use this feature you must enable it in your cameras interface under Settings > Events > Audio Detection. Uses polled method (see below).
Return on
when a motion is detected, off
when not. Motion detection is enabled by default for most cameras, if this functionality is not working check that it is enabled in Settings > Events > Video Detection. Uses streaming method (see below).
Return on
when a motion is detected, off
when not. Motion detection is enabled by default for most cameras, if this functionality is not working check that it is enabled in Settings > Events > Video Detection. Uses polled method (see below).
Return on
when a tripwire tripping is detected, off
when not. Uses streaming method (see below).
Return on
when a tripwire is tripping is detected, off
when not. Uses polled method (see below).
Conditions to display in the frontend. The following conditions can be monitored:
Switches to control certain aspects of the cameras.
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
.
Streaming vs polled binary sensors
Some binary sensors provide two choices for method of operation: streaming or polled. Streaming is more responsive and causes less network traffic because the camera will tell Home Assistant when the sensor’s state has changed. Polled mode queries the camera periodically (every five seconds) to check the state of the sensor. Therefore streaming is the better option. However, some camera models and versions of camera firmware do not seem to implement the streaming method properly. Therefore the polled mode is also available. It is recommended to use the streaming mode (e.g., motion_detected
) first, and if that doesn’t work (e.g., results in constant errors), then try the polled mode instead (e.g., motion_detected_polled
.)
Events
Once loaded, the Amcrest integration will generate (Home Assistant) events每当 Home Assistant 中发生某些事情时,都会触发一个事件。有不同类型的事件,例如状态更改事件、动作触发事件或时间更改事件。所有实体都会产生状态更改事件。每当状态更改时,都会产生状态更改事件。事件可用于触发自动化或脚本。例如,您可以在灯打开时触发自动化,然后在该房间中打开扬声器。事件还可用于触发前端的动作。例如,您可以在按下按钮时触发动作。 [Learn more] when it receives event notifications in the stream sent by the camera. This is only possible if the camera model and firmware implement the streaming method (see above). The event type is amcrest
and the data is as follows:
{
"camera": "<name of the camera that triggered the event>",
"event": "<amcrest-specific code of the event>",
"payload": {
<json-encoded content sent by the device
through the streaming protocol>
}
}
The event code is sent by Amcrest or Dahua devices in the payload as a “Code” member. To ease event matching in automations, this code is replicated in a more top-level event
member in data
.
Actions
Once loaded, the amcrest
integration will expose actions动作在 Home Assistant 的多个地方使用。作为脚本或自动化的一部分,动作定义了触发器被激活后将发生的事情。在脚本中,动作被称为序列。 [Learn more] that can be called to perform various actions. The entity_id
action attribute can specify one or more specific cameras, or all
can be used to specify all configured Amcrest cameras.
Available actions动作在 Home Assistant 的多个地方使用。作为脚本或自动化的一部分,动作定义了触发器被激活后将发生的事情。在脚本中,动作被称为序列。 [Learn more]:
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
Action enable_audio/disable_audio
These actions动作在 Home Assistant 的多个地方使用。作为脚本或自动化的一部分,动作定义了触发器被激活后将发生的事情。在脚本中,动作被称为序列。 [Learn more] enable or disable the camera’s audio stream.
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 . |
Action enable_motion_recording/disable_motion_recording
These actions动作在 Home Assistant 的多个地方使用。作为脚本或自动化的一部分,动作定义了触发器被激活后将发生的事情。在脚本中,动作被称为序列。 [Learn more] enable or disable the camera to record a clip to its configured storage location when motion is detected.
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 . |
Action enable_recording/disable_recording
These actions enable or disable the camera to continuously record to its configured storage location.
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 . |
Action goto_preset
This action will cause the camera to move to one of the PTZ locations configured within the camera.
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. |
Action set_color_bw
This action will set the color mode of the camera.
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 . |
Action start_tour/stop_tour
These actions start or stop the camera’s PTZ tour function.
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 . |
Action ptz_control
If your Amcrest or Dahua camera supports PTZ, you will be able to pan, tilt or zoom your camera.
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
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: perform-action
perform_action: 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: perform-action
perform_action: 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: perform-action
perform_action: 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: perform-action
perform_action: 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: perform-action
perform_action: 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: perform-action
perform_action: 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: perform-action
perform_action: 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: perform-action
perform_action: 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: perform-action
perform_action: amcrest.ptz_control
service_data:
entity_id: camera.lakehouse
movement: zoom_in
hold_action:
action: perform-action
perform_action: amcrest.ptz_control
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
- crossline_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
Example automation to detect button presses on AD110 and AD410 doorbells
Using this trigger触发器是定义的一组平台值或条件,用于触发自动化运行。 [Learn more] in an automationHome Assistant 中的自动化允许您自动响应在家中和周围发生的事情。 [Learn more] will allow you to detect the press of the doorbell call button and create automations based upon it.
# Example automations.yaml entry
alias: "Doorbell Pressed"
description: "Trigger when Amcrest Button Press Event Fires"
triggers:
- trigger: event
event_type: amcrest
event_data:
event: "CallNoAnswered"
payload:
action: "Start"
actions:
- type: flash
entity_id: light.living_room
domain: light
To check if your Amcrest camera is supported/tested, visit the supportability matrixpython-amcrest
project.