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.
This commit is contained in:
Ratatoskr 2023-12-26 17:01:34 +01:00
parent 5f7abef59d
commit dde161ae61
Signed by: Ratatoskr
GPG Key ID: 28B77439A6D78F4E
2 changed files with 6 additions and 5 deletions

View File

@ -42,7 +42,7 @@ delete_expired_at_jobs
# Die IP-Adresse von Lisas-IPhone holen und Ping-Test durchführen # Die IP-Adresse von Lisas-IPhone holen und Ping-Test durchführen
check_ip() { check_ip() {
mac_address="e4:cd:d1" # Ersetze dies durch die MAC-Adresse 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 if [ -z "$A72_ip" ]; then
echo "IP nicht gefunden. Ziel ist nicht erreichbar." echo "IP nicht gefunden. Ziel ist nicht erreichbar."

View File

@ -27,6 +27,7 @@ set_brightness() {
iobroker state set zigbee.0.04cd15fffee03198.brightness "$brightness_value" iobroker state set zigbee.0.04cd15fffee03198.brightness "$brightness_value"
} }
set_colortemp() { set_colortemp() {
local colortemp_value=$1 local colortemp_value=$1
# Ersetze 'zigbee.0.04cd15fffee03198.colortemp' durch die tatsächliche ioBroker-Adresse für die Farbtemperatur # 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 # Die IP-Adresse von Lisas-IPhone holen und Ping-Test durchführen
check_ip() { check_ip() {
mac_address="e4:cd:d1" # Ersetze dies durch die MAC-Adresse mac_address="e4:cd:d1" # Ersetze dies durch die MAC-Adresse
attempts=20 attempts=10
interval=10 interval=5
for ((i = 1; i <= $attempts; i++)); do or ((i = 1; i <= $attempts; i++)); do
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 [ -n "$A72_ip" ]; then if [ -n "$A72_ip" ]; then
echo "Gefundene IP: $A72_ip" echo "Gefundene IP: $A72_ip"