README and option naming fixes.

This commit is contained in:
Dermot Duffy
2022-05-22 13:30:24 -07:00
parent c10fe5ca76
commit 913056f9c8
4 changed files with 38 additions and 35 deletions
+18 -15
View File
@@ -991,11 +991,12 @@ export class FrigateCard extends LitElement {
(entity) => !isTriggeredState(this._hass?.states[entity]),
);
if (shouldTrigger) {
this._triggers.set(camera, now)
this._triggers.set(camera, now);
} else if (shouldUntrigger && this._triggers.has(camera)) {
this._triggers.delete(camera);
}
triggerChanges ||= (!isTriggered && shouldTrigger) || (isTriggered && !this._triggers.size);
triggerChanges ||=
(!isTriggered && shouldTrigger) || (isTriggered && !this._triggers.size);
}
if (triggerChanges && this._isAutomatedViewUpdateAllowed(true)) {
@@ -1012,7 +1013,9 @@ export class FrigateCard extends LitElement {
}
}
if (targetCamera) {
this._changeView({ view: this._view.evolve({ camera: targetCamera }) });
this._changeView(
{ view: new View({ view: 'live', camera: targetCamera }) }
);
changedCamera = true;
}
}
@@ -1037,21 +1040,21 @@ export class FrigateCard extends LitElement {
let shouldUpdate = !oldHass || changedProps.size != 1;
if (oldHass) {
// Home Assistant pumps a lot of updates through. Re-rendering the card is
// necessary at times (e.g. to update the 'clip' view as new clips
// arrive), but also is a jarring experience for the user (e.g. if they
// are browsing the mini-gallery). Do not allow re-rendering from a Home
// Assistant update if there's been recent interaction (e.g. clicks on the
// card) or if there is media active playing.
if (this._updateTriggeredCameras(oldHass)) {
const selectedCamera = this._getSelectedCameraConfig();
if (this._getConfig().view.scan.enabled && this._updateTriggeredCameras(oldHass)) {
shouldUpdate ||= true;
} else if (
// Home Assistant pumps a lot of updates through. Re-rendering the card is
// necessary at times (e.g. to update the 'clip' view as new clips
// arrive), but also is a jarring experience for the user (e.g. if they
// are browsing the mini-gallery). Do not allow re-rendering from a Home
// Assistant update if there's been recent interaction (e.g. clicks on the
// card) or if there is media active playing.
this._isAutomatedViewUpdateAllowed() &&
isHassDifferent(
this._hass,
oldHass,
this._getConfig().view.update_entities || [],
)
isHassDifferent(this._hass, oldHass, [
...(this._getConfig().view.update_entities || []),
...(selectedCamera?.trigger_by_entities || []),
])
) {
// If entities being monitored have changed then reset the view to the
// default. Note that as per the Lit lifecycle, the setting of the view
+2 -2
View File
@@ -41,8 +41,8 @@ export const CONF_VIEW_UPDATE_ENTITIES = `${CONF_VIEW}.update_entities` as const
export const CONF_VIEW_UPDATE_SECONDS = `${CONF_VIEW}.update_seconds` as const;
export const CONF_VIEW_SCAN = `${CONF_VIEW}.scan` as const;
export const CONF_VIEW_SCAN_ENABLED = `${CONF_VIEW_SCAN}.enabled` as const;
export const CONF_VIEW_SCAN_TRIGGER_SHOW_BORDER =
`${CONF_VIEW_SCAN}.trigger_show_border` as const;
export const CONF_VIEW_SCAN_SHOW_TRIGGER_STATUS =
`${CONF_VIEW_SCAN}.show_trigger_status` as const;
export const CONF_EVENT_GALLERY = 'event_gallery' as const;
export const CONF_EVENT_GALLERY_CONTROLS_THUMBNAILS_SHOW_DETAILS =
+5 -5
View File
@@ -86,7 +86,7 @@ import {
CONF_VIEW_DEFAULT,
CONF_VIEW_SCAN,
CONF_VIEW_SCAN_ENABLED,
CONF_VIEW_SCAN_TRIGGER_SHOW_BORDER,
CONF_VIEW_SCAN_SHOW_TRIGGER_STATUS,
CONF_VIEW_TIMEOUT_SECONDS,
CONF_VIEW_UPDATE_CYCLE_CAMERA,
CONF_VIEW_UPDATE_FORCE,
@@ -611,14 +611,14 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor
CONF_VIEW_SCAN_ENABLED,
frigateCardConfigDefaults.view.scan.enabled ?? true,
{
label: localize('config.view.scan.enabled'),
label: localize(`config.${CONF_VIEW_SCAN_ENABLED}`),
},
)}
${this._renderSwitch(
CONF_VIEW_SCAN_TRIGGER_SHOW_BORDER,
frigateCardConfigDefaults.view.scan.trigger_show_border ?? true,
CONF_VIEW_SCAN_SHOW_TRIGGER_STATUS,
frigateCardConfigDefaults.view.scan.show_trigger_status ?? true,
{
label: localize('config.view.scan.trigger_show_border'),
label: localize(`config.${CONF_VIEW_SCAN_SHOW_TRIGGER_STATUS}`),
},
)}
</div>`