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`.
This commit is contained in:
Ratatoskr 2023-11-25 09:58:53 +01:00
parent fcc070e03d
commit 96e857a4cf
Signed by: Ratatoskr
GPG Key ID: 28B77439A6D78F4E

View File

@ -55,11 +55,20 @@ check_ip
first_brightness_change=true first_brightness_change=true
# Überprüfung, ob das Licht extern ausgeschaltet wurde # Ü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() { check_notification() {
local output local output
output=$(ssh a72 'dumpsys notification | grep "Beenden"') 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." echo "Wecker noch nicht beendet."
else else
echo "Wecker beendet." echo "Wecker beendet."
@ -115,7 +124,7 @@ while :; do
if [ "$first_brightness_change" = false ]; then if [ "$first_brightness_change" = false ]; then
check_external_light_status check_external_light_status
else else
first_brightness_cmason.nvimhange=false first_brightness_change=false
fi fi
show_status $i "$current_brightness" "$current_colortemp" show_status $i "$current_brightness" "$current_colortemp"