Files
advanced-camera-card/docs/configuration/templates.md
T

5.0 KiB

Templates

Templates may be used in a certain places to allow template values (if present) to be dynamically replaced. This allows a variety of Home Assistant data, and Advanced Camera Card data, to be accessible. Templates may be used in:

Note

Templates substitute into action values (e.g. a camera or message), not into the action type. The type discriminator (action and advanced_camera_card_action) must be a literal (as in Home Assistant itself).

Stock Templates

The Advanced Camera Card uses ha-nunjucks to process templates. Consult its documentation for the wide variety of different template values supported.

Note

To keep the card lightweight, some template features are not available. If a template feature you need is missing, open an issue to request it.

See an example that accesses Home Assistant state.

Custom Templates

Custom template values must be prefixed with acc.

Template Replaced with
camera The currently selected camera.
view The current view.
config The current card configuration.

See an example that accesses Advanced Camera Card state.

Media Matching

If templates are used for Folder Media Matching an additional media variable is available with these properties:

Media template values must be prefixed with acc.media.

Template Replaced with
title The media title being matched.
is_folder Whether the media item is a folder that may be expanded (vs a single media item).

Triggers

When an action runs from an automation, a top-level trigger variable describes what fired it (as in native Home Assistant actions), including the state before and after the change. Its fields depend on the kind of trigger.

The stock state and numeric_state triggers carry Home-Assistant-faithful entity data (a subset of Home Assistant's own trigger data: the card does not currently surface id, idx, for, attribute, above / below or alias, so request if you need more). The template trigger has no entity, so it carries only trigger.platform (template).

Template Replaced with
trigger.platform The trigger platform (state or numeric_state).
trigger.entity_id The entity that triggered (also available as trigger.entity).
trigger.from_state The full Home Assistant state object before the change, e.g. trigger.from_state.state.
trigger.to_state The full Home Assistant state object after the change, e.g. trigger.to_state.state or trigger.to_state.attributes.<name>.

The card-specific triggers (e.g. camera, view, config) carry the card state before and after the change:

Template Replaced with
trigger.platform acc for card-specific triggers.
trigger.type The card trigger kind (e.g. camera, view, config).
trigger.from_acc The card state before the change, with camera, view and config (e.g. trigger.from_acc.camera).
trigger.to_acc The card state after the change, with camera, view and config (e.g. trigger.to_acc.camera).

See an example that accesses trigger state.