Skip to content

Commit

Permalink
chore: clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
mdvanes committed May 13, 2024
1 parent c0a1b98 commit 86b4450
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ export const DockerStackList: FC = () => {
{data && (
<Stack spacing={0.5}>
{stacks1.map((stack) => (
<DockerStackItem stack={stack} />
<DockerStackItem key={stack.Id} stack={stack} />
))}
</Stack>
)}
</Grid>
<Grid item xs>
<Stack spacing={0.5}>
{stacks2.map((stack) => (
<DockerStackItem stack={stack} />
<DockerStackItem key={stack.Id} stack={stack} />
))}
{/* {!isOpen && <div>{containerDots}</div>} */}
</Stack>
Expand Down
1 change: 1 addition & 0 deletions apps/server/.env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
DOMOTICZ_URI=http://localhost:8080
DOMOTICZ_SENSORS=gas,counter,IDX1;temp1Inside,temp,IDX2
DOMOTICZ_ELECTRA_SENSOR=IDX3
STATUS_CMD=echo { \"field1\": \"field1value\", \"field2\": \"field2value\" }
STATUS_FIELD1=field1
STATUS_FIELD2=field2
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/energyusage/energyusage.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe("EnergyUsage Controller", () => {
]);
expect(mockGot).toBeCalledTimes(1);
expect(mockGot).toBeCalledWith(
"/api/history/period/2024-04-25T00:00:00Z?filter_entity_id=",
"/api/history/period/2024-04-24T00:00:00.000Z?end_time=2024-04-25T00:00:00.000Z&filter_entity_id=&minimal_response",
{
headers: {
Authorization: "Bearer ",
Expand Down
19 changes: 11 additions & 8 deletions apps/server/src/energyusage/energyusage.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ export class EnergyUsageController {
private readonly apiConfig: {
baseUrl: string;
sensors: SensorConfig[];
electraSensorId: string;
};
private readonly haApiConfig: {
baseUrl: string;
Expand All @@ -207,6 +208,8 @@ export class EnergyUsageController {
this.apiConfig = {
baseUrl,
sensors: strToConfigs(DOMOTICZ_SENSORS),
electraSensorId:
this.configService.get<string>("DOMOTICZ_ELECTRA_SENSOR") || "",
};
this.haApiConfig = {
baseUrl:
Expand Down Expand Up @@ -356,7 +359,6 @@ export class EnergyUsageController {
@Get("/electric/exports")
async getElectricExports(
@Request() req: AuthenticatedRequest
// @Query("range") range: "day" | "month"
): Promise<EnergyUsageGetElectricExportsResponse> {
this.logger.verbose(
`[${req.user.name}] GET to /api/energyusage/electric/exports`
Expand All @@ -367,15 +369,16 @@ export class EnergyUsageController {

this.logger.verbose(`[${req.user.name}] start get counter`);

// TODO make idx and actyear dynamic
const thisYear = new Date().getFullYear();
const lastYear = thisYear - 1;

const getUrl = (year: number) =>
`${this.apiConfig.baseUrl}/json.htm?type=graph&sensor=counter&idx=${this.apiConfig.electraSensorId}&range=year&actyear=${year}`;

const electricCounterResponseYear1: GetDomoticzUsePerDayResponse =
await got(
`${this.apiConfig.baseUrl}/json.htm?type=graph&sensor=counter&idx=2071&range=year&actyear=2023`
).json();
await got(getUrl(lastYear)).json();
const electricCounterResponseYear2: GetDomoticzUsePerDayResponse =
await got(
`${this.apiConfig.baseUrl}/json.htm?type=graph&sensor=counter&idx=2071&range=year&actyear=2024`
).json();
await got(getUrl(thisYear)).json();

// this.logger.verbose(
// `[${req.user.name}] end get counter`,
Expand Down

0 comments on commit 86b4450

Please sign in to comment.