@@ -3,6 +3,7 @@
|
||||
- [`actions`](README.md)
|
||||
- [Custom Actions](./custom/README.md)
|
||||
- [Stock Actions](./stock/README.md)
|
||||
- [Templates](./templates.md)
|
||||
- [`automations`](../automations.md)
|
||||
- [`cameras`](../cameras/README.md)
|
||||
- [`conditions`](../conditions.md)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
- [`actions`](../README.md)
|
||||
- [Custom Actions](README.md)
|
||||
- [Stock Actions](../stock/README.md)
|
||||
- [Templates](../templates.md)
|
||||
- [`automations`](../../automations.md)
|
||||
- [`cameras`](../../cameras/README.md)
|
||||
- [`conditions`](../../conditions.md)
|
||||
|
||||
@@ -73,13 +73,13 @@ elements:
|
||||
action: toggle
|
||||
- type: icon
|
||||
icon: mdi:numeric-3-box
|
||||
title: Call Service action
|
||||
title: Perform Action / Call Service action
|
||||
style:
|
||||
left: 200px
|
||||
top: 150px
|
||||
tap_action:
|
||||
action: call-service
|
||||
service: homeassistant.toggle
|
||||
action: perform-action
|
||||
perform_action: homeassistant.toggle
|
||||
data:
|
||||
entity_id: light.office_main_lights
|
||||
- type: icon
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
- [`actions`](../README.md)
|
||||
- [Custom Actions](../custom/README.md)
|
||||
- [Stock Actions](README.md)
|
||||
- [Templates](../templates.md)
|
||||
- [`automations`](../../automations.md)
|
||||
- [`cameras`](../../cameras/README.md)
|
||||
- [`conditions`](../../conditions.md)
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
# Templates
|
||||
|
||||
Before actions are executed, template values (if present) are replaced within
|
||||
each action. This allows a variety of Home Assistant data to be automatically
|
||||
populated in your actions, as well as some Advanced Camera Card data.
|
||||
|
||||
## Stock Templates
|
||||
|
||||
The Advanced Camera Card uses
|
||||
[ha-nunjucks](https://github.com/Nerwyn/ha-nunjucks) to process templates.
|
||||
Consult its documentation for the wide variety of different template values
|
||||
supported.
|
||||
|
||||
See [an example](../../examples.md?id=accessing-home-assistant-state) that
|
||||
accesses Home Assistant state.
|
||||
|
||||
## Custom Templates
|
||||
|
||||
Custom template values must be proceeded by `advanced_camera_card` (or `acc` for
|
||||
short).
|
||||
|
||||
| Template | Replaced with |
|
||||
| -------- | -------------------------------------------------- |
|
||||
| `camera` | The currently selected camera. |
|
||||
| `view` | The current [view](../view.md?id=supported-views). |
|
||||
|
||||
See [an example](../../examples.md?id=accessing-advanced-camera-card-state) that
|
||||
accesses Advanced Camera Card state.
|
||||
|
||||
## Triggers
|
||||
|
||||
If the action is called by an [Advanced Camera Card
|
||||
Automation](../automations.md), additional data is available representing the
|
||||
current and prior state of whatever triggered the action.
|
||||
|
||||
Trigger template values must be proceeded by `advanced_camera_card.trigger` (or
|
||||
`acc.trigger` for short).
|
||||
|
||||
| Template | Replaced with |
|
||||
| -------------- | ------------------------------------------------------------------------------------------------- |
|
||||
| `camera.to` | For [camera conditions](../conditions.md?id=camera), the currently selected camera. |
|
||||
| `camera.from` | For [camera conditions](../conditions.md?id=camera), the previously selected camera. |
|
||||
| `view.to` | For [view conditions](../conditions.md?id=view), the currently selected view. |
|
||||
| `view.from` | For [view conditions](../conditions.md?id=view), the previously selected view. |
|
||||
| `state.entity` | For [state conditions](../conditions.md?id=state), the entity state that triggered the condition. |
|
||||
| `state.to` | For [state conditions](../conditions.md?id=state), the current state of the entity. |
|
||||
| `state.from` | For [state conditions](../conditions.md?id=state), the previous state of the entity. |
|
||||
|
||||
!> If an action is triggered with multiple [state
|
||||
conditions](../conditions.md?id=state), only data from the last listed state
|
||||
condition is available.
|
||||
|
||||
Please [request](https://github.com/dermotduffy/advanced-camera-card/issues) if
|
||||
you need data from additional conditions.
|
||||
|
||||
See [an example](../../examples.md?id=accessing-trigger-state) that accesses
|
||||
trigger state.
|
||||
@@ -143,7 +143,7 @@ This card supports several different views.
|
||||
| `clip` | Shows a viewer for the most recent clip for this camera. Can also be accessed by holding down the `clips` menu icon. |
|
||||
| `clips` | Shows a gallery of clips for this camera. |
|
||||
| `image` | Shows a static image specified by the `image` parameter, can be used as a discrete default view or a screensaver (via `view.interaction_seconds`). |
|
||||
| `live` | Shows the live camera view with the configured [live provider](). |
|
||||
| `live` | Shows the live camera view with the configured [live provider](./cameras/live-provider.md). |
|
||||
| `recording` | Shows a viewer for the most recent recording for this camera. Can also be accessed by holding down the `recordings` menu icon. |
|
||||
| `recordings` | Shows a gallery of recent (last day) recordings for this camera and its dependents. |
|
||||
| `snapshot` | Shows a viewer for the most recent snapshot for this camera. Can also be accessed by holding down the `snapshots` menu icon. |
|
||||
|
||||
@@ -947,6 +947,61 @@ menu:
|
||||
icon: mdi:high-definition
|
||||
```
|
||||
|
||||
## Templates in actions
|
||||
|
||||
### Accessing Home Assistant state
|
||||
|
||||
Perhaps the most common usage of templates is to access Home Assistant state
|
||||
values. In the below example a fictitious service `homeassistant.service` is
|
||||
called with data that refers to the current state of the `light.sunroom_ceiling`
|
||||
entity.
|
||||
|
||||
```yaml
|
||||
tap_action:
|
||||
action: perform-action
|
||||
perform_action: homeassistant.service
|
||||
data:
|
||||
key: '{{ hass.states["light.sunroom_ceiling"].state }}'
|
||||
```
|
||||
|
||||
See [Stock Templates](./configuration/actions/templates.md?id=stock-templates).
|
||||
|
||||
### Accessing Advanced Camera Card state
|
||||
|
||||
In this example, the currently selected camera and
|
||||
[view](./configuration/view.md) are passed as data to a fictitious service
|
||||
`homeassistant.service`.
|
||||
|
||||
```yaml
|
||||
tap_action:
|
||||
action: perform-action
|
||||
perform_action: homeassistant.service
|
||||
data:
|
||||
camera: '{{ advanced_camera_card.camera }}'
|
||||
view: '{{ advanced_camera_card.view }}'
|
||||
```
|
||||
|
||||
See [Custom Templates](./configuration/actions/templates.md?id=custom-templates).
|
||||
|
||||
### Accessing Trigger state
|
||||
|
||||
In this example, an [automation](./configuration/automations.md) is triggered,
|
||||
and values associated with the triggering are included in the action.
|
||||
|
||||
```yaml
|
||||
automations:
|
||||
- conditions:
|
||||
- condition: camera
|
||||
actions:
|
||||
- action: perform-action
|
||||
perform_action: homeassistant.service
|
||||
data:
|
||||
from_camera: '{{ acc.trigger.camera.from }}'
|
||||
to_camera: '{{ acc.trigger.camera.to }}'
|
||||
```
|
||||
|
||||
See [Trigger Templates](./configuration/actions/templates.md?id=triggers).
|
||||
|
||||
## Trigger actions
|
||||
|
||||
You can control the card itself with the `custom:advanced-camera-card-action` action.
|
||||
|
||||
Reference in New Issue
Block a user