62 lines
1.3 KiB
TypeScript
62 lines
1.3 KiB
TypeScript
import { APIClient } from "./ApiClient";
|
|
|
|
export class EnergyApi {
|
|
/**
|
|
* Get current grid consumption
|
|
*/
|
|
static async GridConsumption(): Promise<number> {
|
|
const data = await APIClient.exec({
|
|
method: "GET",
|
|
uri: "/energy/curr_consumption",
|
|
});
|
|
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
|
|
*/
|
|
static async CachedConsumption(): Promise<number> {
|
|
const data = await APIClient.exec({
|
|
method: "GET",
|
|
uri: "/energy/cached_consumption",
|
|
});
|
|
return data.data.consumption;
|
|
}
|
|
|
|
/**
|
|
* Get relays consumption
|
|
*/
|
|
static async RelaysConsumption(): Promise<number> {
|
|
return (
|
|
await APIClient.exec({
|
|
method: "GET",
|
|
uri: "/energy/relays_consumption",
|
|
})
|
|
).data.consumption;
|
|
}
|
|
|
|
/**
|
|
* Get relays consumption history
|
|
*/
|
|
static async RelaysConsumptionHistory(): Promise<number[]> {
|
|
return (
|
|
await APIClient.exec({
|
|
method: "GET",
|
|
uri: "/energy/relays_consumption/history",
|
|
})
|
|
).data;
|
|
}
|
|
}
|