fix fetchEntityState
This commit is contained in:
parent
9f4e784f62
commit
aca8c93a0b
1 changed files with 7 additions and 6 deletions
|
|
@ -5,14 +5,15 @@ const HASS_LLAT = Keychain.get("hass_llat");
|
||||||
const HASS_API_URL = "https://hass-new.adhd.energy/api";
|
const HASS_API_URL = "https://hass-new.adhd.energy/api";
|
||||||
|
|
||||||
|
|
||||||
async function fetchStates() {
|
async function fetchEntityState(entity_id) {
|
||||||
var wordle_req = new Request(HASS_API_URL + "/states/sensor.aaron_wordle")
|
if (entity_id === undefined) {
|
||||||
wordle_req.headers = {
|
return {"error":"entity_id is missing"}
|
||||||
|
}
|
||||||
|
let hass_req = new Request(HASS_API_URL + "/states/" + entity_id)
|
||||||
|
hass_req.headers = {
|
||||||
"Authorization": "Bearer " + HASS_LLAT,
|
"Authorization": "Bearer " + HASS_LLAT,
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
}
|
}
|
||||||
console.log(wordle_req)
|
return await hass_req.loadJSON();
|
||||||
return await wordle_req.loadJSON();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(fetchStates().response)
|
|
||||||
Loading…
Reference in a new issue