Show current consumption chart

This commit is contained in:
2024-09-26 22:37:43 +02:00
parent 2e72634abf
commit 903f1fa8ce
4 changed files with 77 additions and 51 deletions

View File

@ -2,9 +2,9 @@ import { APIClient } from "./ApiClient";
export class EnergyApi {
/**
* Get current house consumption
* Get current grid consumption
*/
static async CurrConsumption(): Promise<number> {
static async GridConsumption(): Promise<number> {
const data = await APIClient.exec({
method: "GET",
uri: "/energy/curr_consumption",
@ -12,6 +12,18 @@ export class EnergyApi {
return data.data.consumption;
}
/**
* Get grid consumption history
*/
static async GridConsumptionHistory(): Promise<number[]> {
return (
await APIClient.exec({
method: "GET",
uri: "/energy/curr_consumption/history",
})
).data;
}
/**
* Get current cached consumption
*/
@ -22,4 +34,16 @@ export class EnergyApi {
});
return data.data.consumption;
}
/**
* Get relays consumption history
*/
static async RelaysConsumptionHistory(): Promise<number[]> {
return (
await APIClient.exec({
method: "GET",
uri: "/energy/relays_consumption/history",
})
).data;
}
}