Fix trigger scan config issue.

This commit is contained in:
Dermot Duffy
2023-10-02 18:52:37 -07:00
parent bfdbe70d6c
commit a3b1e5f834
3 changed files with 10 additions and 9 deletions
+4 -4
View File
@@ -779,10 +779,10 @@ const viewConfigDefault = {
}, },
}; };
const scanSchema = z.object({ const scanSchema = z.object({
enabled: z.boolean().default(viewConfigDefault.scan.enabled).optional(), enabled: z.boolean().default(viewConfigDefault.scan.enabled),
show_trigger_status: z.boolean().default(viewConfigDefault.scan.show_trigger_status).optional(), show_trigger_status: z.boolean().default(viewConfigDefault.scan.show_trigger_status),
untrigger_seconds: z.number().default(viewConfigDefault.scan.untrigger_seconds).optional(), untrigger_seconds: z.number().default(viewConfigDefault.scan.untrigger_seconds),
untrigger_reset: z.boolean().default(viewConfigDefault.scan.untrigger_reset).optional(), untrigger_reset: z.boolean().default(viewConfigDefault.scan.untrigger_reset),
}); });
export type ScanOptions = z.infer<typeof scanSchema>; export type ScanOptions = z.infer<typeof scanSchema>;
+5 -4
View File
@@ -2,6 +2,7 @@
// TODO: Test HA state connection/disconnect logic in real life. // TODO: Test HA state connection/disconnect logic in real life.
// TODO: Should not need to import screenfull anywhere except the fullscreen manager. // TODO: Should not need to import screenfull anywhere except the fullscreen manager.
// TODO: executeMediaQueryForView should not need a HTMLElement host parameter see the view-manager.ts call in particular. // TODO: executeMediaQueryForView should not need a HTMLElement host parameter see the view-manager.ts call in particular.
// TODO: Split out zod schema and add tests for config parsing (e.g. view.scan.show_status argument was missing)
import { LovelaceCardEditor } from 'custom-card-helpers'; import { LovelaceCardEditor } from 'custom-card-helpers';
import { ReactiveController } from 'lit'; import { ReactiveController } from 'lit';
@@ -95,12 +96,12 @@ export class CardController
protected _actionsManager = new ActionsManager(this); protected _actionsManager = new ActionsManager(this);
protected _automationsManager = new AutomationsManager(this); protected _automationsManager = new AutomationsManager(this);
protected _autoUpdateManager = new AutoUpdateManager(this); protected _autoUpdateManager = new AutoUpdateManager(this);
protected _cameraManager: CameraManager = new CameraManager(this); protected _cameraManager = new CameraManager(this);
protected _cameraURLManager = new CameraURLManager(this); protected _cameraURLManager = new CameraURLManager(this);
protected _cardElementManager: CardElementManager; protected _cardElementManager: CardElementManager;
protected _conditionsManager: ConditionsManager; protected _conditionsManager: ConditionsManager;
protected _configManager = new ConfigManager(this); protected _configManager = new ConfigManager(this);
protected _downloadManager: DownloadManager = new DownloadManager(this); protected _downloadManager = new DownloadManager(this);
protected _expandManager = new ExpandManager(this); protected _expandManager = new ExpandManager(this);
protected _fullscreenManager = new FullscreenManager(this); protected _fullscreenManager = new FullscreenManager(this);
protected _hassManager = new HASSManager(this); protected _hassManager = new HASSManager(this);
@@ -112,7 +113,7 @@ export class CardController
protected _microphoneManager = new MicrophoneManager(this); protected _microphoneManager = new MicrophoneManager(this);
protected _queryStringManager = new QueryStringManager(this); protected _queryStringManager = new QueryStringManager(this);
protected _styleManager = new StyleManager(this); protected _styleManager = new StyleManager(this);
protected _triggersManager: TriggersManager = new TriggersManager(this); protected _triggersManager = new TriggersManager(this);
protected _viewManager = new ViewManager(this); protected _viewManager = new ViewManager(this);
constructor( constructor(
@@ -229,7 +230,7 @@ export class CardController
return { return {
cameras: [ cameras: [
{ {
camera_entity: cameraEntity ?? 'camera.demo' camera_entity: cameraEntity ?? 'camera.demo',
}, },
], ],
// Need to use 'as unknown' to convince Typescript that this really isn't a // Need to use 'as unknown' to convince Typescript that this really isn't a
@@ -18,7 +18,7 @@ vi.mock('../../../src/camera-manager/manager.js');
// Creating and mocking a trigger API is a lot of boilerplate, this convenience // Creating and mocking a trigger API is a lot of boilerplate, this convenience
// function reduces it. // function reduces it.
const createTriggerAPI = (options?: { const createTriggerAPI = (options?: {
config?: ScanOptions; config?: Partial<ScanOptions>;
hassStates?: HassEntities; hassStates?: HassEntities;
interaction?: boolean; interaction?: boolean;
}) => { }) => {