[Back] Add hass status

This commit is contained in:
SebClem 2024-04-18 13:41:52 +02:00
parent b87feaa8d9
commit 8db47b5687
Signed by: sebclem
GPG Key ID: 5A4308F6A359EA50
3 changed files with 18 additions and 1 deletions

View File

@ -24,6 +24,7 @@ import type {
SupervisorResponse,
} from "../types/services/ha_os_response.js";
import { States, type Status } from "../types/status.js";
import { DateTime } from "luxon";
const pipeline = promisify(stream.pipeline);
@ -113,9 +114,17 @@ function getBackups(): Promise<Response<SupervisorResponse<BackupData>>> {
option
).then(
(result) => {
const status = statusTools.getStatus();
status.hass.ok = true;
status.hass.last_check = DateTime.now();
statusTools.setStatus(status);
return result;
},
(error) => {
const status = statusTools.getStatus();
status.hass.ok = false;
status.hass.last_check = DateTime.now();
statusTools.setStatus(status);
messageManager.error("Fail to fetch Hassio backups", error?.message);
return Promise.reject(error);
}

View File

@ -12,6 +12,10 @@ let status: Status = {
folder_created: false,
last_check: DateTime.now(),
},
hass: {
ok: false,
last_check: DateTime.now(),
},
};
export function init() {
@ -31,4 +35,4 @@ export function setStatus(new_state: Status) {
status = new_state;
publish_state(status);
}
}
}

View File

@ -25,4 +25,8 @@ export interface Status {
folder_created: boolean;
last_check: DateTime;
};
hass: {
ok: boolean;
last_check: DateTime;
};
}