43 lines
994 B
TypeScript
43 lines
994 B
TypeScript
const token = import.meta.env.VITE_HA_TOKEN;
|
|
|
|
async function fetchTentHumidity() {
|
|
if (!token) {
|
|
console.error("HA token not found");
|
|
|
|
return;
|
|
}
|
|
|
|
const url = `https://home.rivercry.com/api/states/sensor.third_reality_inc_3rths0224z_luftfeuchtigkeit_2`;
|
|
const response = await fetch(url, {
|
|
method: "GET",
|
|
headers: {
|
|
Authorization: `Bearer ${token}`,
|
|
},
|
|
});
|
|
const data = await response.json();
|
|
|
|
return data.state;
|
|
}
|
|
|
|
async function fetchTentTemperature() {
|
|
if (!token) {
|
|
console.error("HA token not found");
|
|
|
|
return;
|
|
}
|
|
|
|
const url = `https://home.rivercry.com/api/states/sensor.third_reality_inc_3rths0224z_temperatur_2`;
|
|
const response = await fetch(url, {
|
|
method: "GET",
|
|
headers: {
|
|
Authorization: `Bearer ${token}`,
|
|
},
|
|
});
|
|
|
|
const data = await response.json();
|
|
|
|
return data.state;
|
|
}
|
|
|
|
export { fetchTentHumidity, fetchTentTemperature };
|