From a9c72e4ebc7bc64f5bdbfb2f38760047ce63af60 Mon Sep 17 00:00:00 2001 From: Daniel Kluge Date: Tue, 1 Nov 2022 14:39:21 +0100 Subject: [PATCH] Better locations --- src/components/HAssOverview.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/HAssOverview.tsx b/src/components/HAssOverview.tsx index dd09dfb..b1bf7e2 100644 --- a/src/components/HAssOverview.tsx +++ b/src/components/HAssOverview.tsx @@ -27,13 +27,18 @@ const HomeAssistant = ({ hassUrl, token }: { hassUrl: string, token: string }) = const vicki = await fetchState("person.vicki") const nextbikes = await fetchState("sensor.nextbikes") + const location = (l: string|undefined) => { switch (l) { + case "home": return "Zuhause"; + case "not_home": return "Unterwegs"; + case undefined: + case "unknown": return "Unbekannt"; + default: return l; + } + } - console.log(daniel); - console.log(vicki); - console.log(nextbikes); setStates({ - daniel: daniel?.state === "home" ? "Zuhause" : "Unterwegs", - vicki: vicki?.state === "home" ? "Zuhause" : "Unterwegs", + daniel: location(daniel?.state), + vicki: location(vicki?.state), nextbikes: nextbikes?.state }); }