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.
This commit is contained in:
Ratatoskr 2024-02-09 08:37:27 +01:00
parent 987469140e
commit 5224de0d20
Signed by: Ratatoskr
GPG Key ID: 28B77439A6D78F4E

View File

@ -34,11 +34,6 @@ done
# Adjust brightness and color temperature in ioBroker # 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.state false
iobroker state set zigbee.0.04cd15fffee03198.brightness 1 iobroker state set zigbee.0.04cd15fffee03198.brightness 1
iobroker state set zigbee.0.04cd15fffee03198.colortemp 1600 iobroker state set zigbee.0.04cd15fffee03198.colortemp 1600
@ -58,12 +53,6 @@ set_colortemp() {
echo "Current Colortemp: $colortemp_value" 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) # Get the IP address of Lisa's iPhone (without ping test)
check_ip() { check_ip() {
mac_address="e4:cd:d1" # Replace this with the MAC address mac_address="e4:cd:d1" # Replace this with the MAC address
@ -136,8 +125,9 @@ check_notification() {
# Alarm turned off # Alarm turned off
date && echo "Alarm turned off." date && echo "Alarm turned off."
echo "$output" 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 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 /root/iobroker_scripts/general/generate_text.sh # Call generate_text.sh script
exit # Exit the script when the alarm is turned off exit # Exit the script when the alarm is turned off
else else
@ -229,6 +219,8 @@ current_colortemp="$end_colortemp"
set_brightness "$end_brightness" set_brightness "$end_brightness"
set_colortemp "$end_colortemp" set_colortemp "$end_colortemp"
/root/iobroker_scripts/schlafzimmer/rgb.sh # Call the rgb.sh script
# Execute the check_ip function. # Execute the check_ip function.
check_ip check_ip
echo "$A72_ip" echo "$A72_ip"
@ -272,11 +264,6 @@ if [ $current_brightness -eq $end_brightness ] && [ $current_colortemp -eq $end_
fi fi
else else
check_external_light_status check_external_light_status
set_color "$green"
sleep 5
set_color "$red"
sleep 5
set_color "$blue"
check_notification #& check_notification #&
fi fi
if [ "$alarm_dismissed" = true ]; then if [ "$alarm_dismissed" = true ]; then