Skip to content

Commit

Permalink
Fix hassio logs for core < 2024.11
Browse files Browse the repository at this point in the history
  • Loading branch information
wendevlin committed Nov 7, 2024
1 parent a08c7a3 commit 6f4dd31
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
9 changes: 9 additions & 0 deletions src/data/hassio/supervisor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/panels/config/logs/error-log-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import {
fetchHassioBoots,
fetchHassioLogs,
fetchHassioLogsFollow,
fetchHassioLogsLegacy,
getHassioLogDownloadLinesUrl,
getHassioLogDownloadUrl,
} from "../../../data/hassio/supervisor";
Expand Down Expand Up @@ -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);
}
Expand Down
9 changes: 7 additions & 2 deletions src/state/connection-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,13 @@ export const connectionMixin = <T extends Constructor<HassBaseEl>>(
},
callApi: async (method, path, parameters, headers) =>
hassCallApi(auth, method, path, parameters, headers),
callApiRaw: async (method, path, parameters, headers, signal) =>
hassCallApiRaw(auth, method, path, parameters, headers, signal),
callApiRaw: async (
method,
path,
parameters,
headers,
signal // introduced in 2024.11
) => hassCallApiRaw(auth, method, path, parameters, headers, signal),
fetchWithAuth: (
path: string,
init: Parameters<typeof fetchWithAuth>[2]
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down

0 comments on commit 6f4dd31

Please sign in to comment.