rewrite typeysation
This commit is contained in:
@@ -1,14 +1,8 @@
|
||||
import type { HomeAssistantEntity } from "@dpu/shared";
|
||||
import { BaseClient } from "@dpu/shared/dist/fastify";
|
||||
import { printNetworkError } from "@dpu/shared/dist/logger.js";
|
||||
import type { AxiosInstance } from "axios";
|
||||
|
||||
export class HomeAssistantClient {
|
||||
private axiosInstance: AxiosInstance;
|
||||
|
||||
constructor(axiosInstance: AxiosInstance) {
|
||||
this.axiosInstance = axiosInstance;
|
||||
}
|
||||
|
||||
export class HomeAssistantClient extends BaseClient {
|
||||
async getEntityStates(entityIds: string[]): Promise<HomeAssistantEntity[]> {
|
||||
try {
|
||||
const promises = entityIds.map((id) => this.getEntityState(id));
|
||||
@@ -21,7 +15,7 @@ export class HomeAssistantClient {
|
||||
|
||||
async getEntityState(entityId: string): Promise<HomeAssistantEntity> {
|
||||
try {
|
||||
const response = await this.axiosInstance.get<HomeAssistantEntity>(
|
||||
const response = await this.getAxios().get<HomeAssistantEntity>(
|
||||
`states/${entityId}`,
|
||||
);
|
||||
return response.data;
|
||||
@@ -33,7 +27,7 @@ export class HomeAssistantClient {
|
||||
|
||||
async triggerWebhook(webhookId: string): Promise<unknown> {
|
||||
try {
|
||||
const response = await this.axiosInstance.post<HomeAssistantEntity>(
|
||||
const response = await this.getAxios().post<HomeAssistantEntity>(
|
||||
`webhook/${webhookId}`,
|
||||
);
|
||||
return response.data;
|
||||
|
||||
Reference in New Issue
Block a user