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) => export const fetchHassioBoots = async (hass: HomeAssistant) =>
hass.callApi<HassioResponse<HassioBoots>>("GET", `hassio/host/logs/boots`); 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 ( export const fetchHassioLogs = async (
hass: HomeAssistant, hass: HomeAssistant,
provider: string, provider: string,

View File

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

View File

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

View File

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