32 lines
999 B
Python
32 lines
999 B
Python
import asyncio
|
|
from sagemcom_api.enums import EncryptionMethod
|
|
from sagemcom_api.client import SagemcomClient
|
|
|
|
HOST = "192.168.0.1"
|
|
USERNAME = "admin"
|
|
PASSWORD = "DJZZEZMX"
|
|
ENCRYPTION_METHOD = EncryptionMethod.MD5 # or EncryptionMethod.SHA512
|
|
|
|
async def main() -> None:
|
|
async with SagemcomClient(HOST, USERNAME, PASSWORD, ENCRYPTION_METHOD) as client:
|
|
try:
|
|
await client.login()
|
|
except Exception as exception: # pylint: disable=broad-except
|
|
print(exception)
|
|
return
|
|
# Print device information of Sagemcom F@st router
|
|
device_info = await client.get_device_info()
|
|
print(f"{device_info.id} {device_info.model_name}")
|
|
|
|
# Print connected devices
|
|
devices = await client.get_hosts()
|
|
|
|
for device in devices:
|
|
if device.active:
|
|
print(f"{device.id} - {device.name}")
|
|
|
|
output= await client.reboot()
|
|
print(output)
|
|
test = input()
|
|
asyncio.run(main())
|