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";
|
||||
|
||||
|
||||
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)
|
||||
Loading…
Reference in a new issue