Update wecker.sh script
The wecker.sh script has been modified with the following changes: 1. Modified the 'check_notification()' function to exit the entire script using 'exit' instead of 'return' when the alarm is turned off or the phone is unreachable. This ensures the script terminates completely in these scenarios. 2. Adjusted the 'sleep_duration' calculation to subtract 3 seconds, enhancing the script's timing accuracy during gradual adjustment of brightness and color temperature. 3. Changed the ssh command in the loop to use 'nohup' and 'tee' for logging the morning-alarm.sh output to a file named 'morning-alarm.log'. This modification improves logging and captures script output for later analysis. These changes enhance the wecker.sh script by improving script termination logic, adjusting sleep duration for better timing accuracy, and enhancing logging during the execution of the morning-alarm.sh script.
This commit is contained in:
parent
62243df8ac
commit
45955451d7
12
wecker.sh
12
wecker.sh
@ -136,7 +136,7 @@ check_notification() {
|
||||
echo $output
|
||||
iobroker state set zigbee.0.04cd15fffee03198.state false
|
||||
/root/iobroker_scripts/general/generate_text.sh > /dev/null
|
||||
return # Exit the function without terminating the entire script
|
||||
exit # Beende das Skript, wenn der Alarm ausgeschaltet wurde
|
||||
else
|
||||
# Phone unreachable
|
||||
echo "Phone unreachable. Waiting $wait_time seconds before the next attempt."
|
||||
@ -147,9 +147,9 @@ check_notification() {
|
||||
|
||||
# Phone could not be reached.
|
||||
echo "Phone could not be reached after $max_attempts attempts."
|
||||
date && echo "Alarm turned off."
|
||||
iobroker state set zigbee.0.04cd15fffee03198.state false
|
||||
return
|
||||
date && echo "Alarm turned off."
|
||||
iobroker state set zigbee.0.04cd15fffee03198.state false
|
||||
exit # Beende das Skript, wenn das Telefon nicht erreicht werden konnte
|
||||
}
|
||||
|
||||
# Define starting values for brightness and color temperature
|
||||
@ -181,7 +181,7 @@ echo "Reached final brightness: $((brightness_step * steps + start_brightness))
|
||||
colortemp_step=$(( start_colortemp / steps ))
|
||||
echo "Color temperature difference per step: $colortemp_step"
|
||||
echo "Reached final colortemp: $((start_colortemp - colortemp_step * steps)) from $end_colortemp"
|
||||
sleep_duration=$((duration_seconds / steps))
|
||||
sleep_duration=$((duration_seconds / steps - 3))
|
||||
|
||||
# Gradual adjustment of brightness and color temperature
|
||||
for ((i = 1; i <= $steps; i++)); do
|
||||
@ -241,7 +241,7 @@ if [ $current_brightness -eq $end_brightness ] && [ $current_colortemp -eq $end_
|
||||
echo "DEBUG: Alternative ssh command."
|
||||
ssh_command "cmd media_session volume scripts/--set 5 --stream 9 && /data/data/com.termux/files/usr/bin/mpv /data/scripts/your-new-morning-alarm.ogg"
|
||||
else
|
||||
ssh_command "/data/scripts/morning-alarm.sh > /dev/null"
|
||||
nohup ssh a72 '/data/scripts/morning-alarm.sh 2>&1 | /data/data/com.termux/files/usr/bin/tee /data/scripts/morning-alarm.log'
|
||||
fi
|
||||
else
|
||||
check_external_light_status
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user