FirtzConnection - WLAN Passwort ändern

Wenn du dir nicht sicher bist, in welchem der anderen Foren du die Frage stellen sollst, dann bist du hier im Forum für allgemeine Fragen sicher richtig.
Antworten
Solderdot
User
Beiträge: 6
Registriert: Montag 6. Juli 2020, 16:02

Hallo zusammen,

irgndwie stehe ich auf dem Schlauch. Ich nutze fritzconnection unter Python3, um mit der FritzBox zu kommunizieren. Das klappt auch schon ganz gut, insbesonder kann ich alles mögliche auslesen. Allerdings kriege ich nichts verändert.

Code: Alles auswählen

from fritzconnection import FritzConnection

fc=FritzConnection(address='192.168.2.1', password='12345678', use_tls=True)
ssid = fc.call_action('WLANConfiguration:3', 'GetSSID')
print(ssid)
securityKeys = fc.call_action('WLANConfiguration:3', 'GetSecurityKeys')
print(securityKeys['NewKeyPassphrase'])
print(securityKeys)
Das klappt soweit. Die Ausgabe auf dem Bildschirm sieht erwartungsgemäß aus:

Code: Alles auswählen

{'NewSSID': 'MeineSSID'}
MeinPasswortIstGut
{'NewWEPKey0': '', 'NewWEPKey1': '', 'NewWEPKey2': '', 'NewWEPKey3': '', 'NewPreSharedKey': '###', 'NewKeyPassphrase': 'MeinPasswortIstGut'}
Nun möchte ich NewKeyPassphrase ändern. Das sollte mittels

Code: Alles auswählen

fc.call_action('WLANConfiguration:3', 'SetSecurityKeys')
irgendwie gehen, aber ich krieg's nicht auf die Reihe, wie ich da Parameter übergeben kann.

Ich probiere z.B.

Code: Alles auswählen

result = fc.call_action('WLANConfiguration:3', 'SetSecurityKeys', NewWEPKey0=' ', NewWEPKey1=' ', NewWEPKey2=' ', NewWEPKey3=' ',  NewPreSharedKey=' ', NewKeyPassphrase="12345678")
print (result)
und erhalte

Code: Alles auswählen

Traceback (most recent call last):
  File "./wlan.py", line 19, in <module>
    result = fc.call_action('WLANConfiguration:3', 'SetSecurityKeys', NewWEPKey0=' ', NewWEPKey1=' ', NewWEPKey2=' ', NewWEPKey3=' ', NewPreSharedKey=' ', NewKeyPassphrase="12345678")
  File "/usr/local/lib/python3.7/dist-packages/fritzconnection/core/fritzconnection.py", line 220, in call_action
    return self.soaper.execute(service, action_name, arguments)
  File "/usr/local/lib/python3.7/dist-packages/fritzconnection/core/soaper.py", line 233, in execute
    return handle_response(response)
  File "/usr/local/lib/python3.7/dist-packages/fritzconnection/core/soaper.py", line 218, in handle_response
    raise_fritzconnection_error(response)
  File "/usr/local/lib/python3.7/dist-packages/fritzconnection/core/soaper.py", line 147, in raise_fritzconnection_error
    raise exception(message)
fritzconnection.core.exceptions.FritzArgumentError: UPnPError:
errorCode: 402
errorDescription: Invalid Args
Ich würd mich über ein kleine Starthilfe freuen.

Vielen Dank im Voraus
-- Solderdot
Benutzeravatar
__blackjack__
User
Beiträge: 14031
Registriert: Samstag 2. Juni 2018, 10:21
Wohnort: 127.0.0.1
Kontaktdaten:

Starthilfe wäre die Dokumentation von der `call_action()`-Methode, die verrät wie Argumente übergeben werden, und explizit sagt, dass zusätzliche Schlüsselwortargumente ignoriert werden. Kann man sich dann natürlich fragen warum die Methode die überhaupt annimmt, aber es ist halt deutlich dokumentiert das die ignoriert werden.
„A life is like a garden. Perfect moments can be had, but not preserved, except in memory. LLAP” — Leonard Nimoy's last tweet.
Antworten