diff --git a/src/card.ts b/src/card.ts index 46ff25a2..557fa614 100644 --- a/src/card.ts +++ b/src/card.ts @@ -20,7 +20,12 @@ import { import screenfull from 'screenfull'; import { z } from 'zod'; -import { entitySchema, frigateCardConfigSchema, MenuInteraction, RawFrigateCardConfig } from './types.js'; +import { + entitySchema, + frigateCardConfigSchema, + MenuInteraction, + RawFrigateCardConfig, +} from './types.js'; import type { BrowseMediaQueryParameters, Entity, @@ -58,7 +63,7 @@ import './patches/ha-hls-player.js'; import cardStyle from './scss/card.scss'; import { ResolvedMediaCache } from './resolved-media.js'; import { BrowseMediaUtil } from './browse-media-util.js'; -import { isConfigUpgradeable } from './config-mgmt.js'; +import { copyConfig, isConfigUpgradeable, upgradeConfig } from './config-mgmt.js'; /** A note on media callbacks: * @@ -413,14 +418,14 @@ export class FrigateCard extends LitElement { const hint = this._getParseErrorPaths(parseResult.error); let upgradeMessage = ''; if (configUpgradeable && getLovelace().mode !== 'yaml') { - upgradeMessage = `${localize('editor.upgrade_available_in_editor')}. `; - } + upgradeMessage = `${localize('error.upgrade_available')}. `; + } throw new Error( upgradeMessage + - `${localize('error.invalid_configuration')}: ` + + `${localize('error.invalid_configuration')}: ` + (hint.length ? JSON.stringify(hint, null, ' ') - : localize('error.invalid_configuration_no_hint')) + : localize('error.invalid_configuration_no_hint')), ); } const config = parseResult.data; @@ -807,13 +812,6 @@ export class FrigateCard extends LitElement { * Master render method for the card. */ protected render(): TemplateResult | void { - if (this.config.show_warning) { - return this._showWarning(localize('common.show_warning')); - } - if (this.config.show_error) { - return this._showError(localize('common.show_error')); - } - const padding = this._getAspectRatioPadding(); const outerStyle = {}, innerStyle = {}; @@ -994,31 +992,6 @@ export class FrigateCard extends LitElement { `; } - /** - * Show a warning card. - * @param warning The warning message. - * @returns A rendered template. - */ - private _showWarning(warning: string): TemplateResult { - return html` ${warning} `; - } - - /** - * Show an error card. - * @param error The error message. - * @returns A rendered template. - */ - private _showError(error: string): TemplateResult { - const errorCard = document.createElement('hui-error-card'); - errorCard.setConfig({ - type: 'error', - error, - origConfig: this.config, - }); - - return html` ${errorCard} `; - } - /** * Return compiled CSS styles (thus safe to use with unsafeCSS). */ diff --git a/src/localize/languages/en.json b/src/localize/languages/en.json index 5527f039..8d7c7aea 100644 --- a/src/localize/languages/en.json +++ b/src/localize/languages/en.json @@ -1,8 +1,6 @@ { "common": { "version": "Version", - "show_warning": "Show warning", - "show_error": "Show error", "frigate_card": "Frigate card", "frigate_card_description": "A Lovelace card for use with Frigate", "no_snapshots": "No snapshots", @@ -118,8 +116,7 @@ "dimensions_secondary": "Dimensions & shape options", "show_button": "Show button", "upgrade": "Upgrade", - "upgrade_available": "An automatic card configuration upgrade is available", - "upgrade_available_in_editor": "An automatic card configuration upgrade is available in the editor" + "upgrade_available": "An automatic card configuration upgrade is available" }, "error": { "empty_response": "Received empty response from Home Assistant for request", @@ -131,6 +128,7 @@ "no_live_camera": "The camera_entity parameter must be set and valid for this live provider", "invalid_configuration": "Invalid configuration", "invalid_configuration_no_hint": "No location hint available (bad or missing type?)", + "upgrade_available": "An automated card configuration upgrade is available, please visit the visual card editor", "missing_webrtc": "WebRTC component not found", "no_frigate_camera_name": "Cannot autodetect Frigate camera name, you need to either set camera_entity and / or frigate.camera_name", "could_not_render_elements": "Could not render picture elements", diff --git a/src/types.ts b/src/types.ts index d3be276a..6007dc34 100644 --- a/src/types.ts +++ b/src/types.ts @@ -461,8 +461,6 @@ export const frigateCardConfigSchema = z.object({ // Stock lovelace card config. type: z.string(), - show_warning: z.boolean().optional(), - show_error: z.boolean().optional(), test_gui: z.boolean().optional(), }); export type FrigateCardConfig = z.infer;