From 5ca5624dbd2d224d43d8f1a0cea722a241a8fa8f Mon Sep 17 00:00:00 2001 From: Dermot Duffy Date: Mon, 16 Aug 2021 08:38:35 -0700 Subject: [PATCH] Add zone/label support. --- src/editor.ts | 76 ++++++++++++++++++++++++++++++++++++++------- src/frigate-card.ts | 6 ++-- src/types.ts | 1 + 3 files changed, 68 insertions(+), 15 deletions(-) diff --git a/src/editor.ts b/src/editor.ts index 51fa6bbc..fb91a5e3 100644 --- a/src/editor.ts +++ b/src/editor.ts @@ -27,7 +27,19 @@ const options = { name: 'Optional', secondary: 'Optional configuration to tweak card behavior', show: false, - } + }, + webrtc: { + icon: 'webrtc', + name: 'WebRTC', + secondary: 'Optional WebRTC parameters', + show: false, + }, + advanced: { + icon: 'cogs', + name: 'Advanced', + secondary: 'Advanced options', + show: false, + }, }; @customElement('frigate-card-editor') @@ -182,10 +194,50 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor .configValue=${'view_timeout'} @value-changed=${this._valueChanged} > + ` + : '' + } +
+
+ +
${options.advanced.name}
+
+
${options.advanced.secondary}
+
+ ${options.advanced.show + ? html` +
+ +
+
+ +
` + : '' + } +
+
+ +
${options.webrtc.name}
+
+
${options.webrtc.secondary}
+
+ ${options.webrtc.show + ? html` +
${Object.keys(liveProvider).map(key => { @@ -201,15 +253,15 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor label="WebRTC Camera Entity (To use with WebRTC Live Provider)" @value-changed=${this._valueChanged} .configValue=${'webrtc.entity'} - > - - ${cameraEntities.map(entity => { - return html` - ${entity} - `; - })} - - + > + + ${cameraEntities.map(entity => { + return html` + ${entity} + `; + })} + +
` : '' } diff --git a/src/frigate-card.ts b/src/frigate-card.ts index ad320a76..837a016f 100644 --- a/src/frigate-card.ts +++ b/src/frigate-card.ts @@ -1,6 +1,4 @@ // TODO Feature: Add title to clips / snapshots playing/viewing -// TODO Feature: Automatically reload views as events happen. -// TODO Feature: Zone label for selectinge events? // TODO Bug: Sometimes webrtc component shows up as not found in browser (maybe after fresh build?) // TODO Last step: Add documentation & screenshots. @@ -80,7 +78,6 @@ function shouldUpdateBasedOnHass( if (!entity) { continue; } - console.info(`${entity} -> ${oldHass.states[entity].state}/${newHass.states[entity].state}`) if (oldHass.states[entity] !== newHass.states[entity]) { return true; } @@ -348,6 +345,9 @@ export class FrigateCard extends LitElement { if (this.config.label) { url += `&label=${this.config.label}`; } + if (this.config.zone) { + url += `&zone=${this.config.zone}`; + } const response = await fetch(url); if (response.ok) { diff --git a/src/types.ts b/src/types.ts index 97bf11a5..23fa74df 100644 --- a/src/types.ts +++ b/src/types.ts @@ -26,6 +26,7 @@ export const frigateCardConfigSchema = z.object({ live_provider: z.enum(["frigate", "webrtc"]).default("frigate"), webrtc: z.object({}).passthrough().optional(), label: z.string().optional(), + zone: z.string().optional(), // Stock lovelace card config. type: z.string(),