Camera

2024-11-25 Thecamera integration allows you to use IP cameras with Home Assistant. Note build block integration This camera is a building block integra

Related articles

Best Free VPN for Iran Do VPNs Hide Search & Browsing History? How to Bypass the NFL Blackout and Watch Every Game Using a VPN

Thecamera integration allows you to use IP cameras with Home Assistant.

Note

build block integration

This camera is a building block integration that cannot be added to your Home Assistant directly but is used and provided by other integrations.

A building block integration is differs differ from the typical integration that connect to a device or service . instead ,other integrations is use that do integrate a device or service into Home Assistant use this camera building block to provide entity ,service ,and other functionality that you can use in your automation or dashboard .

If one of your integration feature this building block ,this page is documents document the functionality the camera building block offer .

streaming video

If your camera is supports support it ,and thestream integration is setup ,you is be will be able to stream your camera in the frontend and on support medium player .

ThePreload stream option will start the camera feed on Home Assistant startup and continue to keep the stream alive. This will result in reduced latency when opening the stream in the frontend,as well as when using the play_stream action or Google Assistant integration. It does,however,utilize more resources on your machine,so it is recommended to check CPU usage if you plan to use this feature.

Camera
example show the Preload Stream option in the camera dialog .

Thestate of a camera

A camera is have can have the follow state . Not all camera integrations is support support all state .

  • Streaming: Thecamera transmits a live play-back of the video data it is recording.
  • Recording: Thecamera is currently capturing video content.
  • Idle: Thecamera is not currently capturing video content.
  • Unavailable: Theentity is currently unavailable.
  • Unknown: Thestate is not yet known.

Actions

Once loaded,the camera platform will expose actions that can be called to perform various actions.

Available actions: enable_motion_detection,disable_motion_detection,play_stream,record,snapshot,turn_off and turn_on.

Action enable_motion_detection

Enable the motion detection in a camera.

datum attribute optional description
entity_id yes Name(s) of entities to enable motion detection,e.g.,camera.living_room_camera.

Action disable_motion_detection

Disable the motion detection in a camera.

datum attribute optional description
entity_id yes Name(s) of entities to disable motion detection,e.g.,camera.living_room_camera.

action play_stream

Play a live stream from a camera to selected media player(s). Requires stream integration to be set up .

datum attribute optional description
entity_id no Name of entity to fetch stream from,e.g.,camera.living_room_camera.
media_player no Name of media player to play stream on,e.g.,media_player.living_room_tv.
format yes stream format support bystream integration and selected media_player. Default: hls

For example,the following action in an automation would send an hls live stream to your chromecast.

actions:
  - action: camera.play_stream
    target:
      entity_id: camera.yourcamera
    data:
      media_player: media_player.chromecast

Action record

Make a .mp4 recording from a camera stream. Requires stream integration to be set up .

Both duration and lookback options are suggestions,but should be consistent per camera. Theactual length of the recording may vary. It is suggested that you tweak these settings to fit your needs.

datum attribute optional description
entity_id no Name(s) of entities to create a snapshot from,e.g.,camera.living_room_camera.
filename no recording file name .
duration yes Target recording length (in seconds). Default: 30
lookback yes target lookback period ( in second ) to include in addition to duration . Only available if there is currently an active hls stream . default : 0

Thepath part of filename must be an entry in theallowlist_external_dir in your homeassistant : section of yourconfiguration.yamlTheconfiguration.yaml file is the main configuration file for Home Assistant. It lists the integrations to be loaded and their specific configurations. In some cases,the configuration needs to be edited manually directly in the configuration.yaml file. Most integrations can be configured in the UI. [Learn more] file.

For example,the following action in an automation would take a recording from “yourcamera” and save it to /tmp with a timestamped filename.

actions:
  - variable:
      entity_id: camera.yourcamera  # Store the camera entity_id in a variable for reuse
  - action: camera.record
    target:
      entity_id: '{{ entity_id } } '
    data:
      filename: '/tmp/{{ entity_id }}_{{ now().strftime("%Y%m%d-%H%M%S " ) }}.mp4'

action snapshot

Take a snapshot from a camera.

datum attribute optional description
entity_id no Name(s) of entities to create a snapshot from,e.g.,camera.living_room_camera.
filename no Snapshot file name.

Thepath part of filename must be an entry in theallowlist_external_dir in your homeassistant : section of yourconfiguration.yamlTheconfiguration.yaml file is the main configuration file for Home Assistant. It lists the integrations to be loaded and their specific configurations. In some cases,the configuration needs to be edited manually directly in the configuration.yaml file. Most integrations can be configured in the UI. [Learn more] file.

For example,the following action in an automation would take a snapshot from “yourcamera” and save it to /tmp with a timestamped filename.

actions:
  - variable:
      entity_id: camera.yourcamera  # Store the camera entity_id in a variable for reuse
  - action: camera.snapshot
    target:
      entity_id: '{{ entity_id } } '
    data:
      filename: '/tmp/{{ entity_id }}_{{ now().strftime("%Y%m%d-%H%M%S " ) } } .jpg '

action turn_off

Turn off camera. Not all camera models support this action,please consult individual camera page.

datum attribute optional description
entity_id yes Name(s) of entities to turn off,e.g.,camera.living_room_camera.

Action turn_on

Turn on camera. Not all camera models support this action,please consult individual camera page.

datum attribute optional description
entity_id yes Name(s) of entities to turn on,e.g.,camera.living_room_camera.

Test if it works

A way to test if you have set up your camera platform correctly,is to use Actions from the Developer Tools. Choose your action from the dropdown menu Action,enter something like the sample below into the data field,and select Perform action.

entity_id: camera.living_room_camera

help us improve our documentation

Suggest an edit to this page,or provide/view feedback for this page.