FritzBox Router-Status über die TR-064 API mit fritzconnection.
Folgende Befehle erfordern IMMER eine Rückfrage vor der Ausführung:
reconnect – Kappt die Internetverbindung für alle Geräte kurzzeitig (10-30 Sekunden)reboot – Startet den Router neu, alles fällt aus (Internet, WLAN, Telefonie) für 2-5 Minutenwlan on/off – Systemweite Auswirkung auf alle GeräteAusnahme: Nur wenn explizit genehmigt ("mach mal", "ja bitte", etc.)
Diese Befehle betreffen nicht nur den User, sondern alle Geräte und Personen im Netzwerk.
bash
cd ~/.openclaw/workspace/skills/fritz-status
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
In ~/.openclaw/skills/.env:
text
FRITZBOX_HOST=192.168.178.1
FRITZBOX_PASSWORD=dein_passwort
Hinweis: FritzBox nutzt nur Passwort-Auth, kein Username.
bash
cd ~/.openclaw/workspace/skills/fritz-status
# Router-Status (Model, Uptime, WAN-IP)
.venv/bin/python scripts/fritz_status.py status
# Traffic-Statistiken (Bytes In/Out, Downstream/Upstream)
.venv/bin/python scripts/fritz_status.py traffic
# Verbundene Geräte (Name, IP, MAC, Status)
.venv/bin/python scripts/fritz_status.py hosts -v
# WLAN-Status (2.4GHz, 5GHz, Gastzugang)
.venv/bin/python scripts/fritz_status.py wlan
# Anrufliste (letzte 10 Anrufe)
.venv/bin/python scripts/fritz_status.py calls
# Anrufliste (letzte 20 Anrufe)
.venv/bin/python scripts/fritz_status.py calls -n 20
# Reconnect (neue IP anfordern) ⚠️ Rückfrage erforderlich!
.venv/bin/python scripts/fritz_status.py reconnect
# Reboot (Router neu starten) ⚠️ Rückfrage erforderlich!
.venv/bin/python scripts/fritz_status.py reboot
status#Router-Status und Verbindungsinformationen.
Output:
text
🖥️ AVM FRITZ!Box 6660 Cable
📍 Host: 192.168.178.1
🔌 Connection: Connected
⏱️ Uptime: 456789 seconds (126h 49m)
🌐 External IP: 203.0.113.42
traffic#Bandbreite und Datenvolumen.
Output:
text
📥 Max Downstream: 274 Mbit/s
📤 Max Upstream: 52 Mbit/s
📊 Total Received: 299.68 GB
📊 Total Sent: 20.34 GB
hosts#Alle bekannten Geräte mit Status.
Output:
text
📱 Verbundene Geräte: 5
✅ Smartphone (192.168.178.10, AA:BB:CC:DD:EE:01)
✅ Laptop (192.168.178.20, AA:BB:CC:DD:EE:02)
✅ fritz.box (192.168.178.1, AA:BB:CC:DD:EE:03)
⏸️ Tablet (192.168.178.30, AA:BB:CC:DD:EE:04)
⏸️ SmartTV (192.168.178.40, AA:BB:CC:DD:EE:05)
Legende: ✅ = aktiv, ⏸️ = offline/inaktiv
wlan#WLAN-Status aller Netzwerke (2.4 GHz, 5 GHz, Gastzugang).
Output:
text
📡 WLAN-Status
📶 2.4 GHz:
Status: ✅ Enabled
SSID: MeinWLAN
Kanal: 6
Standard: ax
📡 5 GHz:
Status: ✅ Enabled
SSID: MeinWLAN
Kanal: 36
Standard: ax
🏠 Gastzugang:
Status: ❌ Disabled
SSID: MeinWLAN Gast
📡 WLAN ist AN
WLAN-Netzwerke:
calls#Anrufliste mit Typ, Nummer und Zeitstempel.
Output:
text
📋 Anrufliste (10 Einträge)
📞 Eingehend
📞 01234567890
🕐 03.03.2026 18:54 (0:39)
📵 Verpasst
📞 09876543210
🕐 02.03.2026 15:30 (0:00)
📱 Ausgehend
📞 017000000000
🕐 01.03.2026 12:15 (2:30)
📌 Letzter Anruf: 📞 Eingehend von 01234567890 am 03.03.26 18:54
Optionen:
-n, --limit N - Anzahl Einträge (default: 10)Call-Typen:
reconnect#Erzwingt einen Reconnect und fordert eine neue externe IP an.
bash
.venv/bin/python scripts/fritz_status.py reconnect
Output:
text
🔄 Reconnect angefordert. Warte auf neue Verbindung...
⚠️ Systemweiter Eingriff:
reboot#Startet die FRITZ!Box neu.
bash
.venv/bin/python scripts/fritz_status.py reboot
Output:
text
🔄 Reboot angefordert. Die FRITZ!Box startet jetzt neu.
⏱️ Das dauert normalerweise 2-5 Minuten.
📡 Alle Geräte verlieren die Verbindung (Internet, WLAN, Telefonie).
⚠️ Systemweiter Eingriff:
Python-Library für FritzBox TR-064 API.
Dokumentation: https://fritzconnection.readthedocs.io/
fritzconnection nutzt zwei unterschiedliche APIs:
APIMethodeVerwendungTR-064fc.call_action(service, action, args)Netzwerk, Status, Konfiguration, Smart HomeAHA-HTTPfc.call_http(command, ain)Smart Home DECT, Device Stats, XML-Responses
TR-064 gibt Python-Datentypen zurück (Dict mit konvertierten Werten). HTTP-Interface gibt rohe HTTP-Response (text/plain oder text/xml, braucht oft Parsen).
python
from fritzconnection import FritzConnection
fc = FritzConnection(address="192.168.178.1", password="pw")
# Router-Info
print(fc) # Model-Informationen
# TR-064: Neue IP via Reconnect
fc.call_action("WANIPConn1", "ForceTermination")
fc.reconnect() # Shortcut für obiges
# HTTP: Device-Stats für Smart-Home
response = fc.call_http("getbasicdevicestats", ain="12345 7891011")
ServiceBeschreibungStatusWANIPConnectionWAN-Status, IP, Uptime, Reconnect✅ ImplementiertWANCommonInterfaceConfigTraffic-Stats, Bandbreite✅ ImplementiertHostsVerbundene Geräte, MAC-Filter✅ ImplementiertDeviceInfoModel, Firmware, Serial✅ ImplementiertX_AVM-DE_OnTelAnrufliste, Telefonbuch✅ ImplementiertWLANConfigurationWLAN-Netzwerke, Gäste-WLAN✅ ImplementiertDeviceConfigRouter-Reboot✅ ImplementiertX_AVM-DE_HomeautoDECT-Smart-Home (Steckdosen, Thermostate)🔲 GeplantLANHostConfigManagementDHCP-Einstellungen🔲 Geplant
Die verfügbaren Services hängen vom Router-Modell und der Firmware ab.
python
# Gäste-WLAN an/aus
fc.call_action('WLANConfiguration:3', 'SetEnable', NewEnable=True)
# Haupt-WLAN an/aus (2.4 GHz)
fc.call_action('WLANConfiguration:1', 'SetEnable', NewEnable=False)
# Alle WLANs global an/aus
fc.call_action('WLANConfiguration:1', 'SetWLANGlobalEnable', NewWLANGlobalEnable=True)
python
# DECT-Geräte auflisten
devices = fc.call_action('X_AVM-DE_Homeauto', 'GetGenericDeviceInfos')
# Steckdose schalten
fc.call_action('X_AVM-DE_Homeauto', 'SetSwitch', NewSwitchState='ON')
python
# Device-Stats für ein DECT-Gerät
response = fc.call_http("getbasicdevicestats", ain="12345")
# Response enthält:
# - content-type: 'text/plain' oder 'text/xml'
# - encoding: z.B. 'utf-8'
# - content: Rohe Daten (muss geparst werden)
python
# CallList-URL holen
result = fc.call_action('X_AVM-DE_OnTel:1', 'GetCallList')
call_list_url = result.get("NewCallListURL")
# XML herunterladen und parsen
import urllib.request
import xml.etree.ElementTree as ET
with urllib.request.urlopen(call_list_url) as response:
xml_data = response.read()
root = ET.fromstring(xml_data)
for call in root.findall(".//Call"):
call_type = call.find("Type").text # 1=eingehend, 2=verpasst, 3=ausgehend
caller = call.find("Caller").text
timestamp = call.find("Date").text
python
from fritzconnection.lib.fritzcallmonitor import FritzCallMonitor
# Realtime-Monitor für eingehende/ausgehende Anrufe
monitor = FritzCallMonitor(address="192.168.178.1", password="pw")
monitor.connect()
# Events:
# - ring: Eingehender Anruf
# - call: Ausgehender Anruf
# - connect: Verbindung hergestellt
# - disconnect: Verbindung beendet
python
# WANIPConn1 - ForceTermination
fc.reconnect()
# Oder manuell:
fc.call_action("WANIPConn1", "ForceTermination")
python
# DeviceConfig:1 - Reboot
fc.call_action("DeviceConfig:1", "Reboot")
python
from scripts.fritz_status import FritzBoxClient
client = FritzBoxClient()
# Status
info = client.get_status()
print(info['model'], info['uptime'])
# Traffic
traffic = client.get_traffic()
print(traffic['bytes_received'], traffic['bytes_sent'])
# Hosts
hosts = client.get_hosts()
print(f"{hosts['count']} Geräte verbunden")
for device in hosts['devices']:
print(f" {device['name']}: {device['ip']} ({'active' if device['active'] else 'offline'})")
text
fritz-status/
├── SKILL.md # Diese Datei
├── requirements.txt # fritzconnection>=1.15.0
├── .gitignore
└── scripts/
└── fritz_status.py # CLI-Interface