Giter VIP home page Giter VIP logo

omada-api's Introduction

Omada API

A simple Python wrapper for the TP-Link Omada Software Controller API.

Test Python versions

Resources

Here are some links which may be helpful when using or extending this library:

Usage

Currently this is just the bare-minimum required to log in, get site settings, push site settings, and log out.

from omada import Omada

# load our local config file
omada = Omada('omada.cfg')

# or specify the baseurl and site name directly
#omada = Omada(baseurl='https://...', site='Office')

# log into the controller (username and password are in omada.cfg)
omada.login()

# or specify the username and password directly
# omada.login(username='apiuser', password='secretpassword')

# get the site settings
settings = omada.getSiteSettings()

# turn the LEDs off
settings['led']['enable'] = False

# push the settings back
omada.setSiteSettings(settings)

# log out of the controller
omada.logout()

Examples

I use this in a cron schedule to turn my site LED setting off at night and back on in the morning.

Turn the LED on:

$ python led.py on
led: on

Turn the LED off:

$ python led.py off
led: off

These are simple apps to display similar output to the "Clients" and "Devices" page on the web interface.

$ python clients.py
USERNAME            IP ADDRESS      STATUS
00-11-22-33-44-55   192.168.1.123   CONNECTED
...

Make sure you have your Settings file configured correctly for these to work.

Settings

You can store your controller settings in a configuration file to avoid hard-coding them in your scripts.

Currently supported settings:

  • baseurl - the base url to the controller
  • site - the name of the site in the controller (usually Default)
  • verify - set this to False to ignore self-signed certificate errors
  • warnings - set this to False to hide urllib3 warnings when verify=False
  • verbose - set this to True to force low-level reqeusts to output debugging info
  • username - the username to log in as
  • password - the password for the user

Example

[omada]
baseurl = https://omadacontroller.local:8043
site = Default
verify = False
username = apiuser
password = secretpassword

Acknowledgements

For my wife, who asked that I turn off the device LEDs at night. ❤️

omada-api's People

Contributors

ghaberek avatar sreggy avatar gdepeyrot avatar f6f avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.