Fix error on hardware page (#23021)

* fix error on hardware page

* Update ha-config-hardware.ts
This commit is contained in:
Bram Kragten 2024-11-27 14:44:24 +01:00 committed by GitHub
parent 71214351ca
commit f54bb20fef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -37,6 +37,7 @@ import { haStyle } from "../../../resources/styles";
import type { HomeAssistant } from "../../../types";
import { hardwareBrandsUrl } from "../../../util/brands-url";
import { showhardwareAvailableDialog } from "./show-dialog-hardware-available";
import { extractApiErrorMessage } from "../../../data/hassio/common";
const DATASAMPLES = 60;
@ -55,7 +56,7 @@ class HaConfigHardware extends SubscribeMixin(LitElement) {
@property({ type: Boolean }) public narrow = false;
@state() private _error?: { code: string; message: string };
@state() private _error?: string;
@state() private _OSData?: HassioHassOSInfo;
@ -268,11 +269,7 @@ class HaConfigHardware extends SubscribeMixin(LitElement) {
`
: ""}
${this._error
? html`
<ha-alert alert-type="error"
>${this._error.message || this._error.code}</ha-alert
>
`
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
: ""}
<div class="content">
${boardName || isComponentLoaded(this.hass, "hassio")
@ -466,7 +463,7 @@ class HaConfigHardware extends SubscribeMixin(LitElement) {
this._OSData = await fetchHassioHassOsInfo(this.hass);
}
} catch (err: any) {
this._error = err.message || err;
this._error = extractApiErrorMessage(err);
}
}