diff --git a/docs/configuration/actions.md b/docs/configuration/actions.md index 5b9af685..b371f765 100644 --- a/docs/configuration/actions.md +++ b/docs/configuration/actions.md @@ -132,9 +132,13 @@ frigate_card_action: change_zoom | - | - | | `action` | Must be `custom:frigate-card-action`. | | `frigate_card_action` | Must be `change_zoom`. | -| `target_id` | The [camera ID](cameras/README.md?id=cameras) to adjust the pan/zoom of, or a media ID (e.g. `frigate` event ID) to zoom in on specific media items. | -| `zoom` | How much to zoom-in. See the [camera zoom parameter](cameras/README.md?id=layout-configuration). | -| `pan` | How much to pan-x/y. See the [camera pan parameter](cameras/README.md?id=layout-configuration). | +| `target_id` | The [camera ID](cameras/README.md?id=cameras) or a media ID (e.g. `frigate` event ID) to change zoom/pam settings for. | +| `zoom` | Optional parameter that controls how much to zoom-in. See the [camera zoom parameter](cameras/README.md?id=layout-configuration). | +| `pan` | Optional parameter that controls how much to pan-x/y. See the [camera pan parameter](cameras/README.md?id=layout-configuration). | + +?> If neither `zoom` nor `pan` are specified the camera will return to its default zoom and pan settings. + +See [example of automatically zoom/panning based on state](../examples.md?id=automatically-zoom-based-on-state). ### `clip`, `clips`, `image`, `live`, `recording`, `recordings`, `snapshot`, `snapshots` @@ -536,4 +540,14 @@ elements: frigate_card_action: ptz ptz_action: preset ptz_preset: doorway + - type: custom:frigate-card-menu-icon + icon: mdi:alpha-r-circle + title: Change Zoom + tap_action: + action: custom:frigate-card-action + frigate_card_action: change_zoom + pan: + x: 50 + y: 50 + zoom: 1 ``` diff --git a/docs/examples.md b/docs/examples.md index 0165992c..5c2aa999 100644 --- a/docs/examples.md +++ b/docs/examples.md @@ -1057,3 +1057,35 @@ overrides: x: 100 y: 100 ``` + +### Automatically zoom based on state + +This example automatically zooms in and out based on the state of an entity: + +```yaml +type: custom:frigate-card +cameras: + - camera_entity: camera.living_room + live_provider: go2rtc +debug: + logging: true +automations: + - conditions: + - condition: state + entity: binary_sensor.door_contact + state: 'on' + actions: + - action: custom:frigate-card-action + frigate_card_action: change_zoom + target_id: camera.living_room + zoom: 4 + pan: + x: 38 + y: 20 + actions_not: + - action: custom:frigate-card-action + frigate_card_action: change_zoom + target_id: camera.living_room +``` + +![](images/zoom-automation.gif 'Zoom automation example :size=400') diff --git a/docs/images/zoom-automation.gif b/docs/images/zoom-automation.gif new file mode 100644 index 00000000..609ad1b1 Binary files /dev/null and b/docs/images/zoom-automation.gif differ diff --git a/src/card-controller/conditions-manager.ts b/src/card-controller/conditions-manager.ts index 7cc0d7ec..4f8b243e 100644 --- a/src/card-controller/conditions-manager.ts +++ b/src/card-controller/conditions-manager.ts @@ -190,6 +190,7 @@ export class ConditionsManager { const config = this._api.getConfigManager().getConfig(); const conditions: FrigateCardCondition[] = []; config?.overrides?.forEach((override) => conditions.push(...override.conditions)); + config?.automations?.forEach((automation) => conditions.push(...automation.conditions)); // Element conditions can be arbitrarily nested underneath conditionals and // custom elements that this card may not known. Here we recursively parse