Compare commits
No commits in common. "4761bfea0f4e10064ef3c54fa7a404f0ce544ab5" and "11ae8bfaf60cddfa9ccb51ac5c8606c8a9fef9bd" have entirely different histories.
4761bfea0f
...
11ae8bfaf6
@ -39,23 +39,25 @@ delete_expired_at_jobs() {
|
||||
# Verwende die Funktion, um überholte Jobs zu löschen
|
||||
delete_expired_at_jobs
|
||||
|
||||
# Die IP-Adresse von Lisas-IPhone holen und Ping-Test durchführen
|
||||
# Die IP-Adresse von Lisas-IPhone holen.
|
||||
check_ip() {
|
||||
mac_address="e4:cd:d1" # Ersetze dies durch die MAC-Adresse
|
||||
A72_ip=$(arp-scan --localnet | grep "$mac_address" | awk '{print $1}')
|
||||
|
||||
if [ -z "$A72_ip" ]; then
|
||||
echo "IP nicht gefunden. Ziel ist nicht erreichbar."
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Gefundene IP: $A72_ip"
|
||||
}
|
||||
|
||||
# Ping-Test durchführen
|
||||
# check_ip -Funktion ausführen.
|
||||
check_ip
|
||||
|
||||
# Datei zum Speichern der geplanten Weckzeiten
|
||||
weckzeit_datei="/root/iobroker_scripts/generel/.weckzeiten.txt"
|
||||
|
||||
# Überprüfen, ob das Ziel über Ping erreichbar ist
|
||||
function is_target_reachable() {
|
||||
echo "teste ping $A72_ip"
|
||||
local ping_output=$(/bin/ping -q -w 3 -c 3 $A72_ip 2>&1)
|
||||
local ping_exit_code=$?
|
||||
|
||||
|
||||
echo "$ping_output" # Ausgabe des Ping-Befehls anzeigen
|
||||
|
||||
if [ $ping_exit_code -eq 0 ] && [[ "$ping_output" == *"3 received"* ]]; then
|
||||
@ -64,44 +66,45 @@ check_ip() {
|
||||
else
|
||||
echo "Das Ziel ist nicht erreichbar. Exit Code: $ping_exit_code"
|
||||
return 1 # Fehler: Das Ziel ist nicht erreichbar
|
||||
fi
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
# check_ip -Funktion ausführen.
|
||||
check_ip || exit 1 # Beende das Skript, wenn das Ziel nicht erreichbar ist
|
||||
# Überprüfen, ob das Ziel erreichbar ist
|
||||
if is_target_reachable; then
|
||||
# Ziel ist erreichbar, Alarmzeit über SSH abrufen
|
||||
alarmTime=$(ssh -i /root/.ssh/A72 root@$A72_ip dumpsys alarm | grep -A 6 ":com.urbandroid.sleep.alarmclock.ALARM_ALERT" | grep "type=RTC_WAKEUP origWhen=" | cut -d= -f3 | cut -c1-16 | uniq)
|
||||
|
||||
# Datei zum Speichern der geplanten Weckzeiten
|
||||
weckzeit_datei="/root/iobroker_scripts/generel/.weckzeiten.txt"
|
||||
if [ -n "$alarmTime" ]; then
|
||||
# Zerlege das Datum und die Uhrzeit
|
||||
datum=$(echo "$alarmTime" | cut -d ' ' -f 1)
|
||||
uhrzeit=$(echo "$alarmTime" | cut -d ' ' -f 2)
|
||||
|
||||
# Ziel ist erreichbar, Alarmzeit über SSH abrufen
|
||||
alarmTime=$(ssh -i /root/.ssh/A72 root@$A72_ip dumpsys alarm | grep -A 6 ":com.urbandroid.sleep.alarmclock.ALARM_ALERT" | grep "type=RTC_WAKEUP origWhen=" | cut -d= -f3 | cut -c1-16 | uniq)
|
||||
# Formatiere das Datum und die Uhrzeit neu
|
||||
neues_format=$(date -d "$datum $uhrzeit" "+%H:%M %m/%d/%y")
|
||||
|
||||
if [ -n "$alarmTime" ]; then
|
||||
# Zerlege das Datum und die Uhrzeit
|
||||
datum=$(echo "$alarmTime" | cut -d ' ' -f 1)
|
||||
uhrzeit=$(echo "$alarmTime" | cut -d ' ' -f 2)
|
||||
# Subtrahiere 15 Minuten von der Zeit
|
||||
lightsOn=$(date -d "$neues_format - 15 minutes" "+%H:%M %m/%d/%y")
|
||||
|
||||
# Formatiere das Datum und die Uhrzeit neu
|
||||
neues_format=$(date -d "$datum $uhrzeit" "+%H:%M %m/%d/%y")
|
||||
echo "Nächster Wecker: $neues_format"
|
||||
echo "Lichter einschalten um: $lightsOn"
|
||||
|
||||
# Subtrahiere 15 Minuten von der Zeit
|
||||
lightsOn=$(date -d "$neues_format - 15 minutes" "+%H:%M %m/%d/%y")
|
||||
# Überprüfen, ob die Weckzeit bereits geplant ist
|
||||
if grep -Fxq "$lightsOn" "$weckzeit_datei"; then
|
||||
echo "Weckzeit ist bereits geplant für: $lightsOn"
|
||||
else
|
||||
echo "Weckzeit planen und in Datei speichern: $lightsOn"
|
||||
echo "$lightsOn" > "$weckzeit_datei"
|
||||
echo "/root/iobroker_scripts/schlafzimmer/wecker.sh > /root/wecker.log" | at "$lightsOn"
|
||||
curl -u "Michaelis:u5ptufUFuDL6q4yEcSN3iqas5gtXNkN77Lx3cy3oX8UoSgFWdifYy9FVopv2Zwtu" -H "Icon:https://static.vecteezy.com/system/resources/previews/018/931/118/original/alarm-clock-icon-png.png" -H "Priority:High" -d "Alarm gestellt um: $neues_format" https://ntfy.michaelis.digital/$HOSTNAME
|
||||
fi
|
||||
else
|
||||
echo "Kein Wecker gestellt. Lösche geplante Weckzeiten."
|
||||
#curl -u "Michaelis:u5ptufUFuDL6q4yEcSN3iqas5gtXNkN77Lx3cy3oX8UoSgFWdifYy9FVopv2Zwtu" -H "Icon:https://static.vecteezy.com/system/resources/previews/018/931/118/original/alarm-clock-icon-png.png" -H "Priority:High" -d "Alarm gelöscht" https://ntfy.michaelis.digital/$HOSTNAME
|
||||
|
||||
echo "Nächster Wecker: $neues_format"
|
||||
echo "Lichter einschalten um: $lightsOn"
|
||||
|
||||
# Überprüfen, ob die Weckzeit bereits geplant ist
|
||||
if grep -Fxq "$lightsOn" "$weckzeit_datei"; then
|
||||
echo "Weckzeit ist bereits geplant für: $lightsOn"
|
||||
rm "$weckzeit_datei"
|
||||
fi
|
||||
else
|
||||
echo "Weckzeit planen und in Datei speichern: $lightsOn"
|
||||
echo "$lightsOn" > "$weckzeit_datei"
|
||||
echo "/root/iobroker_scripts/schlafzimmer/wecker.sh > /root/wecker.log" | at "$lightsOn"
|
||||
curl -u "Michaelis:u5ptufUFuDL6q4yEcSN3iqas5gtXNkN77Lx3cy3oX8UoSgFWdifYy9FVopv2Zwtu" -H "Icon:https://static.vecteezy.com/system/resources/previews/018/931/118/original/alarm-clock-icon-png.png" -H "Priority:High" -d "Alarm gestellt um: $neues_format" https://ntfy.michaelis.digital/$HOSTNAME
|
||||
echo "Ziel ist nicht erreichbar."
|
||||
fi
|
||||
else
|
||||
echo "Kein Wecker gestellt. Lösche geplante Weckzeiten."
|
||||
#curl -u "Michaelis:u5ptufUFuDL6q4yEcSN3iqas5gtXNkN77Lx3cy3oX8UoSgFWdifYy9FVopv2Zwtu" -H "Icon:https://static.vecteezy.com/system/resources/previews/018/931/118/original/alarm-clock-icon-png.png" -H "Priority:High" -d "Alarm gelöscht" https://ntfy.michaelis.digital/$HOSTNAME
|
||||
|
||||
rm "$weckzeit_datei"
|
||||
fi
|
||||
|
||||
28
wecker.sh
28
wecker.sh
@ -39,32 +39,11 @@ set_color() {
|
||||
iobroker state set zigbee.0.04cd15fffee03198.color "$color_value"
|
||||
}
|
||||
|
||||
# Die IP-Adresse von Lisas-IPhone holen und Ping-Test durchführen
|
||||
# Die IP-Adresse von Lisas-IPhone holen.
|
||||
check_ip() {
|
||||
mac_address="e4:cd:d1" # Ersetze dies durch die MAC-Adresse
|
||||
A72_ip=$(arp-scan --localnet | grep "$mac_address" | awk '{print $1}')
|
||||
|
||||
if [ -z "$A72_ip" ]; then
|
||||
echo "IP nicht gefunden. Ziel ist nicht erreichbar."
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Gefundene IP: $A72_ip"
|
||||
|
||||
# Ping-Test durchführen
|
||||
echo "teste ping $A72_ip"
|
||||
local ping_output=$(/bin/ping -q -w 3 -c 3 $A72_ip 2>&1)
|
||||
local ping_exit_code=$?
|
||||
|
||||
echo "$ping_output" # Ausgabe des Ping-Befehls anzeigen
|
||||
|
||||
if [ $ping_exit_code -eq 0 ] && [[ "$ping_output" == *"3 received"* ]]; then
|
||||
echo "Das Ziel ist erreichbar."
|
||||
return 0 # Erfolg: Das Ziel ist erreichbar
|
||||
else
|
||||
echo "Das Ziel ist nicht erreichbar. Exit Code: $ping_exit_code"
|
||||
return 1 # Fehler: Das Ziel ist nicht erreichbar
|
||||
fi
|
||||
}
|
||||
|
||||
# check_ip -Funktion ausführen.
|
||||
@ -91,7 +70,6 @@ check_notification() {
|
||||
|
||||
for ((i = 1; i <= $max_attempts; i++)); do
|
||||
# Führe den SSH-Befehl innerhalb eines Timeout aus
|
||||
check_ip # IP holen
|
||||
output=$(ssh -i /root/.ssh/A72 root@$A72_ip 'dumpsys activity processes | grep com.urbandroid.sleep')
|
||||
echo $output
|
||||
|
||||
@ -162,13 +140,13 @@ colortemp_step=$(bc <<< "$start_colortemp / $steps")
|
||||
set_brightness "$current_brightness"
|
||||
set_colortemp "$current_colortemp"
|
||||
|
||||
sleep 30 # Änderungen alle 30 Sekunden
|
||||
sleep 27 # Änderungen alle 30 (27) Sekunden
|
||||
done
|
||||
|
||||
|
||||
# check_ip -Funktion ausführen.
|
||||
check_ip
|
||||
echo "$A72_ip"
|
||||
|
||||
# Starten des Alarm-Scripts auf dem Handy.
|
||||
ssh -i /root/.ssh/A72 root@$A72_ip '/data/scripts/morning-alarm.sh' > /root/morning_alarm.log
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user