diff --git a/src/util/api-homeassistant.ts b/src/util/api-homeassistant.ts index fc7cf78..318944d 100644 --- a/src/util/api-homeassistant.ts +++ b/src/util/api-homeassistant.ts @@ -1,6 +1,6 @@ import axios from "axios"; import { Config } from "../config/config.js"; -import { logWarning } from "./logger.js"; +import { logInfo, logWarning } from "./logger.js"; type HomeAssistantEntity = { entity_id: string; @@ -78,12 +78,14 @@ export async function getTemperatures(): Promise> { } // UTILITY - async function sendRequestToHomeAssistantStates( entity_id: string, ): Promise { + const url = `${Config.homeassistant.api_url}states/"${entity_id}` + logInfo(`sending request to ${url}`) + const response = await axios.get( - `${Config.homeassistant.api_url}states/"${entity_id}`, + url, { headers: { Authorization: `Bearer ${Config.homeassistant.api_token}`, @@ -97,14 +99,10 @@ async function sendRequestToHomeAssistantStates( async function sendRequestToHomeAssistantWebhook( webhook_id: string, ): Promise { - const response = await axios.post( - `${Config.homeassistant.api_url}webhook/"${webhook_id}`, - { - headers: { - Authorization: `Bearer ${Config.homeassistant.api_token}`, - }, - }, - ); + const url = `${Config.homeassistant.api_url}webhook/"${webhook_id}` + logInfo(`sending request to ${url}`) + + const response = await axios.post(url); return response.data; }