43 lines
871 B
Svelte
Raw Normal View History

2023-01-30 15:54:49 +01:00
<script>
import { onMount } from "../../../node_modules/svelte/internal";
2023-02-09 09:47:49 +01:00
import icon from "$lib/images/sauna.svg"
2023-01-30 15:54:49 +01:00
let backend_url = "https://home.blackfinn.de/sauna/sample";
let temperature_value = 0.0
let temperature_unit = "°C"
function get_temperature() {
fetch(backend_url)
.then(response => response.json())
.then(data => {
temperature_unit = data.unit
temperature_value = data.value
}).catch(error => {
console.log(error);
return [];
});
}
setInterval(() => {
get_temperature();
}, 1000)
onMount(async () => {
get_temperature();
});
</script>
<svelte:head>
<title>Sauna</title>
<meta name="description" content="Sauna"/>
</svelte:head>
<section id='content_id' class='content'>
2023-02-09 10:22:24 +01:00
<h1>Sauna</h1>
2023-01-30 15:54:49 +01:00
<figure>
<img src={icon} alt="Sauna" width=150/>
</figure>
2023-02-09 10:22:24 +01:00
<h1>{temperature_value} {temperature_unit}</h1>
2023-01-30 15:54:49 +01:00
</section>