From 2d3b01583a561eea677fe4904ccd4abf6b16a7d0 Mon Sep 17 00:00:00 2001 From: Dermot Duffy Date: Sat, 20 May 2023 13:26:09 -0700 Subject: [PATCH] Fix overrides bug caused by incorrect initial state. --- package.json | 2 +- src/card.ts | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 7a9a872a..d21d5c5d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "frigate-hass-card", - "version": "5.1.0", + "version": "5.1.1", "description": "Frigate Lovelace Card for Home Assistant", "keywords": [ "frigate", diff --git a/src/card.ts b/src/card.ts index 2be087c1..e467640c 100644 --- a/src/card.ts +++ b/src/card.ts @@ -896,10 +896,6 @@ class FrigateCard extends LitElement { this._message = null; this._setupConditionController(); - this._conditionController?.setState({ - view: undefined, - camera: undefined, - }); this._automationsController = new AutomationsController(this._config.automations); this._setLightOrDarkMode(); @@ -915,6 +911,18 @@ class FrigateCard extends LitElement { this._requestUpdateForComponentsThatUseConditions.bind(this), ); this._conditionController.addStateListener(this._executeAutomations.bind(this)); + + this._conditionController.setState({ + view: undefined, + fullscreen: this._isInFullscreen(), + expand: this._expand, + camera: undefined, + ...(this._hass && + this._conditionController?.hasHAStateConditions && { + state: this._hass.states, + }), + media_loaded: !!this._currentMediaLoadedInfo, + }); } protected _executeAutomations(): void { @@ -2117,14 +2125,12 @@ class FrigateCard extends LitElement { } protected _fullscreenHandler(): void { - const inFullscreen = screenfull.isEnabled && screenfull.isFullscreen; - - if (inFullscreen) { + if (this._isInFullscreen()) { this._expand = false; } this._conditionController?.setState({ - fullscreen: inFullscreen, + fullscreen: this._isInFullscreen(), expand: this._expand, });