Display live and cached consumption on dashboard
This commit is contained in:
26
central_frontend/src/api/EnergyApi.ts
Normal file
26
central_frontend/src/api/EnergyApi.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import { Api } from "@mui/icons-material";
|
||||
import { APIClient } from "./ApiClient";
|
||||
|
||||
export class EnergyApi {
|
||||
/**
|
||||
* Get current house consumption
|
||||
*/
|
||||
static async CurrConsumption(): Promise<number> {
|
||||
const data = await APIClient.exec({
|
||||
method: "GET",
|
||||
uri: "/energy/curr_consumption",
|
||||
});
|
||||
return data.data.consumption;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current cached consumption
|
||||
*/
|
||||
static async CachedConsumption(): Promise<number> {
|
||||
const data = await APIClient.exec({
|
||||
method: "GET",
|
||||
uri: "/energy/cached_consumption",
|
||||
});
|
||||
return data.data.consumption;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user