From 5224de0d20daed12971a762713c4241a9819bc31 Mon Sep 17 00:00:00 2001 From: Ratatoskr Date: Fri, 9 Feb 2024 08:37:27 +0100 Subject: [PATCH] Refactor alarm script and integrate RGB control This commit refactors the 'wecker.sh' script to enhance functionality and integrate RGB control. Changes: - Removed redundant color variables (red, green, blue) as RGB control is now managed by an external script. - Replaced 'set_color' function with a call to the 'rgb.sh' script for RGB control. - Introduced the use of 'pkill rgb.sh' to stop the RGB script when the alarm is turned off. - Added the execution of 'rgb.sh' at the end of the script for dynamic color cycling. - Enhanced code readability and removed unnecessary sleep commands for color cycling. - Modified the 'check_notification' function to ensure proper termination of the RGB script. Usage: 1. Ensure the 'rgb.sh' script is available in the specified path. 2. Run the 'wecker.sh' script to manage alarms with integrated RGB control. Note: Adjust the paths and dependencies based on your system configuration and requirements. --- wecker.sh | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/wecker.sh b/wecker.sh index 387376c..a0b8519 100755 --- a/wecker.sh +++ b/wecker.sh @@ -34,11 +34,6 @@ done # Adjust brightness and color temperature in ioBroker -# Colors -red="ff0000" -green="00ff00" -blue="0000ff" - iobroker state set zigbee.0.04cd15fffee03198.state false iobroker state set zigbee.0.04cd15fffee03198.brightness 1 iobroker state set zigbee.0.04cd15fffee03198.colortemp 1600 @@ -58,12 +53,6 @@ set_colortemp() { echo "Current Colortemp: $colortemp_value" } -set_color() { - local color_value=$1 - # Replace 'zigbee.0.04cd15fffee03198.color' with the actual ioBroker address for color - iobroker state set zigbee.0.04cd15fffee03198.color "$color_value" -} - # Get the IP address of Lisa's iPhone (without ping test) check_ip() { mac_address="e4:cd:d1" # Replace this with the MAC address @@ -136,8 +125,9 @@ check_notification() { # Alarm turned off date && echo "Alarm turned off." echo "$output" - ssh -i /root/.ssh/A72 root@$A72_ip 'killall mpv' + pkill rgb.sh # Kill the rgb.sh script iobroker state set zigbee.0.04cd15fffee03198.state false + ssh -i /root/.ssh/A72 root@$A72_ip 'killall mpv' /root/iobroker_scripts/general/generate_text.sh # Call generate_text.sh script exit # Exit the script when the alarm is turned off else @@ -229,6 +219,8 @@ current_colortemp="$end_colortemp" set_brightness "$end_brightness" set_colortemp "$end_colortemp" +/root/iobroker_scripts/schlafzimmer/rgb.sh # Call the rgb.sh script + # Execute the check_ip function. check_ip echo "$A72_ip" @@ -272,11 +264,6 @@ if [ $current_brightness -eq $end_brightness ] && [ $current_colortemp -eq $end_ fi else check_external_light_status - set_color "$green" - sleep 5 - set_color "$red" - sleep 5 - set_color "$blue" check_notification #& fi if [ "$alarm_dismissed" = true ]; then