Rename view.timeout to view.timeout_seconds .

This commit is contained in:
Dermot Duffy
2022-01-19 21:16:08 -08:00
parent 6688836aa7
commit 656bd5439e
7 changed files with 24 additions and 23 deletions
+4 -4
View File
@@ -135,7 +135,7 @@ view:
| Option | Default | Overridable | Description | | Option | Default | Overridable | Description |
| - | - | - | - | | - | - | - | - |
| `default` | `live` | :heavy_multiplication_x: | The view to show in the card by default. See [views](#views) below.| | `default` | `live` | :heavy_multiplication_x: | The view to show in the card by default. See [views](#views) below.|
| `timeout` | | :heavy_multiplication_x: | 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.| | `timeout_seconds` | | :heavy_multiplication_x: | 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` | | :heavy_multiplication_x: | Actions to use for all views, individual actions may be overriden by view-specific actions. See [actions](#actions) below.| | `actions` | | :heavy_multiplication_x: | Actions to use for all views, individual actions may be overriden by view-specific actions. See [actions](#actions) below.|
| `update_force` | `false` | :heavy_multiplication_x: | Whether card updates/refreshes should ignore playing media and human interaction. See [card updates](#card-updates) below for behavior and usecases.| | `update_force` | `false` | :heavy_multiplication_x: | Whether card updates/refreshes should ignore playing media and human interaction. See [card updates](#card-updates) below for behavior and usecases.|
| `update_entities` | | :heavy_multiplication_x: | **YAML only**: A list of entity ids that should cause the view to reset to the default. See [card updates](#card-updates) below for behavior and usecases.| | `update_entities` | | :heavy_multiplication_x: | **YAML only**: A list of entity ids that should cause the view to reset to the default. See [card updates](#card-updates) below for behavior and usecases.|
@@ -572,7 +572,7 @@ This card supports several different views:
|`snapshot`|Shows an event viewer for the most recent snapshot for this camera/zone/label. Can also be accessed by holding down the `snapshots` menu icon.| |`snapshot`|Shows an event viewer for the most recent snapshot for this camera/zone/label. Can also be accessed by holding down the `snapshots` menu icon.|
|`clips`|Shows an event gallery of clips for this camera/zone/label.| |`clips`|Shows an event gallery of clips for this camera/zone/label.|
|`clip`|Shows an event viewer for the most recent clip for this camera/zone/label. Can also be accessed by holding down the `clips` menu icon.| |`clip`|Shows an event viewer for the most recent clip for this camera/zone/label. Can also be accessed by holding down the `clips` menu icon.|
|`image`|Shows a static image specified by the `image` parameter, can be used as a discrete default view or a screensaver (via `view_timeout`).| |`image`|Shows a static image specified by the `image` parameter, can be used as a discrete default view or a screensaver (via `view.timeout_seconds`).|
### Navigating From A Snapshot To A Clip ### Navigating From A Snapshot To A Clip
@@ -1105,7 +1105,7 @@ The following table describes the behavior these 3 flags have.
### Card Update Truth Table ### Card Update Truth Table
| `view.timeout` | `view.update_force` | `view.update_entities` | Behavior | | `view.timeout_seconds` | `view.update_force` | `view.update_entities` | Behavior |
| :-: | :-: | :-: | - | | :-: | :-: | :-: | - |
| Unset or `0` | *(Any value)* | Unset | Card will not automatically refresh. | | Unset or `0` | *(Any value)* | Unset | Card will not automatically refresh. |
| Unset or `0` | `false` | *(Any entity)* | Card will reload default view when entity state changes, unless media is playing. | | Unset or `0` | `false` | *(Any entity)* | Card will reload default view when entity state changes, unless media is playing. |
@@ -1121,7 +1121,7 @@ The following table describes the behavior these 3 flags have.
```yaml ```yaml
view: view:
default: live default: live
timeout: 30 timeout_seconds: 30
force: true force: true
``` ```
* Using `clip` or `snapshot` as the default view (for the most recent clip or * Using `clip` or `snapshot` as the default view (for the most recent clip or
+1 -1
View File
@@ -26,9 +26,9 @@ export class CachedValueController<T> implements ReactiveController {
protected _timerID?: number; protected _timerID?: number;
constructor(host: ReactiveControllerHost, timerSeconds: number, callback: () => T) { constructor(host: ReactiveControllerHost, timerSeconds: number, callback: () => T) {
(this._host = host).addController(this);
this._timerSeconds = timerSeconds; this._timerSeconds = timerSeconds;
this._callback = callback; this._callback = callback;
(this._host = host).addController(this);
} }
public removeController(): void { public removeController(): void {
+13 -3
View File
@@ -20,7 +20,7 @@ import {
CONF_MENU_MODE, CONF_MENU_MODE,
CONF_OVERRIDES, CONF_OVERRIDES,
CONF_VIEW_DEFAULT, CONF_VIEW_DEFAULT,
CONF_VIEW_TIMEOUT, CONF_VIEW_TIMEOUT_SECONDS,
CONF_VIEW_UPDATE_ENTITIES, CONF_VIEW_UPDATE_ENTITIES,
} from './const'; } from './const';
import { RawFrigateCardConfig, RawFrigateCardConfigArray } from './types'; import { RawFrigateCardConfig, RawFrigateCardConfigArray } from './types';
@@ -129,13 +129,22 @@ export const copyConfig = function (obj: RawFrigateCardConfig): RawFrigateCardCo
/** /**
* Determines if a property is not an object. * Determines if a property is not an object.
* @param value The property. * @param value The value.
* @returns `true` is the value is not an object. * @returns `true` is the value is not an object.
*/ */
const isNotObject = function (value: unknown) { const isNotObject = function (value: unknown) {
return typeof value !== 'object' ? value : undefined; return typeof value !== 'object' ? value : undefined;
}; };
/**
* Converts to a number or return undefined.
* @param value The value.
* @returns A number or undefined.
*/
const toNumberOrIgnore = function (value: unknown) {
return isNaN(value as number) ? undefined : Number(value)
};
/** /**
* Move a property from one location to another. * Move a property from one location to another.
* @param obj The configuration object in which the property resides. * @param obj The configuration object in which the property resides.
@@ -265,7 +274,7 @@ const UPGRADES = [
upgradeMoveTo('label', 'frigate.label'), upgradeMoveTo('label', 'frigate.label'),
upgradeMoveTo('zone', 'frigate.zone'), upgradeMoveTo('zone', 'frigate.zone'),
upgradeMoveTo('view_default', CONF_VIEW_DEFAULT), upgradeMoveTo('view_default', CONF_VIEW_DEFAULT),
upgradeMoveTo('view_timeout', CONF_VIEW_TIMEOUT), upgradeMoveTo('view_timeout', 'view.timeout'),
upgradeMoveTo('live_provider', 'live.provider'), upgradeMoveTo('live_provider', 'live.provider'),
upgradeMoveTo('live_preload', CONF_LIVE_PRELOAD), upgradeMoveTo('live_preload', CONF_LIVE_PRELOAD),
upgradeMoveTo('webrtc', 'live.webrtc'), upgradeMoveTo('webrtc', 'live.webrtc'),
@@ -283,4 +292,5 @@ const UPGRADES = [
// v2.1.0 -> v3.0.0 // v2.1.0 -> v3.0.0
upgradeToMultipleCameras(), upgradeToMultipleCameras(),
updateMenuConditionToMenuOverride(), updateMenuConditionToMenuOverride(),
upgradeMoveTo('view.timeout', CONF_VIEW_TIMEOUT_SECONDS, toNumberOrIgnore),
]; ];
+1 -1
View File
@@ -20,7 +20,7 @@ export const CONF_CAMERAS_ARRAY_LIVE_PROVIDER = `${CONF_CAMERAS}.#.live_provider
export const CONF_VIEW = 'view' as const; export const CONF_VIEW = 'view' as const;
export const CONF_VIEW_DEFAULT = `${CONF_VIEW}.default` as const; export const CONF_VIEW_DEFAULT = `${CONF_VIEW}.default` as const;
export const CONF_VIEW_TIMEOUT = `${CONF_VIEW}.timeout` as const; export const CONF_VIEW_TIMEOUT_SECONDS = `${CONF_VIEW}.timeout_seconds` as const;
export const CONF_VIEW_UPDATE_FORCE = `${CONF_VIEW}.update_force` as const; export const CONF_VIEW_UPDATE_FORCE = `${CONF_VIEW}.update_force` as const;
export const CONF_VIEW_UPDATE_ENTITIES = `${CONF_VIEW}.update_entities` as const; export const CONF_VIEW_UPDATE_ENTITIES = `${CONF_VIEW}.update_entities` as const;
+2 -2
View File
@@ -56,7 +56,7 @@ import {
CONF_MENU_BUTTON_SIZE, CONF_MENU_BUTTON_SIZE,
CONF_MENU_MODE, CONF_MENU_MODE,
CONF_VIEW_DEFAULT, CONF_VIEW_DEFAULT,
CONF_VIEW_TIMEOUT, CONF_VIEW_TIMEOUT_SECONDS,
CONF_VIEW_UPDATE_FORCE, CONF_VIEW_UPDATE_FORCE,
} from './const.js'; } from './const.js';
import { arrayMove, getEntityTitle, prettifyFrigateName } from './common.js'; import { arrayMove, getEntityTitle, prettifyFrigateName } from './common.js';
@@ -657,7 +657,7 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor
? html` ? html`
<div class="values"> <div class="values">
${this._renderDropdown(CONF_VIEW_DEFAULT, viewModes)} ${this._renderDropdown(CONF_VIEW_DEFAULT, viewModes)}
${this._renderStringInput(CONF_VIEW_TIMEOUT, 'number')} ${this._renderStringInput(CONF_VIEW_TIMEOUT_SECONDS, 'number')}
${this._renderSwitch(CONF_VIEW_UPDATE_FORCE, defaults.view.update_force)} ${this._renderSwitch(CONF_VIEW_UPDATE_FORCE, defaults.view.update_force)}
</div> </div>
` `
+2 -2
View File
@@ -41,7 +41,7 @@
"snapshots": "Snapshots gallery", "snapshots": "Snapshots gallery",
"image": "Static image" "image": "Static image"
}, },
"timeout": "View timeout secs (before returning to default, 0=never)", "timeout_seconds": "View timeout seconds (before returning to default, 0=never)",
"update_force": "Force card updates (ignore media playing / interaction)" "update_force": "Force card updates (ignore media playing / interaction)"
}, },
"event_gallery": { "event_gallery": {
@@ -99,7 +99,7 @@
}, },
"image": { "image": {
"src": "Static image URL/data for image view", "src": "Static image URL/data for image view",
"refresh_seconds": "Number of seconds after which to refresh" "refresh_seconds": "Number of seconds after which to refresh (0=never)"
}, },
"menu": { "menu": {
"buttons": { "buttons": {
+1 -10
View File
@@ -371,16 +371,7 @@ const viewConfigSchema = z
.enum(FRIGATE_CARD_VIEWS_USER_SPECIFIED) .enum(FRIGATE_CARD_VIEWS_USER_SPECIFIED)
.optional() .optional()
.default(viewConfigDefault.default), .default(viewConfigDefault.default),
timeout: z timeout_seconds: z.number().default(viewConfigDefault.timeout),
.number()
.or(
z
.string()
.regex(/^\d+$/)
.transform((val) => Number(val)),
)
.optional()
.default(viewConfigDefault.timeout),
update_force: z.boolean().default(viewConfigDefault.update_force), update_force: z.boolean().default(viewConfigDefault.update_force),
update_entities: z.string().array().optional(), update_entities: z.string().array().optional(),
}) })