diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..bc0773f --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +install: + pip install -r requirements.txt + +run: + FRITZ_PASSWORD=$$FRITZ_PASSWORD python main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..2358319 --- /dev/null +++ b/main.py @@ -0,0 +1,34 @@ +from itertools import count + +from fritzconnection import FritzConnection +from fritzconnection.core.exceptions import FritzServiceError +from fritzconnection.core.fritzconnection import os + + +def turn_of_wlan(fc): + result = [] + action = "SetEnable" + for n in count(1): + service = f"WLANConfiguration{n}" + try: + fc.call_action(service, action, NewEnable=False) + except FritzServiceError: + break + result.append(f"Turned off {service}") + return result + + +def main(address, password): + fc = FritzConnection(address=address, password=password) + for result in turn_of_wlan(fc): + print(f"{result}") + + +if __name__ == "__main__": + try: + password = os.environ["FRITZ_PASSWORD"] + except KeyError: + print("Error: FRITZ_PASSWORD environment variable not set.") + exit(1) + + main(address="192.168.178.1", password=password) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..4166c88 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +fritzconnection==1.13.2