Camera


The camera component allows you to use IP cameras with Home Assistant. With a little additional work you could use USB cameras as well.

Service

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

Available services: enable_motion_detection, disable_motion_detection, and snapshot.

Service enable_motion_detection

Enable the motion detection in a camera.

Service data attribute Optional Description
entity_id no Name(s) of entities to enable motion detection, e.g., camera.living_room_camera.

Service disable_motion_detection

Disable the motion detection in a camera.

Service data attribute Optional Description
entity_id no Name(s) of entities to disable motion detection, e.g., camera.living_room_camera.

Service snapshot

Take a snapshot from a camera.

Service data attribute Optional Description
entity_id no Name(s) of entities to create a snapshot from, e.g., camera.living_room_camera.
filename no Template of a file name. Variable is entity_id, e.g., /tmp/snapshot_{{ entity_id }}.

The path part of filename must be an entry in the whitelist_external_dirs in your homeassistant: section of your configuration.yaml file.

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

action:
  service: camera.snapshot
  data:
    entity_id: camera.yourcamera
    filename: '/tmp/yourcamera_{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg'

Test if it works

A simple way to test if you have set up your camera platform correctly, is to use service developer tool icon Services from the Developer Tools. Choose your service from the dropdown menu Service, enter something like the sample below into the Service Data field, and hit CALL SERVICE.

{
  "entity_id": "camera.living_room_camera"
}