Sauna: Add update timestamp to sauna api

This commit is contained in:
Thomas Klaehn
2023-02-21 08:06:05 +01:00
parent 7575193024
commit 84d84b4313
2 changed files with 20 additions and 6 deletions

View File

@@ -2,10 +2,12 @@
import { onMount } from "../../../node_modules/svelte/internal";
import icon from "$lib/images/sauna.svg"
let backend_url = "https://home.blackfinn.de/sauna/sample";
let backend_url = "https://home.blackfinn.de/api/sauna";
let temperature_value = 0.0
let temperature_unit = "°C"
let time = "00:00:00";
let updated = false;
function get_temperature() {
fetch(backend_url)
@@ -13,6 +15,8 @@
.then(data => {
temperature_unit = data.unit
temperature_value = data.value
time = data.time.slice(11, 19)
updated = JSON.parse(data.valid);
}).catch(error => {
console.log(error);
return [];
@@ -38,5 +42,8 @@
<figure>
<img src={icon} alt="Sauna" width=150/>
</figure>
<h1>{temperature_value} {temperature_unit}</h1>
{#if updated}
<div>{time} Uhr:</div>
<h1>{temperature_value} {temperature_unit}</h1>
{/if}
</section>