fix fetchEntityState

This commit is contained in:
Aaron Carson 2024-09-18 14:57:14 +01:00
parent 9f4e784f62
commit aca8c93a0b

View file

@ -5,14 +5,15 @@ const HASS_LLAT = Keychain.get("hass_llat");
const HASS_API_URL = "https://hass-new.adhd.energy/api";
async function fetchStates() {
var wordle_req = new Request(HASS_API_URL + "/states/sensor.aaron_wordle")
wordle_req.headers = {
async function fetchEntityState(entity_id) {
if (entity_id === undefined) {
return {"error":"entity_id is missing"}
}
let hass_req = new Request(HASS_API_URL + "/states/" + entity_id)
hass_req.headers = {
"Authorization": "Bearer " + HASS_LLAT,
"Content-Type": "application/json"
}
console.log(wordle_req)
return await wordle_req.loadJSON();
return await hass_req.loadJSON();
}
console.log(fetchStates().response)