From dde161ae618f45970345aa2e41f352b1b93266dd Mon Sep 17 00:00:00 2001 From: Ratatoskr Date: Tue, 26 Dec 2023 17:01:34 +0100 Subject: [PATCH] Improve IP resolution and add retry mechanism - 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. --- A72_alarm_getter.sh | 2 +- wecker.sh | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/A72_alarm_getter.sh b/A72_alarm_getter.sh index a7c7c7f..8c69a6c 100755 --- a/A72_alarm_getter.sh +++ b/A72_alarm_getter.sh @@ -42,7 +42,7 @@ delete_expired_at_jobs # Die IP-Adresse von Lisas-IPhone holen und Ping-Test durchführen check_ip() { mac_address="e4:cd:d1" # Ersetze dies durch die MAC-Adresse - A72_ip=$(arp-scan --localnet | grep "$mac_address" | awk '{print $1}') + A72_ip=$(arp-scan -r 5 -v --localnet | grep "$mac_address" | awk '{print $1}') if [ -z "$A72_ip" ]; then echo "IP nicht gefunden. Ziel ist nicht erreichbar." diff --git a/wecker.sh b/wecker.sh index 73a0feb..6656be9 100755 --- a/wecker.sh +++ b/wecker.sh @@ -27,6 +27,7 @@ set_brightness() { iobroker state set zigbee.0.04cd15fffee03198.brightness "$brightness_value" } + set_colortemp() { local colortemp_value=$1 # Ersetze 'zigbee.0.04cd15fffee03198.colortemp' durch die tatsächliche ioBroker-Adresse für die Farbtemperatur @@ -42,11 +43,11 @@ set_color() { # Die IP-Adresse von Lisas-IPhone holen und Ping-Test durchführen check_ip() { mac_address="e4:cd:d1" # Ersetze dies durch die MAC-Adresse - attempts=20 - interval=10 + attempts=10 + interval=5 - for ((i = 1; i <= $attempts; i++)); do - A72_ip=$(arp-scan --localnet | grep "$mac_address" | awk '{print $1}') + or ((i = 1; i <= $attempts; i++)); do + A72_ip=$(arp-scan -r 5 -v --localnet | grep "$mac_address" | awk '{print $1}') if [ -n "$A72_ip" ]; then echo "Gefundene IP: $A72_ip"