From d0692fc744d6f6d9b6265774dc60df38eea826d6 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Fri, 18 Oct 2024 08:47:21 +0200 Subject: [PATCH] display if hallway light is on --- run_linux_arm64.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/run_linux_arm64.go b/run_linux_arm64.go index 19714b1..3e88939 100644 --- a/run_linux_arm64.go +++ b/run_linux_arm64.go @@ -125,13 +125,25 @@ func shouldDisplay(ctx context.Context, hassClient *home_assistant.Client) bool return true } + log.Printf("found dayNight=%v\n", dayNight) + + hallLights, err := hassClient.GetState(ctx, "light.couloir") + if err != nil { + log.Printf("error getting hall lights: %v ; displaying anyway\n", err) + return true + } + + log.Printf("found hallLights=%v\n", hallLights) + presentAway, err := hassClient.GetState(ctx, "input_select.house_present_away") if err != nil { log.Printf("error getting day night: %v ; displaying anyway\n", err) return true } - res := dayNight == "day" && presentAway == "present" + log.Printf("found presentAway=%v\n", presentAway) + + res := (hallLights == "on" || dayNight == "day") && presentAway == "present" log.Printf("shouldDisplay: %v\n", res) return res }