mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Fix timer entity exception (#11837)
This commit is contained in:
parent
02d058561b
commit
b7c149fcc1
@ -23,6 +23,18 @@ class HuiTimerEntityRow extends LitElement {
|
|||||||
throw new Error("Invalid configuration");
|
throw new Error("Invalid configuration");
|
||||||
}
|
}
|
||||||
this._config = config;
|
this._config = config;
|
||||||
|
|
||||||
|
if (!this.hass) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const stateObj = this.hass!.states[this._config.entity];
|
||||||
|
|
||||||
|
if (stateObj) {
|
||||||
|
this._startInterval(stateObj);
|
||||||
|
} else {
|
||||||
|
this._clearInterval();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public disconnectedCallback(): void {
|
public disconnectedCallback(): void {
|
||||||
@ -75,18 +87,19 @@ class HuiTimerEntityRow extends LitElement {
|
|||||||
protected updated(changedProps: PropertyValues) {
|
protected updated(changedProps: PropertyValues) {
|
||||||
super.updated(changedProps);
|
super.updated(changedProps);
|
||||||
|
|
||||||
if (changedProps.has("hass")) {
|
if (!this._config || !changedProps.has("hass")) {
|
||||||
const stateObj = this.hass!.states[this._config!.entity];
|
return;
|
||||||
const oldHass = changedProps.get("hass") as this["hass"];
|
}
|
||||||
const oldStateObj = oldHass
|
const stateObj = this.hass!.states[this._config!.entity];
|
||||||
? oldHass.states[this._config!.entity]
|
const oldHass = changedProps.get("hass") as this["hass"];
|
||||||
: undefined;
|
const oldStateObj = oldHass
|
||||||
|
? oldHass.states[this._config!.entity]
|
||||||
|
: undefined;
|
||||||
|
|
||||||
if (oldStateObj !== stateObj) {
|
if (oldStateObj !== stateObj) {
|
||||||
this._startInterval(stateObj);
|
this._startInterval(stateObj);
|
||||||
} else if (!stateObj) {
|
} else if (!stateObj) {
|
||||||
this._clearInterval();
|
this._clearInterval();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user