From 047afeba29deecaf6faa41fe774e277fd7dbaf2b Mon Sep 17 00:00:00 2001 From: Dermot Duffy Date: Sun, 28 Nov 2021 16:02:56 -0800 Subject: [PATCH] Move `update_entities` to `view.update_entities` --- README.md | 20 ++++++++------------ src/card.ts | 2 +- src/config-mgmt.ts | 4 ++++ src/const.ts | 1 + src/types.ts | 4 +--- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 69c522a9..e5bcc15e 100644 --- a/README.md +++ b/README.md @@ -100,12 +100,13 @@ All configuration is under: view: ``` - | Option | Default | Description | | - | - | - | | `default` | `live` | The view to show in the card by default. See [views](#views) below.| | `timeout` | | A numbers of seconds of inactivity after which the card will reset to the default configured view. Inactivity is defined as lack of interaction with the Frigate menu.| | `actions` | | Actions to use for all views, individual actions may be overriden by view-specific actions. See [actions](#actions) below.| +| `update_force` | `false` | Whether card updates/refreshes should ignore playing media and human interaction. See [card updates](#card-updates) below for behavior and usecases.| +| `update_entities` | | **YAML only**: A list of entity ids that should cause the whole card to re-render. Entities used in picture elements / included in the menu do not need to be explicitly included here to be kept updated. See [card updates](#card-updates) below for behavior and usecases.| ### Menu Options @@ -324,14 +325,6 @@ The card aspect ratio can be changed with the `dimensions.aspect_ratio_mode` and If no aspect ratio is specified or available, but one is needed then `16:9` will be used by default. - - -### Other Options - -| Option | Default | Description | -| - | - | - | -| `update_entities` | | A list of entity ids that should cause the whole card to re-render, this can be useful in the `clip` or `snapshot` mode to (for example) cause a motion sensor to trigger a card refresh. Configurable in YAML only. Entities used in picture elements / included in the menu do not need to be explicitly included here to be kept updated. | - ### Using WebRTC @@ -797,6 +790,8 @@ menu: + + ## Card Refreshes / Updates Automated card refreshes / updates are minimized to avoid disruption to the @@ -807,7 +802,7 @@ The following table describes the behavior these 3 flags have. ### Card Update Truth Table -| `view.timeout` | `view.update_force` | `update_entities` & `camera_entity` | Behavior | +| `view.timeout` | `view.update_force` | `view.update_entities` & `camera_entity` | Behavior | | :-: | :-: | :-: | - | | Unset or `0` | *(Any value)* | Unset | Card will not automatically re-render. | | Unset or `0` | `false` | *(Any entity)* | Card will reload **current** view when entity state changes, unless media is playing. | @@ -834,8 +829,9 @@ view: binary_sensor for that camera (or any other entity at your discretion) to trigger the update: ```yaml -update_entities: - - binary_sensor.office_person_motion +view: + update_entities: + - binary_sensor.office_person_motion ``` ## Troubleshooting diff --git a/src/card.ts b/src/card.ts index 4948c8cc..f77c42a4 100644 --- a/src/card.ts +++ b/src/card.ts @@ -503,7 +503,7 @@ export class FrigateCard extends LitElement { this._frigateCameraName = undefined; this.config = config; - this._entitiesToMonitor = this.config.update_entities || []; + this._entitiesToMonitor = this.config.view.update_entities || []; if (this.config.camera_entity) { this._entitiesToMonitor.push(this.config.camera_entity); } diff --git a/src/config-mgmt.ts b/src/config-mgmt.ts index 32092cea..d9691677 100644 --- a/src/config-mgmt.ts +++ b/src/config-mgmt.ts @@ -16,6 +16,7 @@ import { CONF_MENU_MODE, CONF_VIEW_DEFAULT, CONF_VIEW_TIMEOUT, + CONF_VIEW_UPDATE_ENTITIES, } from './const'; import { RawFrigateCardConfig } from './types'; @@ -170,4 +171,7 @@ const UPGRADES = [ upgradeMoveTo('menu_buttons', 'menu.buttons'), upgradeMoveTo('menu_button_size', CONF_MENU_BUTTON_SIZE), upgradeMoveTo('image', CONF_IMAGE_SRC, isNotObject), + + // v2.0.0 -> v2.1.0 + upgradeMoveTo('update_entities', CONF_VIEW_UPDATE_ENTITIES), ]; diff --git a/src/const.ts b/src/const.ts index ec6f1e21..56c3dbdf 100644 --- a/src/const.ts +++ b/src/const.ts @@ -12,6 +12,7 @@ export const CONF_FRIGATE_ZONE = 'frigate.zone'; export const CONF_VIEW_DEFAULT = 'view.default'; export const CONF_VIEW_TIMEOUT = 'view.timeout'; export const CONF_VIEW_UPDATE_FORCE = 'view.update_force'; +export const CONF_VIEW_UPDATE_ENTITIES = 'view.update_entities'; export const CONF_EVENT_VIEWER_AUTOPLAY_CLIP = 'event_viewer.autoplay_clip'; export const CONF_EVENT_VIEWER_DRAGGABLE = 'event_viewer.draggable'; diff --git a/src/types.ts b/src/types.ts index e279c1a2..b037ddc8 100644 --- a/src/types.ts +++ b/src/types.ts @@ -342,6 +342,7 @@ const viewConfigSchema = z .optional() .default(viewConfigDefault.timeout), update_force: z.boolean().default(viewConfigDefault.update_force), + update_entities: z.string().array().optional(), }) .merge(actionsSchema) .default(viewConfigDefault); @@ -570,9 +571,6 @@ export const frigateCardConfigSchema = z.object({ elements: pictureElementsSchema, dimensions: dimensionsConfigSchema, - // Entities that should trigger a card update. - update_entities: z.string().array().optional(), - // Stock lovelace card config. type: z.string(), test_gui: z.boolean().optional(),