diff --git a/cast/src/receiver/layout/hc-lovelace.ts b/cast/src/receiver/layout/hc-lovelace.ts index 0de33aa69d..01b6f03fb0 100644 --- a/cast/src/receiver/layout/hc-lovelace.ts +++ b/cast/src/receiver/layout/hc-lovelace.ts @@ -17,7 +17,7 @@ class HcLovelace extends LitElement { @property({ attribute: false }) public lovelaceConfig!: LovelaceConfig; - @property() public viewPath?: string | number; + @property() public viewPath?: string | number | null; @property() public urlPath: string | null = null; @@ -93,6 +93,9 @@ class HcLovelace extends LitElement { } private get _viewIndex() { + if (this.viewPath === null) { + return 0; + } const selectedView = this.viewPath; const selectedViewInt = parseInt(selectedView as string, 10); for (let i = 0; i < this.lovelaceConfig.views.length; i++) { diff --git a/cast/src/receiver/layout/hc-main.ts b/cast/src/receiver/layout/hc-main.ts index dcf7a80eec..64b821817a 100644 --- a/cast/src/receiver/layout/hc-main.ts +++ b/cast/src/receiver/layout/hc-main.ts @@ -51,10 +51,10 @@ export class HcMain extends HassElement { @state() private _lovelacePath: string | number | null = null; - @state() private _error?: string; - @state() private _urlPath?: string | null; + @state() private _error?: string; + private _hassUUID?: string; private _unsubLovelace?: UnsubscribeFunc; @@ -81,7 +81,7 @@ export class HcMain extends HassElement { if ( !this._lovelaceConfig || - this._lovelacePath === null || + this._urlPath === undefined || // Guard against part of HA not being loaded yet. !this.hass || !this.hass.states || @@ -99,8 +99,8 @@ export class HcMain extends HassElement { `; @@ -226,9 +226,9 @@ export class HcMain extends HassElement { this.initializeHass(auth, connection); if (this._hassUUID !== msg.hassUUID) { this._hassUUID = msg.hassUUID; - this._lovelacePath = null; - this._urlPath = undefined; this._lovelaceConfig = undefined; + this._urlPath = undefined; + this._lovelacePath = null; if (this._unsubLovelace) { this._unsubLovelace(); this._unsubLovelace = undefined; @@ -285,7 +285,7 @@ export class HcMain extends HassElement { ], }; this._urlPath = "energy"; - this._lovelacePath = 0; + this._lovelacePath = null; this._sendStatus(); return; }