Skip to content

Instantly share code, notes, and snippets.

@calmh
Created February 5, 2014 08:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calmh/8819249 to your computer and use it in GitHub Desktop.
Save calmh/8819249 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import argparse
from unifi.controller import Controller
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--controller', default='unifi', help='the controller address (default "unifi")')
parser.add_argument('-u', '--username', default='admin', help='the controller usernane (default("admin")')
parser.add_argument('-p', '--password', default='', help='the controller password')
parser.add_argument('-v', '--version', default='v2', help='the controller base version (default "v2")')
parser.add_argument('-s', '--siteid', default='default', help='the site ID, UniFi >=3.x only (default "default")')
parser.add_argument('aps', metavar='AP', type=str, nargs='+', help='Name of an AP')
args = parser.parse_args()
c = Controller(args.controller, args.username, args.password, args.version, args.siteid)
aps = c.get_aps()
print 'These AP:s exist:'
for ap in aps:
print ' - "%s"' % ap['name']
for ap in args.aps:
print 'Rebooting: "%s"' % ap
c.restart_ap_name(ap)
@calmh
Copy link
Author

calmh commented Feb 5, 2014

This works for me:

jb@jborg-mbp:~/src/github.com/calmh/unifi-api (master) $ ./unifi-reboot-ap -c unifi.int.nym.se -p password --version v3 --siteid default  unifi-garage
These AP:s exist:
 - "unifi-garage"
 - "unifi-livingroom"
 - "unifi-study"
Rebooting: "unifi-garage"
jb@jborg-mbp:~/src/github.com/calmh/unifi-api (master) $ 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment