Schedule LED on/off Unifi controller

As you may or may not know by now, I am passionate Unifi user, and all of my networking equipment is based on their products. Recently, my son told me that LED light that was coming from LR Access Point mounted on the hallway wall is bothering him during night and that he can not sleep.

Of course, that was just lame attempt to not go to sleep 🙂 , but it got me thinking that it would definitely be cool feature to have in Unifi controller. My controller is running in Ubuntu virtual machine in Azure, so this was a case of creating two scripts that would use Cron to run and turn off and on all LED light on all APs.

My controller is set up to control LED status of all devices and devices are set up to obey controllers settings.

After some time on tinkering and searching I came up with viable solution that works, until UBQT exposes it in GUI of the controller. You can vote for this feature here.

Script to turn OFF LED lights:


username=Admin username
password=Admin password

curl_cmd="curl --tlsv1 --silent --cookie ${cookie} --cookie-jar ${cookie} --insecure "
${curl_cmd} --data "{'username':'$username', 'password':'$password'}" $baseurl/api/login

${curl_cmd} --data "{ 'led_enabled': false}" $baseurl/api/s/$site/set/setting/mgmt

Script to turn ON LED lights:


username=Admin username
password=Admin password

curl_cmd="curl --tlsv1 --silent --cookie ${cookie} --cookie-jar ${cookie} --insecure "
${curl_cmd} --data "{'username':'$username', 'password':'$password'}" $baseurl/api/login

${curl_cmd} --data "{ 'led_enabled': true}" $baseurl/api/s/$site/set/setting/mgmt

Notice the only difference is in line 12, true or false. If you want this to run on your first created site, value for variable site should default. If you want it to run on different site in controller, use site name for value.

I have created two files on Ubuntu and saved them as .sh so they can be executed. Nano is my preferred editor although I have been seen using vi editor in extreme situations :).

Do not forget to use  chmod command so the file can be executed.

chmod +x

After that, by simple editing Crontab with

Crontab -e

and adding these lines in it

0 21 * * * /PathToYourFiles/ >/dev/null 2>&1
0 8 * * * /PathToYourFiles/ >/dev/null 2>&1

I have scheduled LED lights to go off every day at 21:00 and to turn on every day at 08:00.

If you are not familiar with Cron syntax I can recommend you this easy to use online Cron generator. For some of these action you will need root privileges. Script can also be set at user level instead of root which is the recommended way.

Scripts could definitely be modified to turn on or off selected APs and not all of them, but I do not have that many so this works for me. Feel free to comment and add your input.

You May Also Like

About the Author: Marin

Started as trainer and administrator in Algebra, 5 years later became head of operating systems department at Algebra private college. At that time, he became IT Pro group lead and 5-year Microsoft MVP. Joined Microsoft in 2014. and after covering roles of Infrastructure and Azure TSP for 4 years, moved to Span to take the role of Senior Solutions Architect for cloud solutions. Currently holds Microsoft Azure MVP award. Personal time is occupied by enjoying short trips with his family and close friends, tinkering with home automation and networking and spending money on too many gadgets.


  1. Thanks for the script, any idea why why the login call could fail ? anything obvious that I’m missing is welcome as I’m a noob here (well, besides username and password being wrong 🙂 )

    1. sorry I even forgot to give you the error:


    2. Hi, sudo as root and try the script manually. If that works than the issue may be crontab. It is also possible that some Unifi Controller update changed some API calls. 🙁

    3. It seems I’ve somehow nailed it down and I don’t know exactly how, but still can be useful to share.
      I’ve swapped the double tick ” and the single ‘ in the json body as below:

      ${curl_cmd} –data ‘{“username”:”myusername”,”password”:”mypassword”}’ $baseurl/api/login
      ${curl_cmd} –data ‘{“led_enabled”: false}’ $baseurl/api/s/$site/set/setting/mgmt

      and then replaced variable $username and $password with their value, since I don’t know how to escape in bash.
      I’ve experienced the same behavior on both my Linux-On-Windows bash and the resinOs on my raspberry with

      Thanks for helping!

  2. Never had the blue light turn off. After the firmware update the blue led turned off at 10 pm. It was distressing as it was always on so we restated. Cleaned it. The next night it turned off so I unplugged and air dusted. Finally I found this article and realized this probably swayed them to make a blanket assumption everyone want the light off. We feel the blue light is assurance its working. Otherwise the dream machine is dark and silent without fan giving no indication its on.

    I write this in hopes another novice like myself searching for answers about the LED that has been on for years and is now a forced timer that turns off leaving the dream machine seemingly dead but it’s not.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.