Fix hassio logs for core < 2024.11 (#22708)

This commit is contained in:
Wendelin 2024-11-07 09:45:58 +01:00 committed by GitHub
parent 9b9adf3c7a
commit 1e73cebda6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 13 additions and 3 deletions

View File

@ -185,6 +185,15 @@ export const fetchHassioInfo = async (
export const fetchHassioBoots = async (hass: HomeAssistant) =>
hass.callApi<HassioResponse<HassioBoots>>("GET", `hassio/host/logs/boots`);
export const fetchHassioLogsLegacy = async (
hass: HomeAssistant,
provider: string
) =>
hass.callApi<string>(
"GET",
`hassio/${provider.includes("_") ? `addons/${provider}` : provider}/logs`
);
export const fetchHassioLogs = async (
hass: HomeAssistant,
provider: string,

View File

@ -49,6 +49,7 @@ import {
fetchHassioBoots,
fetchHassioLogs,
fetchHassioLogsFollow,
fetchHassioLogsLegacy,
getHassioLogDownloadLinesUrl,
getHassioLogDownloadUrl,
} from "../../../data/hassio/supervisor";
@ -545,8 +546,7 @@ class ErrorLogCard extends LitElement {
this._streamSupported = false;
let logs = "";
if (isComponentLoaded(this.hass, "hassio") && this.provider) {
const repsonse = await fetchHassioLogs(this.hass, this.provider);
logs = await repsonse.text();
logs = await fetchHassioLogsLegacy(this.hass, this.provider);
} else {
logs = await fetchErrorLog(this.hass);
}

View File

@ -158,6 +158,7 @@ export const connectionMixin = <T extends Constructor<HassBaseEl>>(
},
callApi: async (method, path, parameters, headers) =>
hassCallApi(auth, method, path, parameters, headers),
// callApiRaw introduced in 2024.11
callApiRaw: async (method, path, parameters, headers, signal) =>
hassCallApiRaw(auth, method, path, parameters, headers, signal),
fetchWithAuth: (

View File

@ -259,7 +259,7 @@ export interface HomeAssistant {
parameters?: Record<string, any>,
headers?: Record<string, string>
): Promise<T>;
callApiRaw(
callApiRaw( // introduced in 2024.11
method: "GET" | "POST" | "PUT" | "DELETE",
path: string,
parameters?: Record<string, any>,