diff --git a/wecker.sh b/wecker.sh index fba85b0..3fa0505 100755 --- a/wecker.sh +++ b/wecker.sh @@ -10,7 +10,7 @@ # Customizable settings: # - Adjust ioBroker brightness and color temperature commands set -e # Stop the script on errors -#set -x # Enable debugging # Uncomment for a more detailed log +set -x # Enable debugging # Uncomment for a more detailed log # Debug DEBUG=false SSH_EXECUTED=false # Variable to track SSH command status @@ -34,10 +34,10 @@ red="ff0000" green="00ff00" blue="0000ff" -iobroker state set zigbee.0.04cd15fffee03198.state false && sleep 2 && -iobroker state set zigbee.0.04cd15fffee03198.brightness 1 && sleep 2 && -iobroker state set zigbee.0.04cd15fffee03198.colortemp 1600 && sleep 2 && -iobroker state set zigbee.0.04cd15fffee03198.state true && sleep 2 && +iobroker state set zigbee.0.04cd15fffee03198.state false +iobroker state set zigbee.0.04cd15fffee03198.brightness 1 +iobroker state set zigbee.0.04cd15fffee03198.colortemp 1600 +iobroker state set zigbee.0.04cd15fffee03198.state true set_brightness() { local brightness_value=$1 @@ -63,7 +63,7 @@ set_color() { check_ip() { mac_address="e4:cd:d1" # Replace this with the MAC address attempts=10 - interval=2 + interval=5 for ((i = 1; i <= $attempts; i++)); do A72_ip=$(arp-scan -r 3 -v --localnet | grep "$mac_address" | awk '{print $1}') @@ -85,7 +85,7 @@ check_ip() { # All attempts unsuccessful echo "The target could not be reached after $attempts attempts." - iobroker state set zigbee.0.04cd15fffee03198.state false || true + iobroker state set zigbee.0.04cd15fffee03198.state false return 1 # Error: IP address not found } @@ -100,6 +100,7 @@ check_external_light_status() { local light_status=$(iobroker state getValue zigbee.0.04cd15fffee03198.state) if [ "$light_status" == "false" ]; then echo "Light is off. Exiting the script." && date + echo $light_status exit fi } @@ -131,7 +132,7 @@ check_notification() { # Alarm turned off date && echo "Alarm turned off." echo $output - iobroker state set zigbee.0.04cd15fffee03198.state false || true + iobroker state set zigbee.0.04cd15fffee03198.state false return # Exit the function without terminating the entire script else # Phone unreachable @@ -144,7 +145,7 @@ 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 || true + iobroker state set zigbee.0.04cd15fffee03198.state false return } @@ -179,7 +180,7 @@ echo "Reached final colortemp: $((start_colortemp - colortemp_step * steps)) fro sleep_duration=$((duration_seconds / steps)) # Gradual adjustment of brightness and color temperature -for ((i = 0; i <= $steps; i++)); do +for ((i = 1; i <= $steps; i++)); do current_brightness=$(printf "%.0f" $(bc <<< "$start_brightness + ($brightness_step * $i)")) current_colortemp=$(printf "%.0f" $(bc <<< "$start_colortemp - ($colortemp_step * $i)"))