-
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do you use this? #362
Comments
Hello. Sorry, I have completely missed your issue. A better documentation will be added soon to cover all the basic usage examples. For now, I can give you a couple of small examples: import aiohttp
import asyncio
from asusrouter import AsusRouter, AsusData
# Create a new event loop
loop = asyncio.get_event_loop()
# Create aiohttp session
session = aiohttp.ClientSession()
router = AsusRouter(
hostname="192.168.1.1",
username="admin",
password="admin",
use_ssl=True,
session=session,
)
# Connect to the router
loop.run_until_complete(router.async_connect())
# Now you can use the router object to call methods
data = loop.run_until_complete(router.async_get_data(AsusData.NETWORK))
print(data)
# Remember to disconnect and close the session when you're done
loop.run_until_complete(router.async_disconnect())
loop.run_until_complete(session.close()) E.g. you can ask for the following
Availability of data depends on your device model and FW version You can also set a state of something. E.g. with the base commands: from asusrouter.modules.led import AsusLED
from asusrouter.modules.parental_control import AsusParentalControl
from asusrouter.modules.port_forwarding import AsusPortForwarding
router.async_set_state(AsusLED.OFF)
router.async_set_state(AsusParentalControl.ON)
router.async_set_state(AsusPortForwarding.ON) Don't forget, that you need to run async methods properly, e.g. like shown in the example before |
thank you so much really appreciate it |
Hello, I try to disconnect and connect a client (talking about a device), but I struggle to find out how to do it. PS: Very nice work you have done! |
Hello, @odd86, There is no currently a possibility to disconnect one single client from the router. I would need to check whether this is possible at all. What is your use case for this? Do you want to:
All those would actually be different functions and they are not obligatory overlapping. But we can work on this |
Hello, I found a way and it is to use ParentControl. I made this function inside of a class async def toggle_internet_access(self, enable):
rule_type = PCRuleType.BLOCK if not enable else PCRuleType.DISABLE
rule = ParentalControlRule(mac=self.mac, type=rule_type)
success = await self.router.router.async_set_state(state=rule)
return success Then I keep track of the time the device is online before it is disconnected by a cronjob (if time is out). Thanks a lot for taking time to respond, and I hope my reply helps others :) |
Hello, Great project and it could be very useful. So, here is my question - there additional functions we have are because application or additional part of API, that is not documented yet ? Regards, |
How to use this? there are no examples or README has very limited information
The text was updated successfully, but these errors were encountered: