diff --git a/src/panels/lovelace/cards/hui-light-card.ts b/src/panels/lovelace/cards/hui-light-card.ts index 7e30776ef1..fa5bee5536 100644 --- a/src/panels/lovelace/cards/hui-light-card.ts +++ b/src/panels/lovelace/cards/hui-light-card.ts @@ -135,6 +135,7 @@ export class HuiLightCard extends LitElement implements LovelaceCard { const stateObj = this.hass!.states[this._config!.entity] as LightEntity; if (!stateObj) { + // Card will require refresh to work again return; } diff --git a/src/panels/lovelace/cards/hui-thermostat-card.ts b/src/panels/lovelace/cards/hui-thermostat-card.ts index 21c5d70614..071f324306 100644 --- a/src/panels/lovelace/cards/hui-thermostat-card.ts +++ b/src/panels/lovelace/cards/hui-thermostat-card.ts @@ -213,6 +213,7 @@ export class HuiThermostatCard extends LitElement implements LovelaceCard { private get _stepSize(): number { const stateObj = this.hass!.states[this._config!.entity]; + if (stateObj.attributes.target_temp_step) { return stateObj.attributes.target_temp_step; } @@ -220,6 +221,13 @@ export class HuiThermostatCard extends LitElement implements LovelaceCard { } private async _initialLoad(): Promise { + const stateObj = this.hass!.states[this._config!.entity] as ClimateEntity; + + if (!stateObj) { + // Card will require refresh to work again + return; + } + this._loaded = true; await this.updateComplete; @@ -233,15 +241,13 @@ export class HuiThermostatCard extends LitElement implements LovelaceCard { (this.shadowRoot!.querySelector( "#thermostat" - )! as HTMLElement).style.height = radius * 2 + "px"; + ) as HTMLElement)!.style.height = radius * 2 + "px"; const loaded = await loadRoundslider(); this._roundSliderStyle = loaded.roundSliderStyle; this._jQuery = loaded.jQuery; - const stateObj = this.hass!.states[this._config!.entity] as ClimateEntity; - const _sliderType = stateObj.attributes.target_temp_low && stateObj.attributes.target_temp_high