Init project

This commit is contained in:
qvalentin 2023-12-09 13:02:00 +01:00
parent 728ad0f981
commit 0f044a1de7
3 changed files with 40 additions and 0 deletions

5
Makefile Normal file
View File

@ -0,0 +1,5 @@
install:
pip install -r requirements.txt
run:
FRITZ_PASSWORD=$$FRITZ_PASSWORD python main.py

34
main.py Normal file
View File

@ -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)

1
requirements.txt Normal file
View File

@ -0,0 +1 @@
fritzconnection==1.13.2