Ubiquiti AP Led Schedule

Ubiquiti | G2IT - IT Support & IT Services in Fremantle, Esperance, Perth

I have been using Ubiquiti access points for quite a while now, and never really had any major complaints. Yes there was was the data breach, which allegedly ubiquiti tried to cover up, but on the whole I really must admin that for the price paid, their access points really work well.

The setup I have is a relatively simple one. I have five access points around the house, 3 Vlans and a Raspberry PI 4 as the host for the controller software. Recently I had to add an access point inside the bedroom, which presented me with a problem. The blue led on the newer models can become very annoying at night. I looked around at the UI and found a place where it can be turned off or on. Surprisingly however, I could not find a way to schedule the led to turn on or off at a particular time.

SSH Access

After quick search on Google I found that the access points can be accessed via ssh, have a basic Linux shell. In order to enable ssh access you need to head to System Settings, open the Device SSH Authentication tab, and set a username and a password or public key. Both for security and convenience I strongly recommend using the public key. In my case I added the public key from the Raspberry PI which is always running anyway, so is just perfect for the task at hand.

Once the public key was added, I could login to the access point using

ssh {ssh-user}@{access point ip}

The greeting below was a sure sign of success !


BusyBox v1.25.1 () built-in shell (ash)


  ___ ___      .__________.__
 |   |   |____ |__\_  ____/__|
 |   |   /    \|  ||  __) |  |   (c) 2010-2020
 |   |  |   |  \  ||  \   |  |   Ubiquiti Networks, Inc.
 |______|___|  /__||__/   |__|
            |_/                  https://www.ui.com/

      Welcome to UniFi UAP-LRv2!

APBedroom-BZ.v4.3.28#

Led On, Led Off

Googling a bit further, revealed that the LEDs can be controlled via /proc/gpio/led_pattern. So literally if you echo a “0” or a “1” to that path on the AP, the LED of the access point will be turned off (0) or on (1).

echo 0 > /proc/gpio/led_pattern

Turns the LED off

echo 1 > /proc/gpio/led_pattern

Turns the LED on

So from here onward it was pretty straightforward. First things first, I set the access point(s) to a static IP’s. This will ensure reliable ssh access from the controller. Next, I set two cron jobs to run at the desired times to turn off and turn on the leds as required. The ssh commands to run to turn off and on the led are as follows :

ssh -o "StrictHostKeyChecking no" [email protected] 'echo 0 > /proc/gpio/led_pattern'
ssh -o "StrictHostKeyChecking no" [email protected] 'echo 1 > /proc/gpio/led_pattern'

ssh-user is the username we added to the Username field of the Device SSH Authentication tab. nnn.nnn.nnn.nnn is the IP address of the access point. StrictHostKeyChecking is set to no in this case, to avoid the prompt to verify host integrity the first time the job is run.

Scheduling the Jobs

The commands were scheduled using cron the syntax is below :

0 22 * * * ssh -o "StrictHostKeyChecking no" [email protected] 'echo 0 > /proc/gpio/led_pattern'
0  6 * * * ssh -o "StrictHostKeyChecking no" [email protected] 'echo 1 > /proc/gpio/led_pattern'

The above will turn off the AP leds at 22:00 hours, and turn them back on at 06:00. Hint : You can check your cron syntax at crontabguru.com

Conclusion

This workaround may seem a bit of an overkill, well it really is, however it solved what in my opinion is a huge missing feature in the Ubiquiti UI. Am also curious if anyone else out there found a different, simpler way to do it.

Leave a reply:

Your email address will not be published.

Site Footer