- Add an echo statement to output the current notification information when the alarm is turned off.
- Call 'generate_text.sh' script from '/root/iobroker_scripts/general/' when the alarm is turned off, providing a visual notification update.
- Remove the call to 'generate_text.sh' when the alarm is dismissed, as it is now handled when the alarm is turned off.
- Replace HTML file creation with Markdown content generation for improved simplicity and readability.
- Construct Markdown content with a header, table, and row entries based on the generated text components.
- Introduce a curl_command variable to construct and echo the curl command for sending a notification to A72.
- Display the constructed Markdown content for debugging purposes.
- Transfer text files to A72's sdcard instead of the scripts directory.
- Start generate_mp3.sh on A72 using nohup and ssh.
- Adjust comments and remove unnecessary HTML file display section.
- Overall, enhance the script structure, content creation, and notification handling in generate_text.sh.
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.
- Commented out 'set -e' and 'set -x' to prevent stopping the script on errors and disable debugging by default.
- Introduced functions set_brightness, set_colortemp, and set_color for better code organization.
- Modified brightness and color temperature commands to use the new functions.
Made the following changes to the wecker.sh script:
- Adjusted comments and translated the comments and script messages into English for better clarity.
- Introduced error handling for SSH commands, Bluetooth operations, and volume adjustments to ensure the script exits gracefully in case of failures.
- Updated variable names for consistency and improved overall readability of the script.
- Removed unnecessary debug-related code and streamlined the script structure.
- Addressed formatting issues for better code presentation.
Adjust the SSH command in the wecker.sh script for better readability and functionality. Instead of 'cmd media_session volume --set 5 --stream 9', use the more descriptive 'cmd media_session volume scripts/--set 5 --stream 9'. Additionally, update the path for the mpv command to use '/data/scripts/your-new-morning-alarm.ogg'. This change ensures consistency and clarity in the script.
Changes made:
- Replace 'cmd media_session volume --set 5 --stream 9' with 'cmd media_session volume scripts/--set 5 --stream 9'
- Update the path for mpv command to '/data/scripts/your-new-morning-alarm.ogg'
- Enabled debugging mode to provide a more detailed log when needed.
- Modified the interval in the check_ip function to 5 seconds for better accuracy in IP retrieval attempts.
- Refactored the sleep_duration calculation to ensure it accurately reflects the intended duration between adjustments.
- Adjusted the loop in gradual adjustment to start from 1, ensuring the initial values are set correctly.
- Replaced multiple consecutive '&& sleep' statements with separate lines for improved readability.
- Simplified the error handling in check_ip and check_notification functions for clarity.
- Removed unnecessary '|| true' statements in error handling.
- Added echo statements to print the light status when it is off in check_external_light_status.
- Improved comments for better script understanding.
These changes enhance the script's execution, improve debugging capabilities, and make the code more readable and maintainable.
- Simplified calculation of brightness_step and colortemp_step for better readability.
- Corrected the calculation of reached final values for brightness and color temperature.
- Introduced sleep_duration variable for improved flexibility in sleep intervals.
- Adjusted the loop to start from 0 to correctly set the initial values.
- Added a comment to clarify the purpose of the loop and its iteration.
- Set the current_brightness and current_colortemp directly to the end values after the loop, ensuring they reach the intended final values.
- Moved the sleep_duration calculation inside the loop for consistency.
This refactoring enhances the script's clarity and ensures accurate calculation of brightness and color temperature steps during the gradual adjustment process. The changes also include improvements in sleep duration handling.
- Updated comments for better clarity and documentation
- Introduced a DEBUG variable to toggle debugging information
- Utilized set -e to stop the script on errors for better error handling
- Corrected the script flow to ensure proper execution of color changes
- Introduced a new ssh_command function for executing SSH commands
- Improved check_ip function for finding the IP address more reliably
- Added DEBUG checks to bypass certain functions for debugging purposes
- Fixed issues with sleep intervals during script execution
- Improved logging by adding echo statements for important steps
- Adjusted variable names for better readability
- Removed unnecessary comments and debug statements
- Added set -e for better error handling
- Introduced command-line option -d for enabling DEBUG mode
- Improved formatting and indentation for better code readability
- Updated comments for better clarity and documentation
- Introduced a DEBUG variable to toggle debugging information
- Utilized set -e to stop the script on errors for better error handling
- Corrected the script flow to ensure proper execution of color changes
- Introduced a new ssh_command function for executing SSH commands
- Improved check_ip function for finding the IP address more reliably
- Added DEBUG checks to bypass certain functions for debugging purposes
- Fixed issues with sleep intervals during script execution
- Improved logging by adding echo statements for important steps
- Adjusted variable names for better readability
- Removed unnecessary comments and debug statements
- Added set -e for better error handling
- Introduced command-line option -d for enabling DEBUG mode
- Improved formatting and indentation for better code readability
- Reordered the iobroker state set commands to set colortemp at the end for better consistency.
- Removed unnecessary ping test in the check_ip function.
- Cleaned up the check_notification function, removed unnecessary echo statements.
- Adjusted the sleep time in the check_notification function to 5 seconds.
- Updated comments and removed unnecessary comments for clarity.
- Minor formatting improvements for better readability.
- Added missing code in the color change loop, now it changes colors as intended. (hopefully)
- Removed redundant comments at the end of the script.
These changes enhance the script's clarity, remove unnecessary code, and ensure proper functionality.
- Modified the IP resolution process to allow for multiple attempts with a specified interval.
- Added a retry mechanism to check the IP address multiple times before considering it unsuccessful.
- If the target IP cannot be found after the specified number of attempts, an error message is displayed.
- Updated the SSH command to run the alarm script in the background.
- Modified the IP resolution process to allow for multiple attempts with a specified interval.
- Added a retry mechanism to check the IP address multiple times before considering it unsuccessful.
- If the target IP cannot be found after the specified number of attempts, an error message is displayed.
- Updated the SSH command to run the alarm script in the background.
- Combined IP retrieval and ping test into a single function 'check_ip'.
- Improved error handling for better script robustness.
- Removed unnecessary commented-out code and added comments for clarity.
- Ensured consistency in indentation and formatting.
Author: Michael, Haider
Date: 22.12.2023
Modified delete_expired_at_jobs function to retain only the next 'at'-job and delete all upcoming jobs. This ensures that only the immediate 'at'-job remains scheduled.
- Geänderte Mac-Adresse für die Funktion check_ip.
- Verwende 'arp-scan' für die IP-Ermittlung.
- Verbesserte Ausgabe und Wartezeit in der Funktion check_notification.
- Start des Alarm-Scripts auf dem Handy mit protokollierter Ausgabe.
- Geänderte Mac-Adresse für Lisas iPhone in check_ip-Funktion.
- Verbesserte Ausgabe und Wartezeit in der check_notification-Funktion.
- Angepasste Schritte und Dauer für die Helligkeits- und Farbtemperaturanpassung.
- Start des Alarm-Scripts auf dem Handy ohne protokollierte Ausgabe.
- Geänderte Mac-Adresse für Lisas iPhone in check_ip-Funktion.
- Verbesserte Ausgabe in der check_notification-Funktion.
- Angepasste Schritte und Dauer für die Helligkeits- und Farbtemperaturanpassung.
- Start des Alarm-Scripts auf dem Handy mit protokollierter Ausgabe.
- 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
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`.