From 96e857a4cfc50b745d5b75916bd156bfbdf709f8 Mon Sep 17 00:00:00 2001 From: Ratatoskr Date: Sat, 25 Nov 2023 09:58:53 +0100 Subject: [PATCH] Commit: Fix check_notification condition and add check_external_light_status 1. Added a new function `check_external_light_status` to check if the light is turned off externally. 2. Modified the condition in the `check_notification` function to correctly check if the notification contains "[1]" and the specified strings. 3. Corrected the assignment statement inside the `while` loop. Changed `first_brightness_cmason.nvimhange=false` to `first_brightness_change=false`. --- wecker.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/wecker.sh b/wecker.sh index e57ea7e..67fccb0 100755 --- a/wecker.sh +++ b/wecker.sh @@ -55,11 +55,20 @@ check_ip first_brightness_change=true # Überprüfung, ob das Licht extern ausgeschaltet wurde +check_external_light_status() { + local light_status=$(iobroker state getValue zigbee.0.04cd15fffee03198.state) + if [ "$light_status" == "false" ]; then + echo "Licht ist aus. Das Skript wird beendet." + exit + fi +} + +# Überprüfung, ob der Wecker am Handy beendet wurde. check_notification() { local output output=$(ssh a72 'dumpsys notification | grep "Beenden"') - if [[ $output == *"Beenden"* && $output == *"com.urbandroid.sleep"* ]]; then + if [[ $output == "[1]"* && output == *"Beenden"* && $output == *"com.urbandroid.sleep"* ]]; then echo "Wecker noch nicht beendet." else echo "Wecker beendet." @@ -115,7 +124,7 @@ while :; do if [ "$first_brightness_change" = false ]; then check_external_light_status else - first_brightness_cmason.nvimhange=false + first_brightness_change=false fi show_status $i "$current_brightness" "$current_colortemp"