Update wecker.sh script
- Adjusted the 'check_notification' function to execute the SSH command within a timeout.
- Modified the logging of wecker.sh start and end times for better monitoring.
Changes:
- Modified line 41 in wecker.sh to execute the SSH command within a timeout for 'check_notification' function
from:
output= [0] "Beenden" -> PendingIntent{cb58c43: PendingIntentRecord{9bf5dfe com.urbandroid.sleep startActivity (allowlist: 27215bc:+30s0ms/0/NOTIFICATION_SERVICE/NotificationManagerService)}}
to:
output=Timeout
- Added date and echo statements to log the start and end times in 'check_notification' function.
- Moved the 'ssh root@ '/data/scripts/morning-alarm.sh'' line to the end of the script to trigger the morning alarm.
Author: Michael Haider
Date: 17.12.2023
This commit is contained in:
parent
b114ce5fdc
commit
b95e0627dc
23
wecker.sh
23
wecker.sh
@ -42,7 +42,7 @@ set_color() {
|
||||
# Die IP-Adresse von Lisas-IPhone holen.
|
||||
check_ip() {
|
||||
mac_address="e4:cd:d1" # Ersetze dies # Die IP-Adresse von Lisas-IPhone holen.
|
||||
A72_ip=$(arp -a | grep "$mac_address" | awk '{print $2}' | sed 's/[()]//g')
|
||||
A72_ip=$(arp -a | grep "$mac_address" | awk '{print $2}' | sed 's/[()]//g')
|
||||
echo "$A72_ip"
|
||||
}
|
||||
|
||||
@ -58,19 +58,22 @@ first_brightness_change=true
|
||||
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."
|
||||
echo "Licht ist aus. Das Skript wird beendet." && date
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
# Überprüfung, ob der Wecker am Handy beendet wurde.
|
||||
# Checkt, ob der Wecker am Handy ausgeschaltet wurde.
|
||||
check_notification() {
|
||||
output=$(ssh a72 'dumpsys notification | grep "Beenden"')
|
||||
# Führe den SSH-Befehl innerhalb eines Timeout aus
|
||||
output=$(timeout 5s ssh -i /root/.ssh/A72 root@$A72_ip 'dumpsys activity processes | grep com.urbandroid.sleep' || echo "Timeout")
|
||||
|
||||
if [[ $output == *"[1]"* && $output == *"Beenden"* && $output == *"com.urbandroid.sleep"* ]]; then
|
||||
echo "Wecker noch nicht beendet."
|
||||
# Überprüfe, ob das Ergebnis nicht "Timeout" ist und den Wecker enthält
|
||||
if [[ $output != *"Timeout"* && $output == *"com.urbandroid.sleep/.alarmclock.AlarmKlaxon"* ]]; then
|
||||
date && echo "Wecker noch nicht beendet."
|
||||
else
|
||||
echo "Wecker beendet."
|
||||
date && echo "Wecker beendet."
|
||||
echo $output
|
||||
iobroker state set zigbee.0.04cd15fffee03198.state false
|
||||
exit
|
||||
fi
|
||||
@ -86,7 +89,7 @@ end_colortemp=0 # Kaltweiß (0)
|
||||
|
||||
|
||||
# Dauer der Anpassung in Sekunden (15 Minuten)
|
||||
duration_seconds=900
|
||||
duration_seconds=899
|
||||
|
||||
# Alle 30 Sekinden Änderung
|
||||
steps=30 # Alle 30 Sekunden einen Schritt
|
||||
@ -118,6 +121,8 @@ colortemp_step=$(bc <<< "$start_colortemp / $steps")
|
||||
sleep 30 # Änderungen alle 30 Sekunden
|
||||
done
|
||||
|
||||
ssh root@$A72_ip '/data/scripts/morning-alarm.sh'
|
||||
|
||||
# Farben ändern für mehr konzentration
|
||||
while :; do
|
||||
if [ "$first_brightness_change" = false ]; then
|
||||
@ -126,8 +131,6 @@ while :; do
|
||||
first_brightness_change=false
|
||||
fi
|
||||
|
||||
show_status $i "$current_brightness" "$current_colortemp"
|
||||
|
||||
set_color "$gruen"
|
||||
sleep 2
|
||||
set_color "$blau"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user